motion

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Motion is an open-source animation library for JavaScript, React, and Vue. It provides a simple API with first-class support for multiple platforms, a hybrid animation engine combining JavaScript with native browser APIs for 120fps GPU-accelerated animations, and production-ready features including TypeScript support, extensive test suite, tree-shakable builds, and a tiny footprint. Batteries included: gestures, springs, layout transitions, scroll-linked effects, and timelines.
The skill is based on Motion v12.29.2, generated at 2026-02-01.
Motion是一款适用于JavaScript、React和Vue的开源动画库。它提供简洁的API,对多平台提供一流支持,采用结合JavaScript与原生浏览器API的混合动画引擎,可实现120fps的GPU加速动画,同时具备生产就绪的特性,包括TypeScript支持、全面的测试套件、可摇树优化的构建以及极小的体积。内置功能丰富:手势、弹簧动画、布局过渡、滚动关联效果和时间轴。
本技能基于Motion v12.29.2,生成于2026-02-01。

Core References

核心参考

TopicDescriptionReference
Motion ComponentsBasic motion components (motion.div, motion.svg, etc.)core-components
Basic Animationanimate prop, initial, while statescore-animation
JavaScript animate()Vanilla animate(), sequences, createScopedAnimatecore-javascript-animate
Vanilla scroll()Imperative scroll() and scrollInfo() for non-Reactcore-vanilla-scroll
motionValueCreate MotionValues without Reactcore-vanilla-motion-value
staggerOrchestrate child delays in variantscore-stagger
frame / cancelFrameMotion's animation loopcore-frameloop
motion/miniMinimal bundle entrycore-motion-mini
VariantsDeclarative animation variants and orchestrationcore-variants
TransitionsAnimation timing, easing, spring physicscore-transitions
主题描述参考链接
Motion组件基础运动组件(motion.div、motion.svg等)core-components
基础动画animate属性、initial状态、while状态core-animation
JavaScript animate()原生animate()、序列动画、createScopedAnimatecore-javascript-animate
原生scroll()非React环境下的命令式scroll()和scrollInfo()core-vanilla-scroll
motionValue无需React即可创建MotionValuescore-vanilla-motion-value
stagger在变体中协调子元素的延迟动画core-stagger
frame / cancelFrameMotion的动画循环core-frameloop
motion/mini极简包入口core-motion-mini
Variants声明式动画变体与编排core-variants
Transitions动画时序、缓动效果、弹簧物理特性core-transitions

Motion Values

运动值

TopicDescriptionReference
useMotionValueCreate and use motion values for reactive animationsvalues-motion-value
useSpringSpring-based motion values with physicsvalues-spring
useTransformTransform motion values with functionsvalues-transform
useMotionTemplateCombine motion values into a string (e.g. filter, boxShadow)values-motion-template
useFollowValueMotion value that follows a source with any transitionvalues-follow
useScrollScroll-linked motion values and animationsvalues-scroll
useVelocityAccess velocity of motion valuesvalues-velocity
useTimeTime-based motion valuesvalues-time
useWillChangeGPU layer hint for animating elementsvalues-will-change
主题描述参考链接
useMotionValue创建并使用运动值实现响应式动画values-motion-value
useSpring基于物理特性的弹簧运动值values-spring
useTransform通过函数转换运动值values-transform
useMotionTemplate将运动值组合为字符串(如filter、boxShadow)values-motion-template
useFollowValue跟随源值的运动值,支持任意过渡效果values-follow
useScroll滚动关联的运动值与动画values-scroll
useVelocity获取运动值的速度values-velocity
useTime基于时间的运动值values-time
useWillChange为动画元素提供GPU层提示values-will-change

Gestures

手势

TopicDescriptionReference
DragDrag gestures with constraints and controlsgestures-drag
PanPan gestures for touch and pointer eventsgestures-pan
Tap & PressTap and press gesture handlersgestures-tap-press
Hover & FocusHover and focus state animationsgestures-hover-focus
主题描述参考链接
Drag带约束与控制的拖拽手势gestures-drag
Pan适用于触摸与指针事件的平移手势gestures-pan
Tap & Press点击与长按手势处理器gestures-tap-press
Hover & Focus悬停与聚焦状态动画gestures-hover-focus

Layout Animations

布局动画

