Stop function
bderongs opened this issue · comments
Hi,
Thank you for your plugin, it is the nicest and easiest I have found. I may have missed something but is there any way to stop the timer at the value it is ?
When I do
var A = $("#myElement").circleProgress({...})
I have tried
- A.stop() => Does nothing
- A.circleProgress('stop') => Redraw the circle
Baptiste
Hi!
Currently you may stop animation with next:
$(el.circleProgress('widget')).stop();
Full example
var el = $('.circle');
el.circleProgress({ value: 0.5 });
setTimeout(function () {
$(el.circleProgress('widget')).stop();
}, 500);
I understand that it's not obvious, so it's good idea to include special "stop" method in next version.
I will leave this issue open to not forget to do this.
Thanks, its works perfectly.
I decided not to implement it (because it brings an ambiguity about current value) but to mention the solution in documentation.
i can stop the circel but then , how can i restart it ?
I personaly redraw it with the correct values :
In the progress function I update a stepValueLeft variable
self.stepValueLeft = self.timeDuration-self.timeDuration*stepValue;
Then I have declared a restart function like this one below :
this.restart = function(){
myObject.circleProgress({
value:1,
animationStartValue: this.stepValue,
animation:{
duration: this.stepValueLeft,
easing: "linear"
}
});
};
Probably not the most optimal solution but it works fine.
This worked great to stop it but for some reason it's triggering the circle-animation-end event. I had to change the event to a circle-animation-progress and time the event in order to prevent my actions from triggering too early.
UPDATE:
I decided to try again from scratch and the circle-animation-end behaved properly this time. No idea why the first attempt failed. I suspect I had some bad math in triggering my stop.
Also, for those who needed help executing a restart I managed to stop and restart from where the bar left off by grabbing circle-animation-progress value:
.on('circle-animation-progress', function(e,p,v) {
newStartValue = v.toPrecision(2);
});