js中window.scroll与window.onmousewheel区别

    xiaoxiao2022-06-24  34

    1、使用window.scroll必须要有滚动条才能触发,一般配合$(window).scrollTop()使用. 2、window.onmousewheel,document.onmousewheel无论有没有滚动条都能触发 一般的兼容性写法:

    // 滚动注册事件 if(document.addEventListener{ document.addEventListener('DOMMouseScroll',rotate,false); } window.onmousewheel=document.onmousewheel=rotate;

    案例:滚动鼠标修改transform值,链接:http://pan.baidu.com/s/1o8JCUgy 效果:

    转载请注明原文地址: https://ju.6miu.com/read-1123925.html

    最新回复(0)