agentleFS
ne11nnne11nn/cantos-plugin/skills/motion-animations/SKILL.md

motion-animations

Skill1 starsChanged 5 months agoMITView on GitHub

Use when building website animations, scroll effects, entrance reveals, layout transitions, gesture interactions, parallax, hero choreography, or any animated UI component. Auto-trigger on any website build or frontend feature that involves motion, transitions, or animated elements.

  • Installs packages

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Next.js RSC: use "use client" directive on any component with motion

    line 12
  2. Very specific:

    Every HTML/SVG element has a motion.* counterpart.

    line 18
  3. Very specific:

    Always set viewport={{ once: true }} unless bidirectional reveal is intentional.

    line 48
  4. Distinctive:

    Use variants for coordinated parent-to-child animations:

    line 52

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Motion Animations

Reference skill for building production animations with the Motion library (formerly Framer Motion). Consult this before writing any animation code.

Install: npm install motion Import: import { motion, AnimatePresence } from "motion/react" Next.js RSC: use "use client" directive on any component with motion


Core Concept

Every HTML/SVG element has a motion.* counterpart. Animation is declarative via props:

<motion.div
  initial={{ opacity: 0, y: 20 }}
  animate={{ opacity: 1, y: 0 }}
  exit={{ opacity: 0 }}
  transition={{ type: "spring", stiffness: 200, damping: 20 }}
/>

Animatable properties: x, y, scale, rotate, opacity, filter, clipPath, backgroundColor, borderRadius, boxShadow. Height can animate to/from "auto".


Pattern Catalog

1. Entrance Animations (scroll-triggered)

The default for any element appearing on scroll:

<motion.div
  initial={{ opacity: 0, y: 40 }}
  whileInView={{ opacity: 1, y: 0 }}
  viewport={{ once: true, amount: 0.3 }}
  transition={{ duration: 0.6, ease: "easeOut" }}
/>

Always set viewport={{ once: true }} unless bidirectional reveal is intentional.

2. Staggered List Entrance

Use variants for coordinated parent-to-child animations:

const container = {
  hidden: {},
  visible: { transition: { staggerChildren: 0.06, delayChildren: 0.1 } }
}
const item = {
  hidden: { opacity: 0, y: 16 },
  visible: { opacity: 1, y: 0, transition: { type: "spring", bounce: 0.3 } }
}

<motion.ul variants={container} initial="hidden" whileInView="visible" viewport={{ once: true }}>
  {items.map(i => <motion.li key={i} variants={item} />)}
</motion.ul>

Children inherit initial/animate labels automatically from parent — only need variants prop.

3. Exit Animations

AnimatePresence holds elements in DOM until exit completes:

<AnimatePresence mode="wait">
  {isVisible && (
    <motion.div
      key="unique"
      initial={{ opacity: 0, scale: 0.95 }}
      animate={{ opacity: 1, scale: 1 }}
      exit={{ opacity: 0, scale: 0.95 }}
    />
  )}
</AnimatePresence>

Modes: "sync" (simultaneous), "wait" (exit before enter), "popLayout" (exiting pops out of flow).

4. Scroll-Linked Animations (parallax, progress)

const ref = useRef(null)
const { scrollYProgress } = useScroll({
  target: ref,
  offset: ["start end", "end start"]
})
const y = useTransform(scrollYProgress, [0, 1], ["-20%", "20%"])

<div ref={ref}>
  <motion.img style={{ y }} />
</div>

Offset format: "[element edge] [viewport edge]" — "start end" means element top hits viewport bottom.

Progress bar:

const { scrollYProgress } = useScroll()
<motion.div style={{ scaleX: scrollYProgress, transformOrigin: "left" }} />

Clip-path reveal:

const clipPath = useTransform(scrollYProgress, [0, 0.4],
  ["inset(100% 0% 0% 0%)", "inset(0% 0% 0% 0%)"])
<motion.img style={{ clipPath }} />

Horizontal scroll (panels):

const { scrollYProgress } = useScroll({ target: containerRef })
const x = useTransform(scrollYProgress, [0, 1], ["0%", "-75%"])
<div ref={containerRef} style={{ height: "400vh" }}>
  <div style={{ position: "sticky", top: 0, overflow: "hidden" }}>
    <motion.div style={{ x, display: "flex" }}>{panels}</motion.div>
  </div>
