Skip to content
This repository was archived by the owner on Jul 7, 2026. It is now read-only.
 
 

Repository files navigation

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
}]
// or imageData can be an Array
let imageData = [imageUrl, imageUrl, imageUrl]

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

Option Description default type Function Params Description
resources preload images data - JSON, Array -
onStart callback when preload on started - Function total: preload images total
onProgress callback when preload on loading - Function currentIndex:loaded images number
total:preload images total
onComplete callback when preload on complete - Function total: preload images total
result: preload images data(the same as resources)

LICENSE

MIT@chenyinkai

About

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

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages