Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop function #37

Closed
bderongs opened this issue Jun 8, 2015 · 6 comments
Closed

Stop function #37

bderongs opened this issue Jun 8, 2015 · 6 comments

Comments

@bderongs
Copy link

bderongs commented Jun 8, 2015

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

@kottenator
Copy link
Owner

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.

@bderongs
Copy link
Author

bderongs commented Jun 9, 2015

Thanks, its works perfectly.

@kottenator
Copy link
Owner

I decided not to implement it (because it brings an ambiguity about current value) but to mention the solution in documentation.

@hellozhangran
Copy link

i can stop the circel but then , how can i restart it ?

@bderongs
Copy link
Author

bderongs commented Aug 4, 2016

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.

@hioctane321
Copy link

hioctane321 commented Apr 10, 2019

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);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants