Skip to main content

Motion Blur

Velocity-driven directional motion blur — samples element position each frame and applies a one-sided ghost trail proportional to speed. effect motion-blur velocity animation physics

Install

npx hyperframes add motion-blur

Details

PropertyValue
TypeComponent

Files

FileTargetType
motion-blur.htmlcompositions/components/motion-blur.htmlhyperframes:snippet

Usage

Paste the snippet into your composition, then call attachMotionBlur() after your GSAP tweens and before registering window.__timelines.
<!-- Extend the timeline to data-duration before calling attachMotionBlur -->
tl.set(document.body, {}, DATA_DURATION);

attachMotionBlur("#my-box", tl, {
  axis: "x",      // "x" | "y" | "both"
  blurMax: 40,    // max blur radius in px (default 20)
});

window.__timelines = window.__timelines || {};
window.__timelines["my-composition"] = tl;

How it works

Each target element gets its own SVG filter. On every timeline seek, attachMotionBlur samples the element’s GSAP x/y position, computes velocity, and drives three SVG filter primitives:
  1. Ghost copies — three faded, blurred copies of the element placed behind it at increasing offsets proportional to speed. Inherently one-sided: no forward blur.
  2. Top blur — a small symmetric Gaussian at the current position so the element looks in-motion rather than crisp on top of the trail.
Blur scales linearly with velocity up to blurMax. Both the ghost trail and top blur clear automatically when the element decelerates to rest.

Options

OptionDefaultDescription
axis"both"Motion axis — "x", "y", or "both"
blurScale0.008Blur per px/s of velocity
blurMax20Max blur radius on the motion axis (px)
stretchScale0.0002scaleX/Y added per px/s (requires stretchMax > 0)
stretchMax0Max stretch above 1.0 — disabled by default