diff --git a/lib/jquery.simplr.smoothscroll.js b/lib/jquery.simplr.smoothscroll.js index 6dc60bf..c934994 100644 --- a/lib/jquery.simplr.smoothscroll.js +++ b/lib/jquery.simplr.smoothscroll.js @@ -21,7 +21,7 @@ // private fields & init var container = self.container - , top = 0 + , top = self.target.scrollTop() , step = self.step , viewport = container.height() , wheel = false @@ -36,19 +36,24 @@ // events self.target.mousewheel(function (event, delta) { - wheel = true + if( !event.ctrlKey && !event.metaKey){ - if (delta < 0) // down - top = (top+viewport) >= self.target.outerHeight(true) ? top : top+=step + wheel = true - else // up - top = top <= 0 ? 0 : top-=step + if (delta < 0){ + // down + top = (top+viewport) >= self.target.outerHeight(true) ? top : top+=step + } else { + // up + top = top <= 0 ? 0 : top-=step + } - target.stop().animate({scrollTop: top}, self.speed, self.ease, function () { - wheel = false - }) + target.stop().animate({scrollTop: top}, self.speed, self.ease, function () { + wheel = false + }) - return false + return false + } }) container diff --git a/lib/jquery.simplr.smoothscroll.min.js b/lib/jquery.simplr.smoothscroll.min.js index e88a6c7..152d08e 100644 --- a/lib/jquery.simplr.smoothscroll.min.js +++ b/lib/jquery.simplr.smoothscroll.min.js @@ -1,2 +1 @@ -/* jquery.simplr.smoothscroll version 1.1 copyright (c) 2012 https://github.com/simov/simplr-smoothscroll licensed under MIT */ -!function(e){"use strict";e.srSmoothscroll=function(t){var n,o=e.extend({step:55,speed:400,ease:"swing",target:e("body"),container:e(window)},t||{}),r=o.container,i=0,s=o.step,a=r.height(),c=!1;n="body"==o.target.selector?-1!==navigator.userAgent.indexOf("AppleWebKit")?o.target:e("html"):r,o.target.mousewheel(function(e,t){return c=!0,i=0>t?i+a>=o.target.outerHeight(!0)?i:i+=s:0>=i?0:i-=s,n.stop().animate({scrollTop:i},o.speed,o.ease,function(){c=!1}),!1}),r.on("resize",function(){a=r.height()}).on("scroll",function(){c||(i=r.scrollTop())})}}(jQuery); +!function(e){"use strict";e.srSmoothscroll=function(t){var o,n=e.extend({step:55,speed:400,ease:"swing",target:e("body"),container:e(window)},t||{}),r=n.container,i=n.target.scrollTop(),s=n.step,a=r.height(),c=!1;o="body"==n.target.selector?-1!==navigator.userAgent.indexOf("AppleWebKit")?n.target:e("html"):r,n.target.mousewheel(function(e,t){return e.ctrlKey||e.metaKey?void 0:(c=!0,i=0>t?i+a>=n.target.outerHeight(!0)?i:i+=s:0>=i?0:i-=s,o.stop().animate({scrollTop:i},n.speed,n.ease,function(){c=!1}),!1)}),r.on("resize",function(e){a=r.height()}).on("scroll",function(e){c||(i=r.scrollTop())})}}(jQuery); \ No newline at end of file