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 從公開儲存庫中收錄這些內容。

檢舉或申請下架