mousewheel滚轮事件 浏览器的写法
鼠标的滚轮事件,在Jquery中有对应的一个插件:https://github.com/brandonaaron/jquery-mousewheel
原生的滚轮事件:火狐与其他浏览器使用了不同的事件
/*
* 滚轮事件只有firefox比较特殊,使用DOMMouseScroll; 其他浏览器使用mousewheel;
*
*/
// firefox
document.body.addEventListener("DOMMouseScroll", function(event) { var direction= event.detail && (event.detail > 0 ? "mousedown" : "mouseup");
console.log(direction);
}); // chrome and ie
document.body.onmousewheel = function (event) {
event = event || window.event; var direction = event.wheelDelta && (event.wheelDelta > 0 ? "mouseup" : "mousedown");
console.log(direction);
};
使用jquery兼容后的事件
// jquery 兼容的滚轮事件
$(document).on("mousewheel DOMMouseScroll", function (e) { var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || // chrome & ie
(e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); // firefox if (delta > 0) {
// 向上滚
console.log("wheelup");
} else if (delta < 0) {
// 向下滚
console.log("wheeldown");
}
});
mousewheel滚轮事件 浏览器的写法的更多相关文章
- mousewheel滚轮事件
		
原生的滚轮事件:火狐与其他浏览器使用了不同的事件 /* * 滚轮事件只有firefox比较特殊,使用DOMMouseScroll; 其他浏览器使用mousewheel; * */ // firefox ...
 - 鼠标滚轮事件MouseWheel
		
其实在大多数浏览器(IE6, IE7, IE8, Opera 10+, Safari 5+,Chrome)中,都提供了 "mousewheel" 事件.但杯具的是 Firefox ...
 - JS滚轮事件(mousewheel/DOMMouseScroll)了解
		
已经没有了小学生时代过目不忘的记忆力了,很多自己折腾的东西.接触的东西,短短1年之后就全然不记得了.比方说,完全记不得获取元素与页面距离的方法(getBoundingClientRect),或者是不记 ...
 - 学习 JS滚轮事件(mousewheel/DOMMouseScroll)
		
学习 JS滚轮事件(mousewheel/DOMMouseScroll) 1-1 滚轮事件兼容性的差异 IE,chrome,safari 浏览器都使用 onmousewheel, 只有firefo ...
 - Winform 中panel的mousewheel鼠标滚轮事件触发
		
如果将窗体或容器控件(如Panel控件)的AutoScroll属性设置为True时,那么当窗体或Panel容不下其中的子控件时就会出现 滚动条,通过移动滚动条可以上下显示出窗体或Panel中的全部内容 ...
 - 事件冒泡、事件委托、jQuery元素节点操作、滚轮事件与函数节流
		
一.事件冒泡定义 事件冒泡是指在一个对象触发某类事件(比如单击onclick事件),如果此对象定义了此事件的处理程序,那么此事件就会调用这个处理程序,如果没有定义此事件处理程序或者事件返回true,那 ...
 - JS鼠标滚轮事件详解
		
鼠标滚轮事件 //兼容性写法,该函数也是网上别人写的,不过找不到出处了,蛮好的,所有我也没有必要修改了 //判断鼠标滚轮滚动方向 if (window.addEventListener)//FF,火狐 ...
 - Javascript和jquery事件--鼠标滚轮事件WheelEvent
		
<1>js事件 滚轮事件在js中,不同浏览器还是有不同的,介于我只测试谷歌和火狐浏览器的情况,其他浏览器有待自行探索.有三种写法: target.onmousewheel = wheel; ...
 - js中的鼠标滚轮事件
		
## 事件对象 event 1 event事件对象,表示用来获取事件的详细信息,比如得到鼠标的横坐标:事件对象.clientX(clientX是可视区坐标) window.onclick = func ...
 
随机推荐
- 137. Single Number II
			
Given an array of integers, every element appears three times except for one. Find that single one. ...
 - 112. Path Sum
			
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...
 - 2015GitWebRTC编译实录5
			
2015.07.20 libaudio_encoder_interface/libaudio_decoder_interface 编译通过将encoder,decoder两个lib合并了,后面需要看看 ...
 - C#部分---arraylist集合、arraylist集合中的object数据转换成int类string类等;间隔时间的表示方法;
			
ArrayList和Array的区别: 相同点:1.两者都实现了IList.ICollection.IEnumerable接口: 2.两者都可以使用证书索引访问集合中的元素,包括读取和赋值 ...
 - 转:SQL:外连接on条件与where条件的区别
			
原文地址:http://hi.baidu.com/benben1006/blog/item/187deb77bc0e5319b151b974.html 数据库在通过连接两张或多张表来返回记录时,都会生 ...
 - Android ——Handler相关
			
layout文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...
 - CLR thread pool
			
Thread Pooling https://msdn.microsoft.com/en-us/library/windows/desktop/ms686756(v=vs.85).aspx Threa ...
 - OpenJudge计算概论-文字排版
			
/*====================================================================== 文字排版 总时间限制: 1000ms 内存限制: 65 ...
 - const, static and readonly
			
const, static and readonly http://tutorials.csharp-online.net/const,_static_and_readonly Within a cl ...
 - C#基础——Func和Action的介绍及其用法
			
Func是一种委托,这是在3.5里面新增的,2.0里面我们使用委托是用Delegate,Func位于System.Core命名空间下,使用委托可以提升效率,例如在反射中使用就可以弥补反射所损失的性能. ...