js中window.scroll与window.onmousewheel区别

来源:互联网 发布:白银之瞳的前夜 知乎 编辑:程序博客网 时间:2024/05/22 14:35

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
效果:这里写图片描述

0 0