Never hijacks scroll
No preventDefault, no scroll writes, no touch-action tricks. Every input listener is passive, so trackpads, wheels, keyboards, scrollbars, and screen readers keep working.
The page scrolls natively. A small spring-driven offset follows your gestures at the document edges, or trails behind scroll velocity, and springs back.
npm install elastixbendimport { createBend } from "elastixbend";
const bend = createBend(document.querySelector("#stage")!, {
preset: "edge",
});
// later
bend.destroy();That is the whole setup. #stage gets a translate3d while you pull past the top or bottom of the page, and returns to rest when you stop.
Both presets share the scheduler, spring integrator, clamp, and renderer. They differ only in what drives the target.
| Preset | Driven by | Use it when |
|---|---|---|
edge | Wheel and touch gestures past the document edge | You want a rubber band at the top and bottom of a page or panel |
surface | Scroll velocity, whatever produced it | Content should lean and catch up, including with keyboard, scrollbar, or programmatic scroll |
createBend(el, { preset: "surface", lagFactor: 0.04 });The default renderer owns style.transform. If the element already has one, or if a position: fixed descendant must stay pinned, switch to the CSS variable renderer:
createBend(el, { render: "cssVar" });.stage {
transform: translate3d(0, var(--bend-pull, 0px), 0);
}Read Renderers before choosing.
The full behaviour is written down in SPEC.md, and the reasons behind the design are in DECISIONS.md. If this site and the spec ever disagree, the spec wins.