码迷,mamicode.com
首页 > Web开发 > 详细

用svg实现上传图片进度条效果

时间:2015-08-04 09:27:06      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:svg

demo:http://codepen.io/tianzi77/pen/jPXRKo

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <svg width="440" height="440">
        <circle cx="220" cy="220" r="170" stroke-width="50" stroke="#f5f89a" fill="none"></circle>
        <circle cx="220" cy="220" r="170" stroke-width="50" stroke="#abcdef" fill="none" transform="matrix(0,-1,1,0,0,440)" stroke-dasharray="0 1069"></circle>
        <p>拖我:
            <input id="range" type="range" min="0" max="100" value="0" style="width:300px;">
        </p>
    </svg>
    <script>
        var range = document.querySelector(‘#range‘),
            circle = document.querySelectorAll(‘circle‘)[1];
        range.addEventListener(‘change‘, function () {
            var percent = this.value / 100,
                perimeter = Math.PI * 2 * 170;
            circle.setAttribute(‘stroke-dasharray‘, perimeter * percent + " " + perimeter * (1 - percent));
        })
    </script>
</body>

</html>

版权声明:本文为博主原创文章,未经博主允许不得转载。

用svg实现上传图片进度条效果

标签:svg

原文地址:http://blog.csdn.net/u011263845/article/details/47271685

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!