feel.js

Gestures that feel right.

12 interactions you can grab, tune and copy. Rubber banding, momentum, springs you can interrupt. One tiny file, no dependencies.

Use it

import { drag, spring, rubberClamp, snap } from './feel.js';

const x = spring(0, { onUpdate: v => (el.style.transform = `translateX(${v}px)`) });
drag(el, {
  axis: 'x',
  onMove: ({ dx }) => x.set(rubberClamp(start + dx, 0, max, width)),
  onEnd: ({ vx }) => x.to(snap(x.value, vx, [0, max]), { velocity: vx }),
});

rubberband resistance past an edge · project where a flick lands · snap nearest snap point to that · Velocity least-squares pointer velocity · spring interruptible, keeps velocity · drag pointer capture, threshold, axis lock · clock one frame loop, steppable