本文介绍了鼠标事件在移动设备中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了这个 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.
更多推荐
鼠标事件在移动设备中不起作用
发布评论