Accessors
note
All Preloader's accessors are available in this class.
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
Represents the actual loading progress in the 0–1 range.
This value is never interpolated and updates immediately whenever a resource loads.
const preloader = new ProgressPreloader({
container: document.getElementById("container"),
});
preloader.loadProgress; // rigid progress
progress
Type: number
Gets the current interpolated progress value (0 to 1).
The smoothness of the progress update depends on lerp props.
See demo
const preloader = new ProgressPreloader({
container: document.getElementById("container"),
});
preloader.progress; // smooth progress
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