source: other-projects/nz-flag-design/trunk/design-2d/Original editor.method.ac/editor/lib/touch.js@ 29468

Last change on this file since 29468 was 29468, checked in by sjs49, 9 years ago

Initial commit for editor.method.ac for flag design

  • Property svn:executable set to *
File size: 1008 bytes
Line 
1function touchHandler(event)
2{
3
4 var touches = event.changedTouches,
5 first = touches[0],
6 type = "";
7 switch(event.type)
8 {
9 case "touchstart": type="mousedown"; break;
10 case "touchmove": type="mousemove"; break;
11 case "touchend": type="mouseup"; break;
12 default: return;
13 }
14
15 //initMouseEvent(type, canBubble, cancelable, view, clickCount,
16 // screenX, screenY, clientX, clientY, ctrlKey,
17 // altKey, shiftKey, metaKey, button, relatedTarget);
18
19 var simulatedEvent = document.createEvent("MouseEvent");
20 simulatedEvent.initMouseEvent(type, true, true, window, 1,
21 first.screenX, first.screenY,
22 first.clientX, first.clientY, false,
23 false, false, false, 0/*left*/, null);
24 if(touches.length < 2) {
25 first.target.dispatchEvent(simulatedEvent);
26 event.preventDefault();
27 }
28}
Note: See TracBrowser for help on using the repository browser.