npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

z-preloader

v1.0.0

Published

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

Downloads

13

Readme

z-preloader

Overview

实现图片的预加载功能,并且可以查看图片的加载进度

安装及引入

Install z-preloader

npm install z-preloader

Import z-preloader

ES6/commonjs import style is supported.

// ES6
import preloader from 'z-preloader';

// commonjs
var preloader = require("z-preloader");

or link as a script in an html file.

<script src="dist/z-preloader.js"></script>

使用

// imageData 可以是json
// url 是必须的,其他信息可根据需要自行添加
let imageData = [{
    name: images1,
    url: imageUrl
},{
    name: images1,
    url: imageUrl
},{
    name: images1,
    url: imageUrl
}]
// 或者 imageData 可以是数组
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)
    }
}

preloader(options);

options 参数描述

| Option | Description | default | type | Function Params Description | | -------------- | ---------------------- | ------- | ------------ | ------------------------ | | resources | 预加载的图片集合 | - | JSON, Array | - | | onStart | 图片开始加载时的回调 | - | Function | total: 预加载的图片总数 | | onProgress | 每一张图片加载完成的回调 | - | Function | currentIndex:已加载的图片数 total:预加载图片总数 | | onComplete | 所有图片加载完成的回调 | - | Function | total: 预加载的图片总数 result: 预加载的图片集合(同resources) |

LICENSE

项目来自 chenyinkai resloader