css 部分使用 svg 绘制环形

 svg{width:100px; height: 100px; margin:15% auto 25%; box-sizing:border-box; display: block;}
svg circle{fill:none;cx:;cy:;}
/* svg text{x:40;y:55;} 不起作用 原因不知*/
svg #txt{ x:;y:55%;fill:red;}
svg #backdrop{stroke-linecap:round;stroke:#333; stroke-width:2px;r:;}
svg #progress{stroke:#690; stroke-dasharray:0 1000;stroke-width:3px;r:;}

此处的 js 放在 body 标签中

 var mulitImg = [
'http://www.cctv.com/img/2.png',
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1520235078852&di=a57664a8e118c403bf2d378757e40b08&imgtype=0&src=http%3A%2F%2Fs9.knowsky.com%2Fbizhi%2Fl%2F100001-105083%2F2009530184324945217430590.jpg',
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1520235078852&di=0a127ba0bf50857c86bd886ef355d2c9&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F4%2F593a3dba085e1.jpg',
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1520235078851&di=f1dacfe012d7e71c7469a4b0b4df2708&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Fe%2F5902ad376edd5.jpg',
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1520235078851&di=b6ab0dcfbe939057988cabb0bd0f3899&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F1%2F535a1f52d5f8c.jpg',
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1520235078850&di=4f0693db95d8e117035f77d7a1d5e493&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Ff%2F594336ec75b26.jpg' ];
// 调用函数, 传入图片数组
load_img(mulitImg);
function load_img(mulitImg)
{
var svg=document.createElementNS('http://www.w3.org/2000/svg','svg');
document.body.appendChild(svg);
var svg_html='<circle id="backdrop" /><text x="35" y="55%" fill="red" id="txt">0%</text><circle id="progress" />';
svg.innerHTML=svg_html; var idtxt=document.getElementById('txt');
var progrees=document.getElementById('progress');
var pro_v=parseInt(css(progrees,'stroke-dashoffset'));
var r=parseInt(css(progrees,'r')); // 半径
var arcLength=Math.floor(2*Math.PI*r); // 周长 var taget=100;
var img = [],
flag = 0; var imgTotal = mulitImg.length;
//添加过渡效果
progrees.style.transitionDuration=arcLength/imgTotal/100+'s';
idtxt.style.transitionDelay=arcLength/imgTotal/100/2+'s'; for(var i = 0 ; i < imgTotal ; i++){
img[i] = new Image();
img[i].index=i;
img[i].src = mulitImg[i]
// 图片加载完成
img[i].onload = function(){ //第i张图片加载完成
flag++;
idtxt.textContent=(flag/imgTotal).toFixed(2) *100+'%';
progrees.style.strokeDasharray=arcLength*(flag/imgTotal)+' 1000';// 第二个值必须大于周长 if( flag == imgTotal ){
//全部加载完成
}
};
// 图片加载失败----继续执行,可以选择用另一张图片替换
img[i].onerror = function(){
//第i张图片加载失败 flag++; // 继续执行
// console.log(this.index+':'+this.src)
idtxt.textContent=(flag/imgTotal).toFixed(2) *100+'%';
progrees.style.strokeDasharray=arcLength*(flag/imgTotal)+' 1000';// 第二个值必须大于周长
if( flag == imgTotal ){
//全部加载完成
}
};
} // 获取css 样式
function css(t, n) {
return t.currentStyle ? t.currentStyle[n] : getComputedStyle(t, !1)[n]
}
}

