语言

Menu
Sites
Language
Web Simulator touch event problem

How to generate touch event? Piano example not works properly under Web Simulator.

编辑者为: Brock Boland 17 3月, 2014 原因: Paragraph tags added automatically from tizen_format_fix module.

响应

4 回复
saab aman
which touch mean by mouse aur hand.because they both are handled differently.and use emulator instead of simulator to check
Artem Novikov
Thanks for advice, but It's impossible to run emulator on my netbook. And seems touch by hand impossible reproduce on Web Simulator..
You can use this code to map the right events( mouse events on computer and touch events on device ) depending on whether you run your app on a pc or a device.
var supportTouch = $.support.touch, scrollEvent = "touchmove scroll", touchStartEvent = supportTouch ? "touchstart" : "mousedown", touchStopEvent = supportTouch ? "touchend" : "mouseup", touchMoveEvent = supportTouch ? "touchmove" : "mousemove";
Then just bind your events using the variables instead of the event name :
$(element).bind(touchStartEvent)
instead of
$(element).bind("touchStart")
Note that you need jQuery for this to work.
Artem Novikov
Ok, it's that easy. Thanks