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:每 ...
随机推荐
- 国内的cdn
测试了一下,百度的非常快 ----------------------------------------------------------------------- 原文:https://www. ...
- mouse的各种事件
IE测试对象为IE9,不全 mousemove(元素内部移动) 鼠标在元素内部移动时触发,只要鼠标移动,即使只是又移动了一个像素,也会触发,这就意味着短时间内会触发多次事件 支持情况: js onmo ...
- WPF InkCanvas 画图 基础使用教程
大家好,由于很多原因,我有很长一段时间没有在 CSDN 上分享我的学习成果了,如今终于可以回归分享之路了. 之前在做一个项目的时候,想在一个区域里绘制自己的图形,于是上网搜索资料,无意中找到了 Ink ...
- vim 操作(转)
高效率移动编辑1.在插入模式之外基本上来说,你应该尽可能少的呆在插入模式里面,因为在插入模式里面 VIM 就像一个“哑巴”编辑器一样.很多新手都会一直呆在插入模式里面,因为这样易于使用.但 VIM 的 ...
- linux(视频学习)2
第二部分(javaee的开发环境的搭建): 1. 安装jdk的过程: 安装ios的镜像文件,挂载到/mnt目录下.挂载: mount /mnt/cdrom卸载: umount /mnt/cdrom ...
- Gson解析数据
package com.bwie.test;import java.io.BufferedReader;import java.io.IOException;import java.io.InputS ...
- java 线程的同步
Example12_7.java public class Example12_7 { public static void main(String args[]) { Bank bank = new ...
- ab测试 uwsgi遇到的问题
1 请求并发数目较大时,接收到的数目小于发送的数目 1.1 描述:uwsgi正常返回302跳转 ab -n 5000 -c 250 -g test.log "192.168.50.20:90 ...
- shortcut to open a linux terminal
1) alt+ f2 2) input "gnome-terminal" 3) press "enter"
- MYSQL启用日志,查看日志,利用mysqlbinlog工具恢复MySQL数据库【转载】
转自 MYSQL启用日志,查看日志,利用mysqlbinlog工具恢复MySQL数据库 - _安静 - 博客园http://www.cnblogs.com/xionghui/archive/2012/ ...