检测水平鼠标滚轮(Detect the horizontal mousewheel)

编程入门 行业动态 更新时间:2024-10-17 19:25:55
检测水平鼠标滚轮(Detect the horizontal mousewheel)

我想对三种情况进行区分:

e.preventDefault(); if(Mousewheel.direction = Left) base.goForward(); else if(Mousewheel.direction = Right) base.goBack(); else{ //Doing normal slide

但我找不到任何指示鼠标滚轮是水平还是垂直的东西,插件鼠标滚轮的唯一返回,即delta和event。

如果有人知道如何在水平和垂直方向上进行区分,感谢您分享您的提示。

I would like to make a differenciation between three cases :

e.preventDefault(); if(Mousewheel.direction = Left) base.goForward(); else if(Mousewheel.direction = Right) base.goBack(); else{ //Doing normal slide

But I can't find anything indicating if the mousewheel is horizontal or vertical, the only returns of the plugin Mousewheel, being delta and event.

If someone knows how i could make a differenciation between horizontal and vertical wheeling, thanks for sharing your tips.

最满意答案

更新 :我用我的笔记本电脑垫测试它和event.originalEvent.wheelDeltaX确实是你的答案。

使用一些javascript调试工具,将断点放入事件处理程序并检查事件对象。

在此处输入图像描述

有一些有趣的属性,如event.originalEvent.wheelDeltaX和event.originalEvent.wheelDeltaY 。 我没有水平滚动鼠标来测试它,但这可能是你的解决方案。

UPDATE: I tested it with my laptops pad and event.originalEvent.wheelDeltaX is indeed your answer.

Using some javascript debugging tools, place a breakpoint into the event handler and examine the event object.

enter image description here

There are some interesting properties there like event.originalEvent.wheelDeltaX and event.originalEvent.wheelDeltaY. I don't have a mouse with horizontal scrolling to test it but possibly this is your solution.

更多推荐

本文发布于:2023-08-03 11:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1387038.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:鼠标   滚轮   水平   mousewheel   horizontal

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!