简体   繁体   中英

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 )

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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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