TopicDescriptionReference
AnimatePresenceAnimate components entering and exitinglayout-animate-presence
usePresence / useIsPresentAccess presence state in AnimatePresence childrenlayout-use-presence
usePresenceDataRead AnimatePresence custom prop in descendantslayout-presence-data
LayoutGroupCoordinate layout animations across componentslayout-group
Layout AnimationsAutomatic layout animations with layoutIdlayout-animations
ReorderDrag-to-reorder with layout animationslayout-reorder
useInstantLayoutTransitionBlock layout update for one framelayout-instant-transition
useResetProjectionReset layout projection tree after structural changelayout-reset-projection
主题描述参考链接
AnimatePresence为组件的进入与退出添加动画layout-animate-presence
usePresence / useIsPresent在AnimatePresence子组件中获取存在状态layout-use-presence
usePresenceData在后代组件中读取AnimatePresence的自定义属性layout-presence-data
LayoutGroup跨组件协调布局动画layout-group
Layout Animations使用layoutId实现自动布局动画layout-animations
Reorder带布局动画的拖拽重排layout-reorder
useInstantLayoutTransition暂停一帧的布局更新layout-instant-transition
useResetProjection结构变化后重置布局投影树layout-reset-projection

Features

功能特性

TopicDescriptionReference
In ViewuseInView, inView(), usePageInView for viewport/visibilityfeatures-in-view
Resizeresize() observer for window or element sizefeatures-resize
Optimized AppearSSR-friendly appear animations with handofffeatures-optimized-appear
SVG PathpathLength, pathOffset, pathSpacing for path animationsfeatures-svg-path
motion/clientNext.js "use client" and tree-shakable componentsfeatures-react-client
主题描述参考链接
In ViewuseInView、inView()、usePageInView用于视口/可见性检测features-in-view
Resize监听窗口或元素尺寸变化的resize()观察者features-resize
Optimized Appear支持SSR的优化入场动画,具备交接机制features-optimized-appear
SVG Path用于路径动画的pathLength、pathOffset、pathSpacingfeatures-svg-path
motion/clientNext.js的"use client"与可摇树组件features-react-client

Utils

工具函数

TopicDescriptionReference
useReducedMotionHooks for reduced motion preferenceutils-reduced-motion
useAnimationFrameFrame-synced callback with Motion's looputils-animation-frame
useCycleCycle through a list of statesutils-cycle
useMotionValueEventSubscribe to motion value eventsutils-motion-value-event
delayFrame-synced delayed executionutils-delay
interpolateMap input range to outpututils-interpolate
useDomEventAttach DOM event listenersutils-dom-event
useInstantTransitionBlock layout animations during updateutils-instant-transition
calcLength / createBox / distanceProjection geometry and distanceutils-path-geometry
主题描述参考链接
useReducedMotion适配减少动画偏好的钩子utils-reduced-motion
useAnimationFrame与Motion循环同步的帧回调utils-animation-frame
useCycle在一组状态间循环切换utils-cycle
useMotionValueEvent订阅运动值事件utils-motion-value-event
delay与帧同步的延迟执行utils-delay
interpolate将输入范围映射到输出utils-interpolate
useDomEvent绑定DOM事件监听器utils-dom-event
useInstantTransition更新期间阻止布局动画utils-instant-transition
calcLength / createBox / distance投影几何与距离计算utils-path-geometry

Advanced

进阶内容

TopicDescriptionReference
Animation ControlsProgrammatic animation control with useAnimationadvanced-animation-controls
useAnimateImperative animation APIadvanced-use-animate
LazyMotionCode-split animations for better performanceadvanced-lazy-motion
MotionConfigGlobal configuration and reduced motionadvanced-motion-config
Scroll AnimationsScroll-linked animations and parallax effectsadvanced-scroll-animations
transformTemplateCustom transform outputadvanced-transform-template
addScaleCorrectorLayout projection scale correctorsadvanced-scale-corrector
主题描述参考链接
Animation Controls使用useAnimation实现程序化动画控制advanced-animation-controls
useAnimate命令式动画APIadvanced-use-animate
LazyMotion代码分割动画以提升性能advanced-lazy-motion
MotionConfig全局配置与减少动画设置advanced-motion-config
Scroll Animations滚动关联动画与视差效果advanced-scroll-animations
transformTemplate自定义转换输出advanced-transform-template
addScaleCorrector布局投影缩放校正器advanced-scale-corrector

Best Practices

最佳实践

TopicDescriptionReference
Bundle SizeEntry points and optimization strategiesbest-practices-bundle
主题描述参考链接
Bundle Size入口点与优化策略best-practices-bundle