Using the mousewheel plugin, I have:
$('html, body').bind("mousewheel", function(objEvent, intDelta){
if (intDelta > 0 && $currentPage != 1){
$currentPage--;
$('html, body').animate({scrollTop:$("#page"+$currentPage).offset().top}, 2000);
}
else if (intDelta < 0 && $currentPage != 4){
$currentPage++;
$('html, body').animate({scrollTop:$("#page"+$currentPage).offset().top}, 2000);
}
});
Which works fine, but whenever I scroll, it scrolls up or down the page a tick first before doing the animation. Is there any way to disable this? Thanks!
Just add a
return false;
Before the last brace.
$('html, body').bind("mousewheel", function(objEvent, intDelta){
if (intDelta > 0 && $currentPage != 1){
$currentPage--;
$('html, body').animate({scrollTop:$("#page"+$currentPage).offset().top}, 2000);
}
else if (intDelta < 0 && $currentPage != 4){
$currentPage++;
$('html, body').animate({scrollTop:$("#page"+$currentPage).offset().top}, 2000);
}
return false;
});
BTW, you should use .on() instead of .bind()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With