简体   繁体   English

触摸未在Safari桌面上触发的事件

[英]touch events not firing in safari desktop

I'm developing an app that would support touch events on desktop and mobile devices. 我正在开发一款支持桌面和移动设备上的触摸事件的应用。 when using something like (per https://developer.apple.com/library/safari/#documentation/appleapplications/reference/SafariWebContent/HandlingEvents/HandlingEvents.html ) 使用类似的东西时(根据https://developer.apple.com/library/safari/#documentation/appleapplications/reference/SafariWebContent/HandlingEvents/HandlingEvents.html

element.addEventListener("touchstart", touchStart, false);
element.addEventListener("touchmove", touchMove, false);
element.addEventListener("touchend", touchEnd, false);
element.addEventListener("touchcancel", touchCancel, false);

these only fire when testing on ipad and iphone, not on desktop. 这些只在ipad和iphone上测试时发生,而不是在桌面上测试。 Since I'm developing on desktop, how could I make so these events are recognized? 由于我在桌面上开发,我怎么能这样才能识别这些事件?

You could view your website in iOS simulator, that is included in XCode on MacOs. 您可以在iOS模拟器中查看您的网站,该模拟器包含在MacO上的XCode中。

Hope it helps. 希望能帮助到你。

On the test machines we use phantom limb to simulate touches. 在测试机器上,我们使用幻肢来模拟触摸。 It's easy to setup and also won't do anything if the device supports touch natively. 如果设备本身支持触摸,它很容易设置,也不会做任何事情。

Otherwise follow Alexey's advice and use the Simulator and a real device as often as possible. 否则,请遵循Alexey的建议,尽可能经常使用模拟器和真实设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM