elementMovement

Parallax
stable

Computes the X/Y translation offset to apply to a parallax target element based on cursor or scroll position, a strength multiplier, and optional min/max clamps.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

action
required
IParallaxElementMovement
Configuration object that includes the current cursor/scroll position (x, y), the origin point (originX, originY defaults 50), a strength multiplier, optional clamp values (minX, maxX, minY, maxY), the event type, and the target element.

API

Return value

The value returned by this util.

An object with the computed x and y translation offsets and the target element reference.

Usage

Examples

Ready-to-paste usage snippets.

Compute parallax offset

typescript