Animation skill · Mobile

Gesture physics

Drag, swipe and fling with momentum, snapping and rubber-banding.

Give this skill to your AI agent

Run this in your project. Claude Code picks it up from .claude/skills; for other agents, paste the file into their rules.

mkdir -p .claude/skills/gesture-physics && curl -fsSL https://kitesmotion.com/skills/gesture-physics/SKILL.md -o .claude/skills/gesture-physics/SKILL.md
Download SKILL.md

Things the user touches should follow the finger exactly, then hand off to physics when let go.

Principles

  1. 1:1 tracking: while dragging, the element moves exactly with the pointer. No easing during the drag.
  2. Velocity handoff: on release, start a spring or decay with the finger's velocity.
  3. Rubber-banding: past a limit, resistance grows: offset = limit + (overshoot * 0.55) or 1 - 1 / (x * 0.55 / d + 1) scaled.
  4. Projection: decide where to snap using the projected end point, end = position + velocity * 0.2, not just the release point.
  5. Interruptible: touching an element mid-animation catches it where it is.

Swipe to dismiss

  • Dismiss if dragged past 30-40% of the size or flung faster than about 800px/s.
  • Rotate cards slightly with horizontal drag (about 10deg at the edge).
  • Otherwise spring back (stiffness 400, damping 30).

Bottom sheets

  • Detents at about 30%, 60% and 95% of the screen height; snap to the nearest projected detent.
  • Dim the background in proportion to the sheet height.

Carousels

  • Snap per item with scroll snapping where possible (scroll-snap-type: x mandatory).
  • Custom carousels: decay with friction, then spring to the nearest item.

Tools

  • Web: Framer Motion drag with dragConstraints, dragElastic and onDragEnd velocity, or pointer events with setPointerCapture.
  • React Native: Gesture Handler plus Reanimated withSpring and withDecay, running on the UI thread.
  • SwiftUI: DragGesture with predictedEndTranslation and spring animations.

Accessibility

  • Every gesture needs a button or keyboard alternative.
  • Add light haptics at snap points on mobile.

More skills