โœฆ StealThis .dev
Patterns Medium

Gesture Animations

Collection of gesture-based animations including hover scale, tap shrink, drag with constraints, and focus glow. Each gesture type demonstrates a different interaction pattern.

Open in Lab
css javascript vue svelte
Targets: TS JS HTML React Vue Svelte

Code

Gesture Animations

A showcase of four distinct gesture-driven animations, each responding to a different user interaction.

Gestures included

  1. Hover Scale โ€” element smoothly scales up on mouseenter and back on mouseleave
  2. Tap Shrink โ€” element shrinks on pointerdown and bounces back on pointerup
  3. Drag with Constraints โ€” element follows the pointer within a bounding box, snaps back on release
  4. Focus Glow โ€” input gains an animated glow ring on focus, fades on blur

How it works

  • All animations use requestAnimationFrame with lerp for smooth interpolation
  • No CSS transitions needed โ€” JS drives every frame for precise, interruptible control
  • Drag constraints are enforced by clamping coordinates to a parent containerโ€™s bounds

Use cases

  • Interactive buttons and cards
  • Micro-interactions for form elements
  • Playful UI elements in portfolios / landing pages