Home >Web Front-end >JS Tutorial >ProgressBar.js – Beautiful responsive SVG progress bar

ProgressBar.js – Beautiful responsive SVG progress bar

高洛峰
高洛峰Original
2016-12-16 16:35:351756browse

ProgressBar.js is a beautiful, responsive progress bar effect using dynamic SVG paths. Progress bars of any shape can be easily created using ProgressBar.js. This JavaScript library provides several built-in shapes such as lines, circles, and squares, but you can create your own progress bar effects using Illustrator or any other vector graphics editor.

Line progress bar:

var line = new ProgressBar.Line('#example-line-container', {
    color: '#FCB03C'
});
 
line.animate(1);

Circular progress bar:

var circle = new ProgressBar.Circle('#example-circle-container', {
    color: '#FCB03C',
    strokeWidth: 2,
    fill: '#aaa'
});
 
circle.animate(1, function() {
    circle.animate(0);
})

Custom shape and path:

var container = document.getElementById('example-custom-container');
container.innerHTML = &#39;<object id="scene" type="image/svg+xml" data="images/moon-scene.svg"></object>&#39;;
 
var scene = document.getElementById(&#39;scene&#39;);
scene.addEventListener(&#39;load&#39;, function() {
    var path = new ProgressBar.Path(scene.contentDocument.querySelector(&#39;#asterism-path&#39;), {
        duration: 1000
    });
 
    path.animate(1, function() {
        path.animate(0);
    });
});



For more ProgressBar.js – beautiful responsive SVG progress bar related articles please pay attention to PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn