useParallaxTransform
Parallax
stable
Computes CSS transform strings for parallax layer elements based on normalised mouse-position coordinates. Supports five transform types: translate, rotate, depth (3-D tilt), depth-inv (inverted tilt), scale, scale-x, and scale-y. Consumed by OrigamParallax to animate child layers.
API
Signature
Full TypeScript signature sourced from the composable file.
useParallaxTransform is a pure computation helper — it has no side effects and does not touch the DOM. OrigamParallax owns the mousemove listener and passes the normalised coordinates down to each layer via this composable.
Consumed interfaces
IParallaxElementProps
API
Parameters
Input parameters accepted by this composable.
- propsrequiredIParallaxElementProps
- Props of a parallax layer element. Reads `type` (PARALLAX_ELEMENT_TYPE enum), `strength` (movement intensity, default 10), and `axis` (AXIS enum, used for rotate type to constrain movement to a single axis).
API
Return values
Properties and methods exposed by the composable return object.
- strength
- Resolved movement strength. For depth / depth-inv types the absolute value is taken so the depth always projects forward.
- transformStyles
- Function that accepts normalised mouse coordinates (typically in [-1, 1]) and returns a CSS transform string. Returns undefined when the type does not match any known case.
Usage
Examples
Ready-to-paste usage snippets.
Manual parallax layer (custom wrapper)
Using OrigamParallax (recommended)