当前位置:网站首页>JS progress bar, displaying the loading progress
JS progress bar, displaying the loading progress
2022-04-23 14:17:00 【Ruirui junior】
One : introduce ImgPreloader.js
(function() {
function Preloader(srcs, opts) {
this.srcs = srcs;
this.opts = opts ||{};
this.loaded = [];
this.load();
}
Preloader.prototype.load = function() {
for (var i = 0; i < this.srcs.length; ++i) {
var src = this.srcs[i];
this.loadImg(src);
}
};
Preloader.prototype.loadImg = function(src) {
var that = this;
var img = new Image();
img.onload = function() {
that.onload(img);
};
img.src = src;
};
Preloader.prototype.onload = function(obj) {
this.loaded.push(obj);
if (this.opts.each instanceof Function) {
var percent = this.loaded.length / this.srcs.length;
this.o
版权声明
本文为[Ruirui junior]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231408339096.html
边栏推荐
猜你喜欢
随机推荐
线程组ThreadGroup使用介绍+自定义线程工厂类实现ThreadFactory接口
使用Executors类快速创建线程池
SED 学以致用
Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface
GFS分布式文件系统(理论)
HyperMotion云迁移完成阿里云专有云产品生态集成认证
星界边境文本自动翻译机使用说明
Some good articles on pthread multithreading
微信小程序客服接入,实现发送和接收消息
redis数据库讲解(三)redis数据类型
sar命令详解
Introduction to the use of countdownlatch and cyclicbarrier for inter thread control
man man随记和crontab的@reboot用法
教育行业云迁移最佳实践:海云捷迅使用HyperMotion云迁移产品为北京某大学实施渐进式迁移,成功率100%
处理 mkdir:无法创建目录“aaa“:只读文件系统
网页自适应,等比缩放
OpenStack如何跨版本升级
进入新公司,运维工程师从下面这几项了解系统的部署
Introduction to the use of semaphore for inter thread control
返回数组排序后下标