Reputation: 787
I have a small animation of a home page and need to disable the mousewheel till it's done (which I manage to do with the jquery mousewheel plugin). My problem is that I can't figure out how to enable the mousewheel again after this animation.
$('html, body').animate({
scrollTop: $("#header").position().top }, 3000).bind("mousewheel", function() {
return false; });
Upvotes: 0
Views: 107
Reputation: 150080
I would guess .unbind("mousewheel")
would be the thing. So:
$('html, body').animate({
scrollTop: $("#header").position().top
}, 3000, function() {
$(this).unbind("mousewheel");
}).bind("mousewheel", function () {
return false;
});
The .animate()
method lets you supply a callback function that will be called on completion of the animation, so within that function you can unbind your mousewheel handler.
(Note: if you're using jQuery version 1.7 or later it is generally recommended to use .on()
and .off()
rather than .bind()
and .unbind()
, though for this purpose they do the same thing.)
Upvotes: 4