Cursor move and drag

Moves the pointer across the product and drags something, the way a person would.

Rendered video, with motion blur.

0.00 / 2.60 s

Live preview, driven by the code below. No motion blur.

What it does

The pointer travels on a gentle arc, pauses, presses, then drags an item that trails just behind it and settles on release.

Curve

Ease in-out cubic

Values

S is the frame's short side, 1080 px at 1080p. Unmeasured inputs in the preview are illustrations, not rules.

FactValue
Purpose
Emphasis
Acts on
Pointer, card
Typical length
0.6 to 1 s (18 to 30 frames at 30 fps), per 50% S of travel
Caution
No accent-coloured cursor, and one pointer only.
PropertyValue
Path
Gentle arc, bow 10 to 15% of the distance
Curve
Ease in-out cubic
Speed
About 0.6 to 1.0 s per 50% S (540 px) of travel
Pause before pressing
0.2 s
Press
Scale 0.86 over 0.14 s
Dragged item
Follows the pointer 2 frames behind
Release
Settle
Export samples
12; 1 when still

Starting values from research. Measure against a reference before relying on them.

Code

ts
export const seg = (t: number, a: number, b: number) => Math.max(0, Math.min(1, (t - a) / (b - a)));

export const lerp = (a: number, b: number, k: number) => a + (b - a) * k;

export const out = (k: number) => (k >= 1 ? 1 : 1 - Math.pow(2, -10 * k));

export const io = (k: number) => (k < 0.5 ? 16 * k ** 5 : 1 - Math.pow(-2 * k + 2, 5) / 2);

export const inn = (k: number) => k * k * k;

export const cubicOut = (k: number) => 1 - Math.pow(1 - k, 3);

export const h = (i: number, j: number) => { const x = Math.sin(i * 127.1 + j * 311.7) * 43758.5453; return x - Math.floor(x); };

export const phase = (t: number, start = 0, duration = 0.6) => seg(t, start, start + duration);

export const easeInOut = (p: number) => p < 0.5 ? 4 * p ** 3 : 1 - (-2 * p + 2) ** 3 / 2;

export const settle = (t: number, A = 220) => A * Math.exp(-3.8 * Math.max(0, t));

export function cursorMoveAndDrag(t: number, fromX: number, fromY: number, grabX: number, grabY: number, dropX: number, dropY: number, travel = 0.8, drag = 0.8) {
  const leg = (tt: number, ax: number, ay: number, bx: number, by: number, start: number, dur: number) => {
    const p = phase(tt, start, dur);
    const k = easeInOut(p);
    const bow = 0.12 * Math.hypot(bx - ax, by - ay) * Math.sin(Math.PI * k);
    return { x: lerp(ax, bx, k), y: lerp(ay, by, k) - bow };
  };
  const dragStart = travel + 0.2 + 0.14;
  const at = (tt: number) => tt < dragStart ? leg(tt, fromX, fromY, grabX, grabY, 0, travel) : leg(tt, grabX, grabY, dropX, dropY, dragStart, drag);
  const pressed = t + 1e-9 >= travel + 0.2 && t < dragStart + drag;
  const c = at(t);
  const lag = at(Math.max(dragStart, t - 2 / 30));
  const released = t >= dragStart + drag;
  // On release the item settles from where it trails onto the drop point.
  const rest = Math.exp(-15 * Math.max(0, t - dragStart - drag));
  const itemX = t < dragStart ? grabX : released ? dropX + (lag.x - dropX) * rest : lag.x;
  const itemY = t < dragStart ? grabY : released ? dropY + (lag.y - dropY) * rest : lag.y;
  return { x: c.x, y: c.y, scale: pressed ? 0.86 : 1, itemX, itemY };
}

Best practices

Use it forAvoid
Showing how a product is used
An accent-coloured cursor
Reordering, sorting and dropping files
More than one pointer

Reduced motion: a simple opacity fade over 0.2 s.