首页 > 代码库 > scrollHelper
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 = http://www.mamicode.com/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 = http://www.mamicode.com/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 }($));
scrollHelper
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。