Reputation: 6805
I'm using Ariel Flesler's awesome scrollto plugin. But I want to determine when the plugin has finished scrolling. The scrollto speed is set to 800 on my page. How can I do that?
I've tried:
isScrolling = true;
jQuery(listWrapper).scrollTo(theId, 800);
isScrolling = false;
But it seems as though isScrolling = false
gets set before the scrolling completes.
I have some JavaScript attached to the scrollto event in addition to this. The scrolling slows down to a painful speed because it's trying to do smooth scroll and run the scroll event at the same time. I was hoping to effectively disable the scroll event while it's scrolling, and re-enable it when the scrolling has completed.
Upvotes: 1
Views: 2737
Reputation: 229
The plugin has a callback function that is called when the animation is over:
onAfter: A function to be called after the whole animation ended.
Upvotes: 3
Reputation: 69905
Use onAfter
event which is triggered after the scrolling has finished which is also the third argument of scrollTo
plugin as a callback function. Try this.
isScrolling = true;
jQuery(listWrapper).scrollTo(theId, 800, function(){
isScrolling = false;
});
Upvotes: 2
Reputation: 38345
Assuming you're using this scrollTo plugin, there's an onAfter
option that takes a function to execute once the scrolling has completed.
Upvotes: 0