This package has been migrated to @cycjimmy/h5-preloader for scoped NPM package. Please switch to @cycjimmy/h5-preloader to stay up to date.
# via npm
$ npm install h5-preloader --save
# or via yarn
$ yarn add h5-preloader
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.
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>