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
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<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
Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et 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
Emplacements de contenu exposés par ce composant.
- #default
- Content of this depth layer. Any markup is valid — images, text, decorative elements.
API
Membres exposés
Propriétés et méthodes accessibles via ref template (defineExpose). Utilisés pour le contrôle programmatique.
- <T extends object>(props: T, exclude?: string[]) => Partial<T>
- Utility to forward a filtered subset of props to a child component.
Personnalisation
Variables CSS
Propriétés CSS personnalisées exposées par ce composant. Surchargez-les pour personnaliser sans perdre la compatibilité avec le thème.
- 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
Accessibilité
Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.
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.
Fondation
Design tokens
Extrait des tokens de ce composant — les variables --origam-<composant>---<propriété>, déclarées dans sa feuille de tokens tenue à la main, sans étape de build.
- 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.
Interactif
Playground
Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.
Rendu de l’aperçu en cours…
Usage
Exemples
Extraits de code prêts à coller dans vos templates.
Scroll-driven multi-layer
CSS scroll-driven (progressive enhancement)