Chuyển đến nội dung
Skillpedia
Giao diện (UI/UX)280k · #211

motion-advanced

Skill này làm gì

Công cụ này cho phép bạn tạo hoạt ảnh phức tạp và tương tác cho website xây dựng bằng React hoặc Next.js. Nó giúp các phần tử di chuyển, phản hồi khi chạm, hoặc thay đổi hình dạng, như hình vẽ xuất hiện dần hoặc chữ tự gõ ra.

Khi nào nên dùng

  • ✓Khi bạn muốn một phần tử có thể kéo được trên màn hình.
  • ✓Khi muốn chữ xuất hiện từng chữ cái hoặc từng từ.
  • ✓Khi tạo hình SVG có hoạt ảnh hoặc nút thay đổi khi di chuột qua.

Liên kết skill

https://github.com/affaan-m/ECC/blob/main/pi/core/skills/motion-advanced/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/motion-advanced/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tạo một hoạt ảnh để một thẻ có thể kéo sang ngang và biến mất nếu kéo quá xa.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Bên trong, công cụ dùng các kỹ thuật nâng cao để điều khiển chuyển động của phần tử trên màn hình. Nó có thể tạo hoạt ảnh liên tục hoặc theo chuỗi, đảm bảo mọi thứ chạy mượt và không bị giật, kể cả trên thiết bị cảm ứng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Motion Advanced

Complex, interactive, and physics-based animation patterns. Requires motion-foundations to be set up first. Use these when motion-patterns is not enough.

When to Activate

  • Building drag-to-dismiss sheets, swipe gestures, or reorderable lists
  • Animating text word-by-word, character-by-character, or as a live counter
  • Drawing SVG paths, morphing icons, or animating circular progress
  • Writing a custom animation hook (useScrollReveal, magnetic button, cursor follower)
  • Sequencing multi-step animations imperatively with useAnimate
  • Building spinners, shimmer skeletons, pulse indicators, or loading button states

Outputs

This skill produces:

  • Drag interactions: draggable cards, drag-to-dismiss sheets, Reorder.Group lists
  • Gesture hooks: swipe detection, long press, pinch outline
  • Text animation components: word reveal, character typewriter, number counter
  • SVG animation: path draw-on, icon morph, stroke progress ring
  • Custom hooks: useScrollReveal, useHoverScale, useNavigationDirection, useInViewOnce
  • Imperative sequences via useAnimate with interrupt-safe async/await
  • Loader components: spinner, shimmer, pulse dot, progress bar, button loading state

Principles

  • Physics-based motion (useSpring, springs.*) always feels more natural than duration-based for direct manipulation.
  • useMotionValue + useTransform computes derived values without triggering re-renders.
  • useAnimate sequences are imperative and interrupt-safe — calling animate() mid-flight cancels the previous animation automatically.
  • Motion values (useMotionValue, useSpring) are SSR-safe and do not cause hydration errors.

Rules

  1. Drag interactions must be tested on touch devices, not just mouse. drag prop works on both but feel and threshold differ.
  2. Infinite animations must pause when document.visibilityState === "hidden". Background tabs must not consume GPU/CPU.
  3. Swipe threshold must be explicit. Never infer intent from velocity alone; combine offset + velocity checks.
  4. useAnimate scope ref must be attached to a mounted DOM element. Calling animate() before mount throws silently.
  5. Motion values must not be recreated on render. useMotionValue(0) inside a component body is correct; new MotionValue(0) in a render is not.
  6. All token values are imported from motion-foundations. No inline numbers.
  7. Custom hooks must handle cleanup. Every window.addEventListener needs a matching removeEventListener in the useEffect return.
  8. SVG morphing requires equal path command counts. Paths with different command structures snap instead of interpolating.

Decision Guidance

Choosing the right advanced API

Scenario API
Drag with physics on release drag + dragTransition: springs.release
Ordered drag-to-reorder list Reorder.Group + Reorder.Item
Dismiss on drag offset drag="y" + onDragEnd offset check
Swipe left/right drag="x" + onDragEnd offset check
Long press useLongPress hook
Value smoothed over time useSpring
Value derived from another useTransform
Multi-step sequence useAnimate with async/await
One-shot imperative animation animate() from motion
Text entering word by word Stagger on inline-block spans
SVG drawing on pathLength 0 → 1
SVG morph d attribute tween (equal commands)
Circular progress strokeDashoffset tween

When to use useSpring vs a spring transition

useSpring transition: springs.*
Use for Cursor follower, pointer-tracked values Discrete state changes
Updates Continuous, on every frame Triggered by state change
Interrupt Smooth — physics picks up from velocity Restarts from current value

Core Concepts

useMotionValue + useTransform

Reactive computation without re-renders:

const x = useMotionValue(0)
const opacity = useTransform(x, [-200, 0, 200], [0, 1, 0])
// opacity updates every frame as x changes — no setState, no re-render

useAnimate

Returns [scope, animate]. The scope ref must be attached to a DOM element. animate() calls are interrupt-safe — calling mid-flight cancels the previous run.

const [scope, animate] = useAnimate()


…
Câu hỏi thường gặp

Tôi có cần là lập trình viên giỏi để dùng nó không?

Bạn không cần quá giỏi, nhưng nên có kiến thức cơ bản về React hoặc Next.js, vì công cụ này là phần mở rộng cho các môi trường đó.

Có dùng được trên mọi website không?

Công cụ này chỉ dành riêng cho các dự án dùng thư viện React hoặc Next.js.

Tôi có thể tạo hoạt ảnh có cảm giác vật lý, giống thế giới thực không?

Có, công cụ cho phép tạo hoạt ảnh dựa trên nguyên lý vật lý, giúp chuyển động tự nhiên và thực tế hơn, đặc biệt với các tương tác như kéo thả.

Chi tiết

Mô tả gốc của tác giả

Advanced motion patterns for React / Next.js — drag & drop, gestures, text animations, SVG path drawing, custom hooks, imperative sequences (useAnimate), loaders, and the full API decision tree. Requires motion-foundations. Use when building drag and drop, gestures, text or SVG animation, or imperative animation sequences in React or Next.js.

repo: affaan-m/ECC

Độ phổ biến

Sao GitHub
280k
Vị trí xếp hạng
#211
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự