jQuery runloop - how to create a loop?
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();
l开发者_如何学Pythonoop.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)
Your console probably goes 'crazy' when you call console.log(loop);
I imagine that's what's doing it.
Add pause()
before reset()
like so:
function callback() {
loop.pause();
loop.reset();
loop.play(3000);
}
精彩评论