Skip to content
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.

cycdpo/h5-preloader

Repository files navigation

H5 Preloader

NPM version David deps devDependencies Status npm download jsdelivr npm license

(Releases | Demo)

This package has been deprecated

This package has been migrated to @cycjimmy/h5-preloader for scoped NPM package. Please switch to @cycjimmy/h5-preloader to stay up to date.

Install

# via npm
$ npm install h5-preloader --save

# or via yarn
$ yarn add h5-preloader

Usage

import h5Preloader from 'h5-preloader';

// OR
const h5Preloader = require('h5-preloader');

h5Preloader({
  type: 'progressBar',
  progressBar: {
    eProgressBar: ...,
    eProgressBarPercent: ...
  },
  resources: [
    ...
  ],
  hookWhenProgressComplete: () => 
    ...
  },
}).load();
  • h5Preloader config:

    • resources: [Require][Array] Resource paths array.
    • baseUrl: [Option][String] Base url for Resource paths. Default './'
    • type: [Option][String] Set type of progress. Currently only supports 'progressBar'. Default 'progressBar'.
    • progressBar: [Option][Object] Progress bar config
      • eProgressBar: [Element] Element of Progress bar.
      • eProgressBarPercent: [Element] Element for showing percent.
    • hookWhenProgressComplete: [Option][Function] The hook function when the progress complete.
    • autoComplete: [Option][Boolean] Whether to automatic operation the hook function when the progress complete. Default true
  • h5Preloader instance supports the following methods:

    • load(): Start preloader.
    • progressComplete(): Call the progress complete function manually.

CDN

To use via a CDN include this in your HTML:

<script src="https://cdn.jsdelivr.net/npm/h5-preloader@0/build/h5-preloader.min.js"></script>