鼠标事件在移动设备中不起作用

编程入门 行业动态 更新时间:2024-10-21 10:27:47
本文介绍了鼠标事件在移动设备中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了这个 360 全景图像,它在桌面上运行良好,但在手机上鼠标事件不工作.我如何为移动设备解决这个问题?

I created this 360 panorama image which is working fine in desktop but on mobile phones the mouse events are not working. How can i fix this for mobile?

//监听器

document.addEventListener("mousedown", onDocumentMouseDown, false); document.addEventListener("mousemove", onDocumentMouseMove, false); document.addEventListener("mouseup", onDocumentMouseUp, false);

我将事件更改为

document.addEventListener("touchstart", onDocumentMouseDown, false); document.addEventListener("touchmove", onDocumentMouseMove, false); document.addEventListener("touchend", onDocumentMouseUp, false);

但这不适用于移动设备.

but this is not working for mobile.

推荐答案

我找到了答案.对于触摸 event.clientX 和 event.clientY 不起作用,我已将其更改为 event.touches[0].clientX 和 event.touches[0].clientY,它修复了触摸事件问题.

i found the answer. For touch event.clientX and event.clientY were not working which i have changed to event.touches[0].clientX and event.touches[0].clientY and it fixed the touch event issue.

更多推荐

鼠标事件在移动设备中不起作用

本文发布于:2023-11-27 04:15:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:鼠标   中不   事件   设备

发布评论

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

>www.elefans.com

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