Skip to main content

Accessors

note

All Preloader accessors (isLoaded, isHiding, isHidden, …) are available in this class.

resourceContainer​

Type: HTMLElement | null

Not a getter on the instance — set via resourceContainer prop. DOM root used to scan images, videos, and customSelector matches. Defaults to document when null.

loadedWeight​

Type: number

Total loaded resources weight.
Custom resources may have a data-loaded attribute which represents their loaded weight.
See demo

const preloader = new ProgressPreloader({
container: document.getElementById('container'),
});

preloader.loadedWeight; // loaded weight

loadProgress​

Type: number

Actual weighted progress in the 0–1 range. Not interpolated — updates immediately when a resource resolves.

preloader.loadProgress; // rigid progress

progress​

Type: number

Smoothed progress (0–1) for UI. Damped toward loadProgress each frame via lerp.

loaded fires when progress >= 1, not when loadProgress hits 1 first.

preloader.on('progress', () => {
console.log(preloader.progress); // smooth value for display
});

resources​

Type: IProgressPreloaderResource[]

The list of all tracked custom resources.
See demo

IProgressPreloaderResource structure

interface IProgressPreloaderResource {
id: string | Element; // Unique resource identifier or DOM element
loaded: number; // Currently loaded weight
weight: number; // Total resource weight
}
const preloader = new ProgressPreloader({
container: document.getElementById('container'),
});

preloader.resources; // list of resources

totalWeight​

Type: number

Returns the total weight of all resources to preload.
See demo

const preloader = new ProgressPreloader({
container: document.getElementById('container'),
});

preloader.totalWeight; // total resources weight