/** * ScrollMotion component: one frame-throttled scroll listener per container. * * @augments IvComponent */ export class ScrollMotion extends IvComponent { /** @type {Readonly} */ static defaults: Readonly; /** * Returns the instance attached to `el`, if any. * * @param {Element} el Host element. * @returns {ScrollMotion|undefined} The instance or `undefined`. */ static get(el: Element): ScrollMotion | undefined; /** * Returns the existing instance or creates one. * * @param {Element} el Host element. * @param {Partial} [options] Options passed in JavaScript. * @returns {ScrollMotion} The instance. */ static getOrCreate(el: Element, options?: Partial): ScrollMotion; /** * @param {Element} el Container holding the elements driven by scroll. * @param {Partial} [options] Options passed in JavaScript. */ constructor(el: Element, options?: Partial); /** @type {boolean} Whether the engine drives the sheets by itself. */ _native: boolean; /** @type {boolean} Whether this instance writes anything at all. */ _active: boolean; /** @type {Window|null} View of the element, or `null` outside a document. */ _view: Window | null; /** @type {Set} Elements carrying properties written here. */ _touched: Set; /** @type {number} Pending animation frame, `0` when there is none. */ _frame: number; /** @type {boolean} Whether a frame is scheduled. */ _pending: boolean; /** @type {Map} `style` attributes as served. */ _styles: Map; /** * Resolved options. * * @returns {Readonly} The options. */ get options(): Readonly; /** * Whether the engine has CSS scroll-driven animations, as reported by * `CSS.supports` when the component was set up. * * @returns {boolean} `true` when the sheets drive themselves. */ get native(): boolean; _reduced: boolean | undefined; /** * Recomputes both properties now, outside any frame. Call it after the * container changed size or gained elements. * * @returns {void} */ update(): void; /** * Parallax elements of this instance. * * @returns {HTMLElement[]} The elements to drive. */ _targets(): HTMLElement[]; /** * Schedules one measurement per frame. * * @returns {void} */ _schedule(): void; /** * Reads the layout once and writes both properties. * * @returns {void} */ _measure(): void; /** * Writes a property unless it already holds that value, so a scroll that * moves nothing invalidates no style. * * @param {HTMLElement} el Element to write on. * @param {string} name Custom property. * @param {string} value New value. * @returns {void} */ _write(el: HTMLElement, name: string, value: string): void; /** * Drops any scheduled frame. * * @returns {void} */ _cancel(): void; } export type ScrollMotionOptions = { /** * Write the properties even where the engine has * scroll-driven animations. For checking the fallback, and for a page that * drives something else from `--iv-view`. */ force: boolean; }; import { IvComponent } from "../core/component.js";