@animaly/react
v0.2.2
Published
motion's React API (motion components, variants, gestures, AnimatePresence, hooks) running on animaly.
Maintainers
Readme
@animaly/react
motion's React API running on animaly. Replace the import and keep your components:
import { AnimatePresence, motion, useScroll, useTransform } from "@animaly/react";
const list = { visible: { transition: { staggerChildren: 0.05 } } };
const item = { hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0 } };
export function List({ items }: { items: string[] }) {
const { scrollYProgress } = useScroll();
const scale = useTransform(scrollYProgress, [0, 1], [1, 0.9]);
return (
<motion.ul initial="hidden" animate="visible" variants={list} style={{ scale }}>
<AnimatePresence>
{items.map((text) => (
<motion.li key={text} variants={item} exit={{ opacity: 0 }} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }}>
{text}
</motion.li>
))}
</AnimatePresence>
</motion.ul>
);
}Animated styles are written by animaly's renderer in one pass per frame, not by a listener per value. A motion value in style is bound to the element and rendered in the same pass.
Supported:
motion.*components andmotion.create(), withinitial,animate,exit,variants,transition,transitionEnd,custom,inherit,transformTemplate, thevaluesprop, motion values instyleand as children- variants with propagation,
staggerChildren,delayChildren,staggerDirectionandwhen whileHover,whileTap,whileFocus,whileInViewand their callbacks (onHoverStart,onTap,onTapCancel,onViewportEnterand the rest),globalTapTarget,propagate={{ tap: false }}AnimatePresencewithmode(sync,wait,popLayout),initial={false},custom,propagate,onExitComplete, plususePresence,useIsPresentandusePresenceDataMotionConfig(transition,reducedMotion,skipAnimations,isStatic,nonce,isValidProp)useMotionValue,useMotionValueEvent,useTransform,useMotionTemplate,useSpring,useVelocity,useScroll,useInView,useAnimate,useAnimation/useAnimationControls,useCycle,useReducedMotion- server rendering: components render their initial styles to HTML without a DOM
Checked against motion v13.4.6: 342 of motion's own React tests (motion components, variants, gestures, AnimatePresence, MotionConfig, hooks) run against this package in Chromium, Firefox and WebKit.
Known differences:
MotionValue.get()returns the live animated value at the moment it is called; motion returns the value of the last frame. A value read right after an animation starts is already slightly past its first keyframe.- Colors with
MotionGlobalConfig.mixunset must be hex,rgb(),rgba(),hsl()orhsla().
Not yet: layout animations (layout, layoutId, LayoutGroup), drag, Reorder, LazyMotion and m.
Pre-release: the API can still change. Parts of motion are ported under its MIT license; see NOTICE.
