Package Exports
- image-preload
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (image-preload) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
image-preload
Simple, framework-agnostic image preloader. Async, sync, background, foreground, whatever!
Installation
npm install --save image-preload
Or you can use a browser script available from https://unpkg.com/image-preload@1.0.6/browser/main.js
.
Minimal usage
import Preload from "image-preload";
Preload(["https://i.imgur.com/VCr4saa.png"]);
Async, in background usage
import Preload from "image-preload";
Preload(["https://i.imgur.com/VCr4saa.png"], {
inBackground: true,
toBase64: true,
onSingleImageComplete: base64 => console.log(base64)
});
Sorting options usage
import Preload, { Order } from "image-preload";
Preload(["https://i.imgur.com/VCr4saa.png"], { order: Order.AllAtOnce });
// or
Preload(["https://i.imgur.com/VCr4saa.png"], { order: Order.InOrder });
All options
type Options = {
order?: Order;
timeout?: number;
shouldContinueOnFail?: boolean;
toBase64?: boolean;
inBackground?: boolean;
onSingleImageFail?: Function;
onSingleImageComplete?: Function;
onComplete?: Function;
};
Defaul options
const defaultOptions = {
order: Order.InOrder,
timeout: 0,
shouldContinueOnFail: true,
toBase64: false,
inBackground: false,
onSingleImageFail: () => {},
onSingleImageComplete: () => {},
onComplete: () => {}
};