animation

Animation Implementation with Motion

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "animation" with this command: npx skills add adrsource/adr-source-v2/adrsource-adr-source-v2-animation

Animation Implementation with Motion

Use the Motion library (https://motion.dev) for all animation work.

Quick Start

React (Primary):

import { motion } from "motion/react"

// Basic animation <motion.div animate={{ opacity: 1, y: 0 }} />

// With transition config <motion.div animate={{ x: 100 }} transition={{ type: "spring", stiffness: 100 }} />

Core Patterns

  1. Spring Physics (Preferred)

<motion.div animate={{ scale: 1 }} transition={{ type: 'spring', stiffness: 260, damping: 20, }} />

Spring presets:

  • Gentle: stiffness: 120, damping: 14

  • Wobbly: stiffness: 180, damping: 12

  • Stiff: stiffness: 300, damping: 20

  1. Gesture Interactions

<motion.div whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} drag="x" dragConstraints={{ left: -100, right: 100 }} />

  1. Layout Animations

<motion.div layout>{/* Content that changes position/size */}</motion.div>

  1. Scroll-Linked Effects

import { useScroll, useTransform } from "motion/react"

const { scrollYProgress } = useScroll() const opacity = useTransform(scrollYProgress, [0, 1], [1, 0])

<motion.div style={{ opacity }} />

  1. Stagger Children

<motion.ul variants={{ visible: { transition: { staggerChildren: 0.07 } }, }}

{items.map((item) => ( <motion.li key={item} variants={{ hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0 }, }} /> ))} </motion.ul>

  1. Enter/Exit Animations

import { AnimatePresence } from 'motion/react';

<AnimatePresence> {show && <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} />} </AnimatePresence>;

Animation Properties

Transform (GPU-accelerated, performant):

  • x, y, z

  • Translate

  • scale, scaleX, scaleY

  • Scale

  • rotate, rotateX, rotateY, rotateZ

  • Rotation

  • skew, skewX, skewY

  • Skew

Visual (use sparingly, can affect performance):

  • opacity

  • background, backgroundColor

  • color

  • borderRadius

SVG-specific:

  • pathLength

  • For path drawing animations

  • pathOffset

  • Offset the path

  • pathSpacing

  • Spacing between dashes

Accessibility

Always respect user preferences:

<motion.div animate={{ x: 100 }} transition={{ type: 'spring', // Disables animation if user prefers reduced motion duration: 0, }} />

Motion automatically handles prefers-reduced-motion . Springs become instant transitions.

Performance Tips

  • Animate transforms/opacity only when possible (GPU-accelerated)

  • Use layout prop instead of animating width/height manually

  • Avoid animating during scroll when possible

  • Use will-change: transform for complex animations (Motion handles this)

  • Limit simultaneous animations - stagger instead of all-at-once

Design Principles (Brief)

When to Animate

  • State transitions (loading → success)

  • Spatial changes (entering/exiting view)

  • Drawing attention (sparingly)

  • Confirming user action

When NOT to Animate

  • Repeated actions after first occurrence

  • Performance-critical paths

  • User-controlled scrolling

  • Every single interaction (restraint matters)

Timing Guidelines

  • Micro-interactions: 150-250ms

  • Panel/modal transitions: 200-300ms

  • Page transitions: 300-500ms

  • Springs: Let physics determine duration

Spring vs Duration

  • Use springs for: Interactive elements, gestures, layout changes

  • Use duration for: Intentional sequences, choreography, loaders

See principles.md for detailed animation philosophy.

Common Patterns

Loading state:

<motion.div animate={{ rotate: 360 }} transition={{ repeat: Infinity, duration: 1, ease: 'linear', }} />

Toast notification:

<motion.div initial={{ x: 400, opacity: 0 }} animate={{ x: 0, opacity: 1 }} exit={{ x: 400, opacity: 0 }} transition={{ type: 'spring', stiffness: 300, damping: 30 }} />

Drawer:

<motion.div initial={{ x: '-100%' }} animate={{ x: 0 }} exit={{ x: '-100%' }} transition={{ type: 'spring', damping: 25 }} />

Accordion:

<motion.div animate={{ height: isOpen ? 'auto' : 0 }} transition={{ type: 'spring', bounce: 0 }} style={{ overflow: 'hidden' }} />

Resources

Quick Troubleshooting

Animation not running?

  • Check if element is conditionally rendered (use AnimatePresence)

  • Verify target values are different from initial values

  • Check for CSS that might override (e.g., !important )

Performance issues?

  • Stick to transforms and opacity

  • Use layout prop instead of animating dimensions

  • Check browser DevTools Performance tab

Layout animations flickering?

  • Ensure parent has position: relative

  • Add layout to both parent and child if needed

  • Check for conflicting CSS transitions

Notes

  • Motion is MIT licensed, production-ready

  • Hybrid engine: 120fps, GPU-accelerated

  • TypeScript support built-in

  • Tree-shakable for optimal bundle size

  • Works with React 18+ (including Suspense)

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

animation

No summary provided by upstream source.

Repository SourceNeeds Review
General

ai-image-generator

AI 图片与视频异步生成技能,调用 AI Artist API 根据文本提示词生成图片或视频,自动轮询直到任务完成。 ⚠️ 使用前必须设置环境变量 AI_ARTIST_TOKEN 为你自己的 API Key! 获取 API Key:访问 https://staging.kocgo.vip/index 注册登录后创建。 支持图片模型:SEEDREAM5_0(默认高质量图片)、NANO_BANANA_2(轻量快速)。 支持视频模型:SEEDANCE_1_5_PRO(文生视频,支持音频)、SORA2(文生视频或首尾帧图生视频,支持 firstImageUrl/lastImageUrl)。 触发场景: - 用户要求生成图片,如"生成一匹狼"、"画一只猫"、"风景画"、"帮我画"等。 - 用户要求生成视频,如"生成视频"、"用 SORA2 生成"、"文生视频"、"图生视频"、"生成一段...的视频"等。 - 用户指定模型:SEEDREAM5_0、NANO_BANANA_2、SEEDANCE_1_5_PRO、SORA2。

Archived SourceRecently Updated
General

淘宝投放数据分析

# 投放数据分析技能

Archived SourceRecently Updated
General

productclank-campaigns

Community-powered growth for builders. Boost amplifies your social posts with authentic community engagement (replies, likes, reposts). Discover finds relevant conversations and generates AI-powered replies at scale. Use Boost when the user has a post URL. Use Discover when the user wants to find and engage in conversations about their product.

Archived SourceRecently Updated