I have this very simple script for easing the mousewheel scrolling on my website. It works great with jQuery 1.8.3, but not at all with 2.0.1 which is what I already have on my website for another script. I was wondering what could be the cause of this script not working on a newer version of jQuery?
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'
}, 500, 'easeOutQuint', function() {
wheel = false;
});
return false;
});
It's this line
$($.browser.webkit ? 'body' : 'html').stop().animate({ ...
jQuery's $.browser
was deprecated as early as jQuery 1.3, and finally removed in jQuery 1.9
You can just do this instead
$('body, html').stop().animate({ ....