1.1.0 • Published 5 years ago

resloader v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

resloader

Build Status npm npm npm npm

English 中文文档

Overview

A image preloaded plugin and can display the loaded image progress bar

DEMO

Install

Install resloader

npm install resloader

Import resloader

ES6/commonjs import style is supported.

// ES6
import resloader from 'resloader';

// commonjs
var resloader = require("resloader");

or link as a script in an html file.

<script src="dist/resloader.js"></script>

Usage

// imageData expected a JSON
// url is required
let imageData = [{
    name: images1,
    url: imageUrl
},{
    name: images1,
    url: imageUrl
},{
    name: images1,
    url: imageUrl
},{
    name: audio,
    url: audioUrl
}]
// or imageData can be an Array
let imageData = [imageUrl, imageUrl, imageUrl, audioUrl]

const options = {
    resources: imageData, //imageData expected a JSON or Array
    onStart: function(total) {
        console.log('onStart:' + total)
    },
    onProgress: function(currentIndex, total) {
        console.log('onProgress:' + currentIndex + '/' + total)
    },
    onComplete: function(total,result) {
        console.log('onComplete:' + total)
        console.log(result)
    }
}

resloader(options);

options

OptionDescriptiondefaulttypeFunction Params Description
resourcespreload images/audio data-JSON, Array-
onStartcallback when preload on started-Functiontotal: preload images total
onProgresscallback when preload on loading-FunctioncurrentIndex:loaded images number total:preload images total
onCompletecallback when preload on complete-Functiontotal: preload images total result: preload images data(the same as resources)

LICENSE

MIT@chenyinkai

1.1.0

5 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