mousewheel,DOMMouseScroll判断滚轮滚动方向
firefox使用DOMMouseScroll,其他浏览器使用mousewheel
首先绑定一个滚动事件
//firefox使用DOMMouseScroll,其他浏览器使用mousewheel
$(document).bind('mousewheel DOMMouseScroll',mouseScroll);
当滚动时获取wheelDelta值,firefox使用detail:值为下滚3上滚-3,其他浏览器使用wheelDelta:值为下滚-120上滚120,通过判断其值为正或者负即可判断鼠标滚轮上滚还是下滚
function fullscreenScroll(e){
var delta = -e.originalEvent.wheelDelta || e.originalEvent.detail;//firefox使用detail:下3上-3,其他浏览器使用wheelDelta:下-120上120//下滚
if(delta>){
console.log('下滚');
}
//上滚
if(delta<){
console.log('上滚');
}
}
mousewheel,DOMMouseScroll判断滚轮滚动方向的更多相关文章
- jQuery判断鼠标滚动方向
var scrolltop = new Array(); var index = 0; scrolltop[0] = 0; $(document).scroll(function(){ index + ...
- JS滚轮事件(mousewheel/DOMMouseScroll)了解
已经没有了小学生时代过目不忘的记忆力了,很多自己折腾的东西.接触的东西,短短1年之后就全然不记得了.比方说,完全记不得获取元素与页面距离的方法(getBoundingClientRect),或者是不记 ...
- 学习 JS滚轮事件(mousewheel/DOMMouseScroll)
学习 JS滚轮事件(mousewheel/DOMMouseScroll) 1-1 滚轮事件兼容性的差异 IE,chrome,safari 浏览器都使用 onmousewheel, 只有firefo ...
- js判断滚动方向
//页面滚动监听事件 window.onscroll = function (e) { scrollFunc(); $("#t&quo ...
- JS 鼠标滚轮事件(mousewheel/DOMMouseScroll)
onmousewheel (FireFox不支持此事件) // IE/Opera/Chrome/Safari document.body.onmousewheel = function(event) ...
- 实用小技巧(一):UIScrollView中上下左右滚动方向的判断
https://www.jianshu.com/p/93e8459b6dae 2017.06.01 01:13* 字数 674 阅读 1201评论 0喜欢 1 2017.06.01 01:13* 字数 ...
- js 判断滚动条的滚动方向
以下代码实现判断页面的滚动条的滚动方向: var sign = 80;//定义默认的向上滚与向下滚的边界 window.onscroll = window.onresize = function(){ ...
- js判断鼠标滑轮滚动方向并根据滚动的方向触发不同的事件
<script> var scrollFunc = function (e) { var direct = 0; e = e || window.event; if (e.wheelDel ...
- 纯javaScript实现元素平滑滚动,改进前两个版本,支持鼠标滚轮滚动和点击元素滚动,滚动更顺畅
windowScroll(id, number, distance, direction, obj) 参数介绍: 1.id:所要滚动的元素id; 2.number:滚动次数; 3.distance:每 ...
随机推荐
- Git 版本管理基本操作
Git是一个版本管理操作的工具 非常N,可以很智能的分布式管理, 本网站学习笔记 来自于廖雪峰老师的内容借鉴 安装 yum -y install git 本地设置全局 告知是谁提交代码 信息 # gi ...
- CodeForces 719B Anatoly and Cockroaches 思维锻炼题
题目大意:有一排蟑螂,只有r和b两种颜色,你可以交换任意两只蟑螂的位置,或涂改一个蟑螂的颜色,使其变成r和b交互排列的形式.问做少的操作次数. 题目思路:更改后的队列只有两种形式:长度为n以r开头:长 ...
- vi编辑器常见命令的使用
Linux下的文本编辑器有很多种,vi 是最常用的,也是各版本Linux的标配.注意,vi 仅仅是一个文本编辑器,可以给字符着色,可以自动补全,但是不像 Windows 下的 word 有排版功能. ...
- 破解MyEclipse2013注册码
1.下载破解工具 http://down8.3987.com:801/2010/Myeclipse_zcj.3987.com.rar 2.打开 找到meclipse安装路径找到plugins文件夹打开 ...
- Linux学习 -- Shell编程 -- 字符处理命令
sort排序命令 sort [选项] 文件名 -f 忽略大小m写 -n 按数值型,默认字符串型 -r 反向 -t 指定分隔符 -k n[,m] 指定字段范围,默认行尾 eg. sort -n -t & ...
- play1.x vs play2.x 对比(转)
个人看到对比play1.x和play2.x比较的文章中,写的最深入,最清晰的一个.转自:http://freewind.me/blog/20120728/965.html 为了方便群中的Play初学者 ...
- Chapter 1 First Sight——10
Instead, I was ivory-skinned, without even the excuse of blue eyes or red hair, despite the constant ...
- scroll、scrollBy和 scrollTo三种方法定位滚动条位置
在默认情况下,页面加载完后默认滚动在最顶端,有些时候我们需要在页面打开后,定位滚动条的位置,比如,横向和纵向滚动条居中,实现页面滚动的方法有三种:scroll.scrollBy和 scrollTo,三 ...
- Integer自动装箱拆箱bug,创建对象在-128到127
1 public class Demo3 { public static void main(String[] args) { Integer a = 1; Integer b = 2; Intege ...
- 关于java.lang.reflect.InvocationTargetException(jar 包缺少或者冲突)的错误
我在合肥那边运行了的是湖北石首市的项目没有错 可是回武汉之后 运行这个项目 点击这里的时候 就报错java.lang.reflect.InvocationTargetException 不是数据库 ...