Lazy

Layout & Structure
stable

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.

Anatomy of OrigamLazySchematic of the Lazy component in its two states: placeholder and revealed. placeholder (min-height applied, children not mounted) revealed (children mounted + fade transition) 1 2
Anatomy of <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. The v-intersect directive 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.

modelValue
boolean
false
Controls visibility. Once set to true (either programmatically or via the IntersectionObserver), the children are mounted and stay mounted.
options
IntersectionObserverInit
{ root: undefined, rootMargin: undefined, threshold: undefined }
IntersectionObserver options passed to the v-intersect directive. Controls root element, margin and threshold.
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
height
number | string
Placeholder height before the content is loaded. Helps IntersectionObserver detect the element.
maxHeight
number | string
Maximum placeholder height.
maxWidth
number | string
minHeight
number | string
Minimum placeholder height.
minWidth
number | string
width
number | string
Placeholder width before the content is loaded.
tag
string
'div'
Root HTML element tag.
transition
{ component: OrigamFade }
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:modelValue
any
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

vue

Controlled (v-model)

vue

Custom observer options

vue