/** * Reveal component: one observer per root, one entrance per element. * * @augments IvComponent */ export class Reveal extends IvComponent { /** @type {Readonly} */ static defaults: Readonly; /** * Returns the instance attached to `el`, if any. * * @param {Element} el Host element. * @returns {Reveal|undefined} The instance or `undefined`. */ static get(el: Element): Reveal | undefined; /** * Returns the existing instance or creates one. * * @param {Element} el Host element. * @param {Partial} [options] Options passed in JavaScript. * @returns {Reveal} The instance. */ static getOrCreate(el: Element, options?: Partial): Reveal; /** * Instantiates every `[data-iv-component="reveal"]` inside `root`. When the * page declares no root and there are elements to reveal, the body becomes a * generated root marked with `data-iv-auto`, which `destroy` removes again. * * @param {ParentNode} [root] Subtree to scan. * @returns {Reveal[]} Newly created instances. */ static initAll(root?: ParentNode): Reveal[]; /** * @param {Element} el Container holding the elements to reveal. * @param {Partial} [options] Options passed in JavaScript. */ constructor(el: Element, options?: Partial); /** @type {IntersectionObserver|null} The observer, when the browser has one. */ _observer: IntersectionObserver | null; /** @type {Set} Elements this instance marked. */ _seen: Set; /** * Resolved options. * * @returns {Readonly} The options. */ get options(): Readonly; /** * Elements revealed so far, in the order they entered. * * @returns {HTMLElement[]} The elements carrying `data-iv-inview`. */ get revealed(): HTMLElement[]; /** * Targets of this instance: every element to reveal in the subtree that is * not owned by a nested root. * * @returns {HTMLElement[]} The elements to observe. */ _targets(): HTMLElement[]; /** * Reacts to the observer: entering elements are revealed; with `repeat` a * leaving element goes back to its hidden state. * * @param {IntersectionObserverEntry[]} entries Reported entries. * @returns {void} */ _onIntersect(entries: IntersectionObserverEntry[]): void; /** * Marks an element as seen, staggering it when it declares an inline `--iv-i`. * * @param {HTMLElement} el Element entering the viewport. * @param {boolean} stagger Whether the delay applies; a page without an * observer has nothing to stagger. * @returns {void} */ _show(el: HTMLElement, stagger: boolean): void; /** * Puts an element back to its hidden state (`repeat` only). * * @param {HTMLElement} el Element leaving the viewport. * @returns {void} */ _hide(el: HTMLElement): void; } export type RevealOptions = { /** * Fraction of the element that must be visible. */ threshold: number; /** * Whether the entrance runs again after leaving. */ repeat: boolean; /** * Milliseconds added per `--iv-i` step. */ stagger: number; }; import { IvComponent } from "../core/component.js";