Wednesday, 11 September 2013

Execute code repeatedly during animation?

Execute code repeatedly during animation?

I've seen something like this in java and I'm wondering if it's there
something similar in javascript/jquery. Basically I have a function with
an animation and a code that runs at the end of it:
$('html,body').animate({ scrollTop: 0 }, 'slow', function(){
lastScrollTop = $(this).scrollTop();
});
However I want this code to be updated during the animation eg: if the
user is 500px, I want lastScrollTop to become 450,400,300,200,100,50,0
Is there a way to keep my variable updated during the animation?

No comments:

Post a Comment