Last active
November 18, 2015 20:26
-
-
Save karki-dennis/6e51c5aca99f47bec9db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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