Micro-interactions

Tear

A ticket with a perforated stub you tear off for real. The ticket is drawn twice and cut from one seeded jag polygon: an attached layer holds everything still connected, the body plus the stub below the tear front, and a flap layer holds only the freed part, rotated about the frontmost attached point, so the torn edges mate tooth for tooth and the swing can never overlap the body. The seam fights back through a resistance curve, a failed tear springs shut, and a completed one lets the stub fall under gravity carrying the release velocity. The jag array comes from a seeded PRNG so the edge never boils between renders.

Install

# Tear needs no npm packages

Then copy 2 files into your project:

  • components/registry/tear/tear.tsx
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
perforationAtnumber0.62Where the seam sits across the ticket.
jagnumber0.6Roughness of the torn edge — 0 is a die-cut, 1 is a bad day.
teethnumber26Perforation tooth count; also the resolution of the torn edge.
resistancenumber0.6How hard the seam fights before it lets go.
gravitynumber1How fast the freed stub falls away.
autoResetbooleantrueHeal the ticket after the stub is gone.
resetDelaynumber1800Dwell before the ticket heals.
inkColorstring (hex)"#c4b5fd"The ticket's printed ink — title, seat block, barcode.

What It Demonstrates

Drag
Moving an element by grabbing it, often with momentum when released.
Rubber-banding
Resistance and snap-back when you drag past a boundary (the iOS overscroll feel).
Clip-path
Clipping an element to a shape, used for reveals, masks, and before/after sliders.
Velocity
How fast and in which direction an element is moving. A spring carries it into the next animation when interrupted, so a flicked element keeps its speed.

Related Components

Appears In