js 多张图片加载 环形进度条的更多相关文章

  1. android 网络异步加载数据进度条

    ProgressDialog progressDialog = null; public static final int MESSAGETYPE = 0; private void execute( ...

  2. js - 预加载+监听图片资源加载制作进度条

    这两天遇到一个新需求:一个一镜到底的h5动画.因为功能的特殊性,就要求我们提前监听页面的静态图片是否全部加载完毕.即处理预加载. 总结下来,下次这种需求需要提前注意以下几点: 一.图片而不是背景图 本 ...

  3. cocos2dx 3.x(加载cocostudio进度条)

    // // MyLoagingScene.hpp // My // // Created by work on 16/10/13. // // #ifndef MyLoagingScene_hpp # ...

  4. WPF BackGroundWord 异步加载更新进度条示例

    <Window x:Class="AsynchronousLoading.MainWindow" xmlns="http://schemas.microsoft.c ...

  5. WebView长按保存图片;WebView不跳转到系统的浏览器;WebView加载显示进度条;WebView返回事件处理;

    直接看代码即可,代码里面注释写的很清楚,这个类拉下来就能用: 写法和命名比较粗暴,但也简单易懂: public class MainActivity extends AppCompatActivity ...

  6. pace.js – 网页自动加载进度条插件

    网站顶部的页面加载进度条是怎么实现的,页面的加载进度百分比,有时候获取是比较麻烦的,当然也可以利用一些优秀的JavaScript插件来实现,今天就为大家介绍这样子的一款插件:pace.js. [官方网 ...

  7. js 利用 ajax 加载 js ,显示加载进度 ,严格按照js的顺序先后加载到页面

    js 利用 ajax 加载 js ,显示加载进度 ,严格按照js的顺序先后加载到页面 , 做手机端开发时,发现一个问题,有些浏览器,在网速比较慢的情况下,js文件没有加载完,后续的调用已经开始调用了, ...

  8. JS判断单、多张图片加载完成

    转:http://www.daqianduan.com/6419.html 试想,如果模板中有图片,此时如何判断图片是否加载完成? 在此之前来了解一下jquery的ready与window.onloa ...

  9. 自定义环形进度条RoundProgressBar

    一.效果图: Canvas画圆环说明: 圆环宽度不必在意,只是画笔宽度设置后达到的效果. 二.实现步骤 1.自定义View-RoundProgressBar 2.设置属性resources(decle ...

随机推荐

  1. Struts1使用技巧

    转自:https://blog.csdn.net/chjttony/article/details/6099101 1.Struts1是Apache推出的java web开发领域一个比较早,同时也是使 ...

  2. WebRTC的拥塞控制技术<转>

    转载地址:http://www.jianshu.com/p/9061b6d0a901 1. 概述 对于共享网络资源的各类应用来说,拥塞控制技术的使用有利于提高带宽利用率,同时也使得终端用户在使用网络时 ...

  3. ListView显示Sqlite的数据美化版与性能优化

    在上一篇文章中,我们已经实现在listview显示数据库内容的.但是我们listview中,排版不是很好看,所以这篇文章呢,我们来对listveiw进行美化.哈哈,说白了,就是对listview添加一 ...

  4. 超详细的Maven使用教程

    原文:  http://blog.csdn.net/u010425776/article/details/52027706 主题 Maven 什么是Maven? 如今我们构建一个项目需要用到很多第三方 ...

  5. sql 一些偶尔会用到的写法和函数 不定时更新

    小数转整数: --round() 遵循四舍五入把原值转化为指定小数位数,如: ) -- =1 ) -- =2 --floor() 向下舍入为指定小数位数 如: SELECT floor(1.45) - ...

  6. 关于A类,B类,C类IP地址的网段和主机数的计算方法

    关于A类,B类,C类IP地址的网段和主机数的计算方法 IP地址是一个32位的二进制数,由四个八位字段组成.每个IP地址包括两部分:一部分为网络标识(网络号),一部分为主机标识(主机号). A类地址前8 ...

  7. gitlab 添加ssh秘钥

    在创建新的ssh秘钥对之前,要先确认一下电脑中是否已经有了一对秘钥: Git Bash on Windows / GNU/Linux / macOS / PowerShell: cat ~/.ssh/ ...

  8. Tensorflow梯度下降应用

    import tensorflow as tfimport numpy as np #使用numpy生成随机点x_data = np.random.rand(100)y_data = x_data*0 ...

  9. WordCountPro 编码与测试

    WordCountPro github项目地址:https://github.com/handsomesnail/WordCountPro PSP表格 PSP2.1  PSP阶段  预估耗时(小时) ...

  10. mono-3.0.2安装指南

     install-mono.sh.zip   mono-3.0.2安装指南.pdf   mod_mono.diff.zip mono-3.0.2安装指南 一见 2012/12/27 目录 1. 前言 ...