标签:style blog io color ar sp div on log
$(function() { // 设置每次滚动长度,单位 px var scroll_width = 100; var scroll_events = "mousewheel DOMMouseScroll MozMousePixelScroll"; $("body").on(scroll_events, function(e) { var delta = e.originalEvent.wheelDelta console.log(delta); var detail= e.originalEvent.detail; // 滑轮向下滚动,滚动条向右移动,scrollleft+ if(!detail){ this.scrollLeft-= (delta); }else{ if(detail>0){ $("html").scrollLeft($("html").scrollLeft() + scroll_width); } // 滑轮向上滚动,滚动条向座移动,scrollleft- else{ $("html").scrollLeft($("html").scrollLeft() - scroll_width); } } }); });
目前来说是最简洁的了!
标签:style blog io color ar sp div on log
原文地址:http://www.cnblogs.com/woleicom/p/4058561.html