Framer Motion

作者 pproencacf93c57cac89无许可证215 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7周前更新

Framer Motion performance optimization guidelines. This skill should be used when writing, reviewing, or refactoring React animations with Framer Motion to ensure optimal performance patterns. Triggers on tasks involving motion components, animations, gestures, layout transitions, scroll-linked effects, and SVG animations.

AI 生成的概览

用于优化 React 应用中 Framer Motion 动画性能的指南。

功能
该技能提供按优先级排列的 42 条规则,分为 9 个类别,用于编写、审查和重构 React 中的 Framer Motion 动画。内容涵盖打包优化、避免重复渲染、动画属性、布局过渡、滚动效果、手势、弹簧动画、SVG 动画和退出动画。每条规则都有独立的参考文件,包含说明和代码示例,并提供用于新增规则的模板。
适用场景
适用于使用 Framer Motion 为 React 组件添加动画、优化动画密集型应用的打包体积、避免动画期间不必要的重复渲染,或实现布局、滚动联动、手势及 SVG 动画的场景。
运行要求
无需脚本或运行时依赖,仅为说明性技能。假定使用者正在使用 React 和 Framer Motion 库。

Community Framer Motion Best Practices

Comprehensive performance optimization guide for Framer Motion animations in React applications. Contains 42 rules across 9 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Adding animations to React components with Framer Motion
  • Optimizing bundle size for animation-heavy applications
  • Preventing unnecessary re-renders during animations
  • Implementing layout transitions or shared element animations
  • Building scroll-linked or gesture-based interactions

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Bundle OptimizationCRITICALbundle-
2Re-render PreventionCRITICALrerender-
3Animation PropertiesHIGHanim-
4Layout AnimationsHIGHlayout-
5Scroll AnimationsMEDIUM-HIGHscroll-
6Gesture OptimizationMEDIUMgesture-
7Spring & PhysicsMEDIUMspring-
8SVG & Path AnimationsLOW-MEDIUMsvg-
9Exit AnimationsLOWexit-

Quick Reference

1. Bundle Optimization (CRITICAL)

  • bundle-lazy-motion [blocked] - Use LazyMotion and m component instead of motion
  • bundle-dynamic-features [blocked] - Dynamically import motion features
  • bundle-dom-animation [blocked] - Use domAnimation for basic animations
  • bundle-use-animate-mini [blocked] - Use mini useAnimate for simple cases
  • bundle-strict-mode [blocked] - Enable strict mode to catch accidental imports

2. Re-render Prevention (CRITICAL)

  • rerender-motion-value [blocked] - Use useMotionValue instead of useState
  • rerender-use-transform [blocked] - Derive values with useTransform
  • rerender-stable-callbacks [blocked] - Keep animation callbacks stable
  • rerender-variants-object [blocked] - Define variants outside component
  • rerender-animate-prop [blocked] - Use stable animate values
  • rerender-motion-value-event [blocked] - Use motion value events

3. Animation Properties (HIGH)

  • anim-transform-properties [blocked] - Animate transform properties
  • anim-opacity-filter [blocked] - Prefer opacity and filter for visual effects
  • anim-hardware-acceleration [blocked] - Leverage hardware acceleration
  • anim-will-change [blocked] - Use willChange prop judiciously
  • anim-independent-transforms [blocked] - Animate transforms independently
  • anim-keyframes-array [blocked] - Use keyframe arrays for sequences

4. Layout Animations (HIGH)

  • layout-dependency [blocked] - Use layoutDependency to limit measurements
  • layout-position-size [blocked] - Use layout="position" or "size" appropriately
  • layout-group [blocked] - Group related layout animations
  • layout-id-shared [blocked] - Use layoutId for shared element transitions
  • layout-scroll [blocked] - Add layoutScroll to scrollable ancestors

5. Scroll Animations (MEDIUM-HIGH)

  • scroll-use-scroll [blocked] - Use useScroll hook for scroll-linked animations
  • scroll-use-spring-smooth [blocked] - Smooth scroll animations with useSpring
  • scroll-element-tracking [blocked] - Track specific elements entering viewport
  • scroll-offset-configuration [blocked] - Configure scroll offsets
  • scroll-container-ref [blocked] - Track scroll within specific containers

6. Gesture Optimization (MEDIUM)

  • gesture-while-props [blocked] - Use whileHover/whileTap instead of handlers
  • gesture-variants-flow [blocked] - Let gesture variants flow to children
  • gesture-drag-constraints [blocked] - Use dragConstraints ref for boundaries
  • gesture-drag-elastic [blocked] - Configure dragElastic for natural feel
  • gesture-tap-cancel [blocked] - Use onTapCancel for interrupted gestures

7. Spring & Physics (MEDIUM)

  • spring-physics-based [blocked] - Use physics-based springs for interruptibility
  • spring-damping-ratio [blocked] - Configure damping to control oscillation
  • spring-mass-inertia [blocked] - Adjust mass for heavier/lighter feel
  • spring-use-spring-hook [blocked] - Use useSpring for reactive values

8. SVG & Path Animations (LOW-MEDIUM)

  • svg-path-length [blocked] - Use pathLength for line drawing animations
  • svg-motion-components [blocked] - Use motion.path and motion.circle
  • svg-viewbox-animation [blocked] - Animate viewBox for zoom effects
  • svg-morph-matching-points [blocked] - Match point counts for morphing

9. Exit Animations (LOW)

  • exit-animate-presence [blocked] - Wrap conditional renders with AnimatePresence
  • exit-unique-keys [blocked] - Provide unique keys for AnimatePresence children
  • exit-mode-wait [blocked] - Use mode="wait" for sequential transitions

How to Use

Read individual reference files for detailed explanations and code examples:

  • Section definitions [blocked] - Category structure and impact levels
  • Rule template [blocked] - Template for adding new rules

Reference Files

FileDescription
references/_sections.md [blocked]Category definitions and ordering
assets/templates/_template.md [blocked]Template for new rules
metadata.json [blocked]Version and reference information

来源与署名

来源:pproenca/dot-skills位于skills/.experimental/framer-motion提交cf93c57

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架