Skip to content

Options ​

ts
createBend(element, options?: BendOptions): BendInstance;

All options are optional. They are read once at creation; there is no setOptions. Destroy and recreate to change the feel.

Top-level ​

OptionTypeDefaultNotes
preset"edge" | "surface""edge"What drives the displacement
axis"x" | "y""y"Axis for geometry, input, and rendering
resistancenumber | { wheel?, touch? }{ wheel: 5, touch: 3 }Divisor on cumulative gesture distance
curve"linear" | "ease""linear"Shape applied after resistance
max{ px?, ratio? }{ px: 120, ratio: 0.18 }Pull ceiling
spring{ stiffness?, damping?, mass? }{ stiffness: 200, damping: 25, mass: 1 }Integrator configuration
render"transform" | "cssVar""transform"How displacement reaches the DOM
lagFactornumber0.04surface only; seconds of lag
ignore(element: Element) => boolean—Leave matching gesture origins alone
releaseDelaynumber140edge only; ms of quiet before release
respectReducedMotionbooleantrueMake the effect inert under reduced motion
debugbooleanfalseLog contract violations once

resistance ​

A plain number applies to every input class. The object form tunes wheel and touch apart; a key that is not named keeps its default.

ts
createBend(el, { resistance: 4 });                 // both classes
createBend(el, { resistance: { touch: 6 } });      // wheel keeps 5
createBend(el, { resistance: { wheel: 8, touch: 4 } });

Resistance is a divisor, so a higher number means a heavier band. It applies to the cumulative gesture distance, never to a single event. Switching input class mid-gesture starts a new gesture rather than reusing the running sum.

curve ​

ValueFormula
"linear"d / resistance
"ease"`limit × (1 − exp(−

ease starts with the same slope as linear and saturates toward the pull limit, so long gestures keep moving the band a little instead of pinning it.

max ​

The effective ceiling is min(px, ratio × viewport), so a phone does not get a desktop-sized pull.

KeyTypeDefaultMeaning
pxnumber120Absolute ceiling in CSS pixels
rationumber0.18Ceiling as a fraction of the viewport

spring ​

KeyTypeDefaultMeaning
stiffnessnumber200Restoring force, in s⁻²
dampingnumber25Energy loss, in s⁻¹
massnumber1Inertia

Critical damping is 2 × sqrt(stiffness × mass). The default ratio is about 0.88, so the band overshoots slightly before settling.

lagFactor ​

surface only. The target is -velocity × lagFactor, so the value is the number of seconds the band behaves as if it were behind the scroll. Larger is heavier.

ignore ​

Receives the wheel or touch origin and returns true to leave that gesture alone. Use it for nested scrollers or widgets that should keep their own input.

ts
createBend(el, {
  ignore: (origin) => origin.closest("[data-own-scroll]") !== null,
});

releaseDelay ​

edge only. Milliseconds of wheel quiet before the band releases and springs back. Touch releases on touchend regardless.

respectReducedMotion ​

When true and the user prefers reduced motion, createBend returns an inert instance: state stays idle, subscribe never fires, no listener is installed, and the DOM is untouched.

debug ​

Logs contract violations once: an element that already has a transform, or a position: fixed descendant that will move with the band. It does not change behaviour.

Full type ​

ts
interface BendOptions {
  preset?: "edge" | "surface";
  axis?: "x" | "y";
  resistance?: number | { wheel?: number; touch?: number };
  curve?: "linear" | "ease";
  max?: { px?: number; ratio?: number };
  spring?: { stiffness?: number; damping?: number; mass?: number };
  render?: "transform" | "cssVar";
  lagFactor?: number;
  ignore?: (element: Element) => boolean;
  releaseDelay?: number;
  respectReducedMotion?: boolean;
  debug?: boolean;
}

Elastic scroll displacement that never touches scroll.