Color of the "empty" arc. Only a color fill supported by now Default: "rgba(0, 0, 0, .1)"
animation
Animation config. See jQuery animations. You may also set it to false Default: { duration: 1200, easing: "circleProgressEasing" } "circleProgressEasing"is just a ease-in-out-cubic easing
animationStartValue
Default animation starts at 0.0 and ends at specified value. Let's call this direct animation. If you want to make reversed animation then you should set animationStartValue to 1.0. Also you may specify any other value from 0.0 to 1.0 Default: 0.0
insertMode
Canvas insertion mode: append or prepend it into the parent element? Default: "prepend"
From version 1.1.3 you can specify any config option as HTML data- attribute.
It will work only on init, i.e. after the widget is inited you may update its properties only via .circleProgress({/*...*/}) method. data- attributes will be ignored.
Also, object options like "fill" or "animation" should be valid JSON (and don't forget about HTML-escaping):
function(event, animationProgress, stepValue): - event - jQuery event - animationProgress - from 0.0 to 1.0 - stepValue - current step value: from 0.0 to value
circle-animation-end
Triggered once the animation is finished.
function(event): - event - jQuery event
Browsers support
The library uses <canvas> which is supported by all modern browsers (including mobile browsers)
and Internet Explorer 9+ (Can I Use).
I haven't implemented any fallback / polyfill for unsupported browsers yet
(i.e. for Internet Explorer 8 and older / misc browsers).
Assuming that you have jquery, jquery-circle-progress and requirejs in libs/ directory:
<scriptsrc="libs/requirejs/require.js"></script><script>requirejs.config({paths: {'jquery': 'libs/jquery/dist/jquery',// 'jquery' path is required - 'jquery-circle-progress' requires it'jquery-circle-progress': 'libs/jquery-circle-progress/dist/circle-progress'// and this one is for your convenience}});requirejs(['jquery','jquery-circle-progress'],function($){$('#circle').circleProgress({value: 0.75});});</script>
You can configure RequireJS as you wish, just make 'jquery' dependency reachable.
It will return the first item's value (by first I mean when $('.circle').length >= 1).
It works only if the widget is already inited. Raises an error otherwise.
Set it:
$('.circle').circleProgress('value',0.75);// set value to 0.75 & animate the change
It will update all selected items value and animate the change.
It doesn't redraw the widget - it updates the value & animates the changes.
For example, it may be an AJAX loading indicator, which shows the loading progress.
It will return the first item's <canvas> (by first I mean when $('.circle').length >= 1).
It works only if the widget is already inited. Raises an error otherwise.
Get CircleProgress instance
varinstance=$('#circle').data('circle-progress');
Redraw existing circle
$('#circle').circleProgress({value: 0.5,fill: {color: 'orange'}});$('#circle').circleProgress('redraw');// use current configuration and redraw$('#circle').circleProgress();// alias for 'redraw'$('#circle').circleProgress({size: 150});// set new size and redraw
It works only if the widget is already inited. Raises an error otherwise.
Change default options
$.circleProgress.defaults.size=50;
FAQ
How to start the animation only when the circle appears in browser's view (on scrolling)?
请发表评论