I'm using the popular mousewheel plugin to to emulate the fullpage scroll like this website.
jQuery(function() {
var top = 0,
viewport = jQuery(window).height(),
step = jQuery(".home .l-section:first").outerHeight(),
body = jQuery.browser.webkit ? jQuery('body') : jQuery('html'),
wheel = false;
jQuery('body').mousewheel(function(event, delta) {
wheel = true;
if (delta < 0) {
top = (top + viewport) >= jQuery(document).height() ? top : top += step;
body.stop().animate({
scrollTop: top
}, 400, function() {
wheel = false;
});
} else {
top = top <= 0 ? 0 : top -= step;
body.stop().animate({
scrollTop: top
}, 400, function() {
wheel = false;
});
}
return false;
});
jQuery(window).on('resize', function(e) {
viewport = jQuery(window).height();
step = jQuery(".home .l-section:first").outerHeight();
});
jQuery(window).on('scroll', function(e) {
if (!wheel) top = jQuery(this).scrollTop();
});
});
It works great but NOT when using the trackpad. Using trackpad, it just scrolls to the bottom of the page no matter how slowly I try to scroll.
to anyone else who finds this, the "mousewheel" event has been deprecated. https://developer.mozilla.org/en-US/docs/Web/Events/wheel
instead, use the "wheel" event you can use the "originalEvent" property on the wheel event to get to the attributes you would be expecting. (deltaX, deltaY, etc...)
I solved my problem tracking with date(), so the user is not able to scroll any more if a certain time set by me, is not in the past.
Here is my snippet just using the 'wheel' function
I have used underscore's debounce function to overcome this issue. This is the code I have used.
Works well with my laptop's trackpad. However, this is known issue, did you try using debounce?
This is already reported issue here : https://github.com/brandonaaron/jquery-mousewheel/issues/36
You will get multiple solutions there. Hope that helps. Help yourself :-)
Peace,
Rahul