/** * Waits for the media of a slider, shows a screen meanwhile, and says how * far it is. * * createSlider( element, { plugins: [ loading() ] } ); * * The screen is the element that is given, or the one with the class * `gs-loading` in the slider, or one that is made: a number and a line, * styled by `loading.css`. It is told how far the loading is: * * --gs-loaded 0 to 1, on the screen * [data-gs-loaded] elements in it whose text is the number, 0 to 100 * .gs-loaded the class of the screen when all is there * * The slider has the class `gs-is-loading` meanwhile. With `screen: false` * there is none, and what is shown is up to who listens: * * loading:start { total } * loading:progress { loaded, failed, total, progress, media } * loading:done { loaded, failed, total, progress, time, late } * * Media that fail count as the others: `failed` says how many. `late` * says that the time was over before everything was there. * * Images that wait for their place to come near (`loading="lazy"`) are * told to load now, and videos to load their first picture: a slider * that waits for them would wait for ever. * * Several sliders count together when they are given the same plugin: * * const together = loading( { screen: element } ); * createSlider( one, { plugins: [ together ] } ); * createSlider( two, { plugins: [ together ] } ); */ import type { Slider } from '../index.js'; /** What is there, what failed and what is waited for. */ export interface State { loaded: number; failed: number; total: number; progress: number; } /** * @param options Options. * @param options.screen The screen; false for * none. * @param options.min The least time the * screen is shown, ms. * @param options.timeout The time after which * it is done with what * is there, ms. 0: no * such time. * @param options.also What else is waited * for, and counted: * fonts, data. The * plugin is for a * slider that is made * now: what is kept * before there is one * is told to nobody. */ export declare function loading({ screen, min, timeout, also, }?: { screen?: Element | false; min?: number; timeout?: number; also?: Promise[]; }): (slider: Slider) => { name: string; slides: () => void; /** What is there, what failed and what is waited for. */ state: State; /** Whether the loading is over. */ readonly done: boolean; /** Is kept when the loading is over. */ ready: Promise; destroy(): void; };