ParallaxLayer
Depth layer inside a Parallax container. Each layer registers a speed multiplier with the parent and is driven frame-by-frame via a rAF loop (JS path) or CSS scroll-driven animations (CSS path).
Structure
Anatomy
Visual breakdown of the component's internal structure with BEM class call-outs.
<origam-parallax-layer> — 4 parts: ① host parallax, ② background layer (low speed), ③ neutral layer (speed 1), ④ foreground layer (high speed). Each layer is positioned absolute; inset: 0 and driven by a shared rAF loop or CSS scroll-driven animation.- 1.origam-parallax (host)
- Parent OrigamParallax providing the injection context. Owns the scroll/mouse listeners and the rAF loop. Layers register on mount and unregister on unmount.
- 2.origam-parallax__layer (background)
- Background layer (speed < 1). Positioned absolute; inset: 0. Moves slower than the scroll — creates the depth illusion.
- 3.origam-parallax__layer (neutral)
- Neutral layer (speed = 1). Moves with the scroll. When the CSS scroll-driven path is active, carries .origam-parallax__layer--css-driven.
- 4.origam-parallax__layer (foreground)
- Foreground layer (speed > 1). Moves faster than the scroll. Under prefers-reduced-motion: reduce, carries .origam-parallax__layer--reduced-motion and transform is locked to translate3d(offsetX, offsetY, 0).
API
Props
All props accepted by this component, with their type, default value and description.
- speednumber1
- Parallax speed multiplier: 0 = fixed, 0.5 = half scroll speed (far background), 1 = neutral, >1 = faster than scroll (foreground). Negative values reverse the direction.
- offsetXnumber0
- Static horizontal offset in px applied on top of the parallax translation. Useful to nudge a layer without changing its speed.
- offsetYnumber0
- Static vertical offset in px applied on top of the parallax translation.
- zIndexnumber
- Optional z-index override. By default layers stack in document order.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- tagstring'div'
- Root HTML element tag.
API
Slots
Content slots exposed by this component.
- #default
- Content of this depth layer. Any markup is valid — images, text, decorative elements.
API
Exposed members
Properties and methods accessible via template ref (defineExpose). Use them for programmatic control.
- <T extends object>(props: T, exclude?: string[]) => Partial<T>
- Utility to forward a filtered subset of props to a child component.
Customisation
CSS variables
CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.
- CSS will-change hint for the layer. Defaults to transform to promote layers to compositor.
- Transform origin for each layer element.
- Speed multiplier used by the CSS scroll-driven keyframe (from 0 to 100% view coverage).
- Static X offset applied in the reduced-motion keyframe.
- Static Y offset applied in the reduced-motion keyframe.
Inclusion
Accessibility
ARIA roles, keyboard navigation and focus management. Sourced from the real component template.
Notes
- Under prefers-reduced-motion: reduce, the CSS keyframe animation and the rAF loop are both disabled. The layer is rendered at its static offset (offsetX, offsetY) without any movement.
- ParallaxLayer is a purely presentational layer. All semantic content must come from the slotted markup.
Foundation
Design tokens
Excerpt from this component's token declarations — the --origam-<component>---<property> variables, declared in its hand-maintained token sheet with no build step.
- othertransform
- CSS will-change hint for each layer — promotes to compositor.
- othercenter center
- Default transform-origin shared by all layers.
- cubicBeziercubic-bezier(0.16, 1, 0.3, 1)
- Spring-like easing curve available for the multi-layer scroll path.
Interactive
Playground
Edit props live and see the component update in real time. The generated code snippet updates as you change values.
Rendering the live preview…
Usage
Examples
Ready-to-paste code snippets for your templates.
Scroll-driven multi-layer
CSS scroll-driven (progressive enhancement)