0

I am using jQuery runloop for a rather complex animation. Despite the name runLOOP I'm not able run the animation in a loop.

Here is what I tried (simplified):

  var loop = jQuery.runloop();

  loop.addKey('25%', function(){
    console.log('25%');
  });
  loop.addKey('50%', function(){
    console.log('50%');
  });
  loop.addKey('75%', function(){
    console.log('75%');
  });
  loop.play(3000, callback);

  function callback() {
    console.log('done!');
    console.log(loop);
    loop.reset();
    loop.play(3000);
    console.log(loop);
  }

I expected loop.reset(); to reset runloop in a way that allows my to run the loop again with loop.play(); but my console goes crazy after completing the animation for the first time.

Has anyone tried it with success?

– Dominik

Edit: See the code in action -> http://jsfiddle.net/v9UPx/ (turn on your console)

dmnkhhn
  • 1,013
  • 1
  • 10
  • 18

2 Answers2

0

Add pause() before reset() like so:

function callback() {
    loop.pause();
    loop.reset();
    loop.play(3000);
}
Spooky
  • 2,966
  • 8
  • 27
  • 41
Artur
  • 1
0

Your console probably goes 'crazy' when you call console.log(loop); I imagine that's what's doing it.

Calum
  • 5,308
  • 1
  • 22
  • 27