|
104 | 104 |
|
105 | 105 | var filename = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; |
106 | 106 |
|
107 | | - function touchHandler(event) |
108 | | -{ |
109 | | - var touches = event.changedTouches, |
110 | | - first = touches[0], |
111 | | - type = ""; |
112 | | - switch(event.type) |
113 | | - { |
114 | | - case "touchstart": type = "mousedown"; break; |
115 | | - case "touchmove": type = "mousemove"; break; |
116 | | - case "touchend": type = "mouseup"; break; |
117 | | - default: return; |
118 | | - } |
119 | 107 |
|
120 | | - var simulatedEvent = document.createEvent("MouseEvent"); |
121 | | - simulatedEvent.initMouseEvent(type, true, true, window, 1, |
122 | | - first.screenX, first.screenY, |
123 | | - first.clientX, first.clientY, false, |
124 | | - false, false, false, 0/*left*/, null); |
125 | | - |
126 | | - first.target.dispatchEvent(simulatedEvent); |
127 | | -} |
128 | 108 |
|
129 | 109 | init(); |
130 | 110 |
|
131 | 111 | function init() { |
132 | 112 | canvas = document.getElementById('drawingCanvas'); |
133 | | - document.addEventListener("touchstart", touchHandler, true); |
134 | | - document.addEventListener("touchmove", touchHandler, true); |
135 | | - document.addEventListener("touchend", touchHandler, true); |
136 | | - document.addEventListener("touchcancel", touchHandler, true); |
| 113 | + |
137 | 114 | ctx = canvas.getContext("2d"); |
138 | 115 | w = canvas.width; |
139 | 116 | h = canvas.height; |
|
152 | 129 | }, false); |
153 | 130 |
|
154 | 131 | canvas.addEventListener("touchmove", function (e) { |
155 | | - touchHandler, true); |
| 132 | + findxy('out', e.touches[0]), false); |
156 | 133 | canvas.addEventListener("touchstart", function (e) { |
157 | | - touchHandler, true); |
| 134 | + findxy('out', e.touches[0]), false); |
158 | 135 | canvas.addEventListener("touchend", function (e) { |
159 | | - touchHandler, true); |
| 136 | + findxy('out', e.touches[0]), false); |
160 | 137 | } |
161 | 138 |
|
162 | 139 | function draw() { |
|
0 commit comments