Skip to content

Instantly share code, notes, and snippets.

@karki-dennis
Last active November 18, 2015 20:26
Show Gist options
  • Save karki-dennis/6e51c5aca99f47bec9db to your computer and use it in GitHub Desktop.
Save karki-dennis/6e51c5aca99f47bec9db to your computer and use it in GitHub Desktop.
jQuery.extend(jQuery.easing, {
easeOutQuint: function(x, t, b, c, d) {
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
}
});
var wheel = false,
$docH = $(document).height() - $(window).height(),
$scrollTop = $(window).scrollTop();
$(window).bind('scroll', function() {
if (wheel === false) {
$scrollTop = $(this).scrollTop();
}
});
$(document).bind('DOMMouseScroll mousewheel', function(e, delta) {
delta = delta || -e.originalEvent.detail / 3 || e.originalEvent.wheelDelta / 120;
wheel = true;
$scrollTop = Math.min($docH, Math.max(0, parseInt($scrollTop - delta * 30)));
$($.browser.webkit ? 'body' : 'html').stop().animate({
scrollTop: $scrollTop + 'px'
}, 2000, 'easeOutQuint', function() {
wheel = false;
});
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment