Lazy
Defers the mounting of its children until the placeholder enters the viewport. Uses IntersectionObserver (v-intersect directive) with an optional fade-in transition.
Structure
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<origam-lazy> — ① placeholder state (children unmounted, min-height reserves space for IntersectionObserver) → ② revealed state (children mounted with transition).- 1.origam-lazy (placeholder)
- While
isActive=false, the root element is an empty block with the configured dimensions. Thev-intersectdirective watches it. - 2.origam-lazy (revealed)
- Once
isActive=true, the default slot is rendered inside an<origam-transition>(OrigamFade by default). The element is never hidden again.
API
Props
Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.
- modelValuebooleanfalse
- Controls visibility. Once set to true (either programmatically or via the IntersectionObserver), the children are mounted and stay mounted.
- optionsIntersectionObserverInit{ root: undefined, rootMargin: undefined, threshold: undefined }
- IntersectionObserver options passed to the v-intersect directive. Controls root element, margin and threshold.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- heightnumber | string
- Placeholder height before the content is loaded. Helps IntersectionObserver detect the element.
- maxHeightnumber | string
- Maximum placeholder height.
- maxWidthnumber | string
- minHeightnumber | string
- Minimum placeholder height.
- minWidthnumber | string
- widthnumber | string
- Placeholder width before the content is loaded.
- tagstring'div'
- Root HTML element tag.
- Transition to apply when the slot content is revealed. Defaults to OrigamFade. Pass null to disable.
API
Slots
Emplacements de contenu exposés par ce composant.
- #default
- Content to render once the element enters the viewport. Wrapped in the configured transition.
API
Emits
Événements émis par ce composant.
- @update:modelValueany
- Emitted when the IntersectionObserver fires and the element becomes visible. Payload is always true (component only mounts once).
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.
- Ref<string>
- Reactive CSS string generated by useStyle.
- string
- Unique style-sheet ID for this instance.
- () => void
- Injects the computed style sheet. Called automatically on mount.
- () => void
- Removes the injected style sheet. Called automatically on unmount.
- Ref<boolean>
- True once the style sheet has been injected into the DOM.
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.
- Duration of the reveal transition (OrigamFade).
- Easing of the reveal transition.
- Minimum height of the placeholder zone so the IntersectionObserver has something to detect.
- Background color of the placeholder zone (visible only before reveal).
Inclusion
Accessibilité
Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.
Notes
- While the content is not yet revealed, the root element carries <code>aria-busy="true"</code>. This signals to assistive technologies that the region is still loading.
- OrigamLazy relies on IntersectionObserver. Ensure placeholder dimensions are set (min-height / height) so the browser can observe a non-zero element. A zero-size element may never intersect and the content would never mount.
- The default OrigamFade transition respects prefers-reduced-motion: reduce — pass transition="null" to fully disable animation.
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.
Basic lazy load
Controlled (v-model)
Custom observer options