import type { TWhenEntersViewportSettings } from '../when/whenEntersViewport.js'; import type { TWhenInteractSettings } from '../when/whenInteract.js'; import type { TWhenInViewportSettings } from '../when/whenInViewport.js'; import type { TWhenNearViewportSettings } from '../when/whenNearViewport.js'; import type { TWhenOutOfViewportSettings } from '../when/whenOutOfViewport.js'; import type { IWhenStyleSheetsReadySettings } from '../when/whenStylesheetsReady.js'; import type { TWhenVisibleSettings } from '../when/whenVisible.js'; /** * @name when * @namespace js.dom.when * @type Function * @platform js * @status stable * @async * * This function listen for passed `trigger(s)` on the passed `HTMLElement` and resolve the promise once one of them has reached his state. * * @param {HTMLElement} $elm The element to listen on * @param {String|String[]} trigger The trigger(s) to listen on * @param {TwhenSettings} [settings={}] Some settings like offset, etc... * @return {SPromise} A promise resolved when all the triggers are fulfilled * * @setting {Partial} [whenInViewport={}] Some settings for the whenInViewport function * @setting {Partial} [whenNearViewport={}] Some settings for the whenNearViewport function * @setting {Partial} [whenEntersViewport={}] Some settings for the whenEntersViewport function * @setting {Partial} [whenOutOfViewport={}] Some settings for the whenOutOfViewport function * @setting {Partial} [whenInteract={}] Some settings for the whenInteract function * @setting {Partial} [whenVisible={}] Some settings for the whenVisible function * @setting {Partial} [whenStylesheetsReady={}] Some settings for the whenStylesheetsReady function * * @snippet __when($1, $2, $3) * __when($1, $2).then(() => { * $2 * }); * * @todo tests * * @example js * import { __when } from '@lotsof/sugar/dom'; * __when($elm, 'inViewport', { * whenInViewport: { * offset: 50 * } * }).then(() => { * // do something * }); * * @since 1.0.0 * @author Olivier Bossel (https://lotsof.dev) */ export type TwhenSettings = { whenInViewport?: TWhenInViewportSettings; whenNearViewport?: TWhenNearViewportSettings; whenEntersViewport?: TWhenEntersViewportSettings; whenOutOfViewport?: TWhenOutOfViewportSettings; whenInteract?: TWhenInteractSettings; whenVisible?: TWhenVisibleSettings; whenStylesheetsReady?: IWhenStyleSheetsReadySettings; }; export type TWhenTrigger = ('direct' | 'directly' | 'inViewport' | 'nearViewport' | 'enterViewport' | 'outOfViewport' | 'interact' | 'visible' | 'domReady' | 'stylesheetsReady' | 'animationEnd')[]; export declare const WhenTriggers: string[]; export default function __when($elm: HTMLElement, trigger: TWhenTrigger[], settings?: TwhenSettings): Promise;