</div>

5. Layout Animations

Auto-animate any DOM layout change:

<motion.div layout />

Shared element transitions (thumbnail to modal, tab switches):

// Grid item
<motion.div layoutId={`card-${id}`} onClick={() => setSelected(id)} />

// Expanded modal
<AnimatePresence>
  {selected && <motion.div layoutId={`card-${selected}`} className="modal" />}
</AnimatePresence>

Layout prop values: true (position + size), "position", "size", "preserve-aspect".

6. Gesture Animations

<motion.button
  whileHover={{ scale: 1.05, backgroundColor: "#f0f0f0" }}
  whileTap={{ scale: 0.97 }}
  whileFocus={{ outline: "2px solid blue" }}
/>

Drag:

<motion.div
  drag
  dragConstraints={constraintsRef}
  dragElastic={0.2}
  whileDrag={{ scale: 1.1, boxShadow: "0 10px 30px rgba(0,0,0,0.2)" }}
/>

7. Timeline Sequences (hero choreography)

import { animate, stagger } from "motion"

const sequence = [
  ["nav", { opacity: 1 }, { duration: 0.5 }],
  ["h1", { opacity: 1, y: 0 }, { at: "<" }],       // simultaneous
  ["p", { opacity: 1 }, { at: "+0.2" }],            // 0.2s after previous
  ["button", { opacity: 1, scale: 1 }, { at: 2.0 }] // absolute time
]
const controls = animate(sequence)

at values: "<" (with previous), "+0.5" (after previous), "<0.3" (after previous starts), 2.0 (absolute).

8. Physics Effects

Magnetic button:

const mouseX = useMotionValue(0), mouseY = useMotionValue(0)
const x = useSpring(mouseX, { stiffness: 150, damping: 15 })
const y = useSpring(mouseY, { stiffness: 150, damping: 15 })
// onMouseMove: set mouseX/Y to (cursor offset from center) * 0.3

Velocity-aware skew:

const xVelocity = useVelocity(x)
const skewX = useTransform(xVelocity, [-2000, 0, 2000], [-15, 0, 15])

Counter without re-renders:

const count = useMotionValue(0)
const rounded = useTransform(count, v => Math.round(v))
animate(count, 1000, { duration: 2, ease: "easeOut" })
<motion.span>{rounded}</motion.span>

Transitions

TypeConfig
Spring{ type: "spring", stiffness: 200, damping: 20 } or { type: "spring", bounce: 0.3, duration: 0.6 }
Tween{ type: "tween", duration: 0.5, ease: "easeOut" }
Keyframesanimate={{ x: [0, 100, 50] }} with times: [0, 0.5, 1]
Per-propertytransition={{ default: { type: "spring" }, opacity: { duration: 0.3 } }}

Easing: "linear", "easeIn", "easeOut", "easeInOut", "circOut", "backOut", "anticipate", or [0.17, 0.67, 0.83, 0.67].

Global defaults:

<MotionConfig transition={{ duration: 0.3, ease: "easeOut" }}>
  <App />
</MotionConfig>

Performance Rules (non-negotiable)

  1. Only animate transform and opacity — these are GPU-composited. Never animate width, height, top, left, padding, margin.
  2. Use MotionValues for high-frequency updates — useMotionValue, useTransform, useSpring bypass React renders entirely. Use these for scroll, drag, and mouse-tracking effects.
  3. Set viewport={{ once: true }} on scroll-triggered animations unless bidirectional is intentional.
  4. Use initial={false} to skip entrance animations on SSR/first render.
  5. Wrap app in <MotionConfig reducedMotion="user"> for accessibility.

Bundle optimization: Full motion is ~34kb. Use LazyMotion + m component for lighter builds (4.6kb + lazy features).


API Quick Reference

Hook/ComponentPurpose
motion.divDeclarative animation component
AnimatePresenceMount/unmount transitions
useScrollScroll position tracking
useTransformMap/derive MotionValues
useMotionValueReactive primitive (no re-renders)
useSpringSpring-physics MotionValue
useVelocityTrack rate of change
useAnimateScoped imperative animations
useInViewViewport detection (0.6kb)
MotionConfigGlobal defaults + accessibility
animate()Imperative + timeline sequences
stagger()Cascading delays

For full API details, see reference.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.