鼠标滚轮 控制作用滚动
生活随笔
收集整理的這篇文章主要介紹了
鼠标滚轮 控制作用滚动
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
config.maxScroll = $('.scroll-x table').outerWidth() - $('.scroll-x').outerWidth();config.speed = 30;$('.scroll-x')[0] ? $('.scroll-x')[0].onmousewheel = function(event) {if($(this).width() == $(this).find('table').width()){return;};var event = event ? event : window.event;var dir = event.wheelDelta;var k = event.wheelDelta ? event.wheelDelta : -event.detail * 10;$(this)[0].scrollTop = $(this)[0].scrollTop - k;if (dir > 0) { // 向右config.tableScroll += config.speed;if (config.tableScroll >= config.maxScroll) {config.tableScroll = config.maxScroll;}} else { // 向左config.tableScroll -= config.speed;if (config.tableScroll <= 0) {config.tableScroll = 0;}}$(this).scrollLeft(config.tableScroll);return false;} : '';$('.scroll_speed').click(function() {$(this).addClass('btn-primary');$(this).siblings('.scroll_speed').removeClass('btn-primary')config.speed = $(this).data('speed') ? $(this).data('speed') : config.speed;}); <div class="scroll-x"><table></table>
</div>
?
轉(zhuǎn)載于:https://www.cnblogs.com/heqhbk/p/5163677.html
總結(jié)
以上是生活随笔為你收集整理的鼠标滚轮 控制作用滚动的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Spring MVC 基础注解之@Req
- 下一篇: 16-01-25---Servlet复习