1.0.6 • Published 6 years ago

image-preload-test v1.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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: () => {}
};
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago