scrollHelper
1 (function ($) { 2 var mouseScroll = function (e) { 3 try { 4 var origEvent = e.originalEvent; 5 origEvent.preventDefault(); 6 } catch (err) { 7 } 8 }; 9 var mouseWheel = function (e) { 10 try { 11 e = e || window.event; 12 e.preventDefault(); 13 e.returnValue = false; 14 } catch (err) { 15 } 16 }; 17 $.fn.preventOuterScroll = function () { 18 var element = this.get(0); 19 if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1) { 20 this.on("DOMMouseScroll", function (e) { 21 var origEvent = e.originalEvent; 22 element.scrollTop += origEvent.detail > 0 ? 60 : -60; 23 origEvent.preventDefault(); 24 }); 25 } else { 26 element.onmousewheel = function (e) { 27 e = e || window.event; 28 element.scrollTop += e.wheelDelta > 0 ? -60 : 60; 29 e.preventDefault(); 30 e.returnValue = false; 31 }; 32 } 33 return this; 34 }; 35 $.fn.preventScroll = function () { 36 var element = this.get(0); 37 if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1) { 38 this.on("DOMMouseScroll", mouseScroll); 39 } else { 40 $(element).on("mousewheel", mouseWheel); 41 } 42 return this; 43 }; 44 $.fn.liveScroll = function() { 45 var element = this.get(0); 46 if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1) { 47 this.off("DOMMouseScroll", mouseScroll); 48 } else { 49 $(element).off("mousewheel", mouseWheel); 50 } 51 return this; 52 }; 53 }($));