JavaScriptを色々あれこれしようとするがひたすら失敗を繰り返している
リビジョン | 47 (tree) |
---|---|
日時 | 2016-12-10 15:20:49 |
作者 | ![]() |
・タッチイベント対応
@@ -326,7 +326,7 @@ | ||
326 | 326 | window.appArea.setSingleTouchEventObj('DispBase',this.mouseMove.bind(this), this.mouseUp.bind(this)); |
327 | 327 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
328 | 328 | evt.preventDefault(); // 要素既定のdefault動作を止める |
329 | - this.startMovingElement(evt.touches[0]); | |
329 | + this.startMovingElement(evt.targetTouches[0]); | |
330 | 330 | } |
331 | 331 | startMovingElement(evt){ |
332 | 332 | /* test |
@@ -354,9 +354,11 @@ | ||
354 | 354 | window.partsFocus.setClingingPartner(this.DOMbase); |
355 | 355 | |
356 | 356 | } |
357 | - mouseMove(evt, xy) { | |
358 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
359 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
357 | + mouseMove(evt, touchevt) { | |
358 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
359 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
360 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
361 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
360 | 362 | |
361 | 363 | /* test |
362 | 364 | let matp = matPerspective(1); |
@@ -388,12 +390,14 @@ | ||
388 | 390 | this.DOMbase.style.top = y + "px"; |
389 | 391 | this.DOMobject.style.opacity = 0.4; |
390 | 392 | } |
391 | - mouseUp(evt, target) { | |
393 | + mouseUp(evt, target, touchevt) { | |
392 | 394 | this.debuglog("mouseUp"); |
393 | 395 | // Mouse event処理対象をクリア |
394 | - window.appArea.setMouseEventObj(null, null, null); | |
395 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
396 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
396 | + window.appArea.clearCallEventObj(); | |
397 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
398 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
399 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
400 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
397 | 401 | |
398 | 402 | |
399 | 403 | // 移動元として座標を保持 |
@@ -197,7 +197,7 @@ | ||
197 | 197 | evt.preventDefault(); // 要素既定のdefault動作を止める |
198 | 198 | // Mouse eventをappAreaからScalerに渡してもらうように設定 |
199 | 199 | window.appArea.setSingleTouchEventObj(null, this.mouseMoveScale.bind(this), this.mouseUpScale.bind(this)); |
200 | - this.startScaling(evt.touches[0]); | |
200 | + this.startScaling(evt.targetTouches[0]); | |
201 | 201 | } |
202 | 202 | startScaling(evt){ |
203 | 203 | let eleFocus = this.getFocusdElements(); |
@@ -219,11 +219,13 @@ | ||
219 | 219 | this.startDragX = tmp2[0]; |
220 | 220 | this.startDragY = tmp1[1]; |
221 | 221 | } |
222 | - mouseMoveScale(evt) { | |
222 | + mouseMoveScale(evt, touchevt) { | |
223 | 223 | let eleFocus = this.getFocusdElements(); |
224 | 224 | if (eleFocus.length < 2) return; |
225 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
226 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
225 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
226 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
227 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
228 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
227 | 229 | |
228 | 230 | // 画像を反転している場合、マウス入力座標も反転させる |
229 | 231 | // let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2; |
@@ -338,15 +340,17 @@ | ||
338 | 340 | eleFocus[1].style.fontSize = scalefont + '%'; |
339 | 341 | } |
340 | 342 | |
341 | - mouseUpScale(evt) { | |
343 | + mouseUpScale(evt, target, touchevt) { | |
342 | 344 | this.debuglog('mouseUpScale'); |
343 | 345 | // Mouse event callback設定をクリア |
344 | - window.appArea.setMouseEventObj(null, null, null); | |
346 | + window.appArea.clearCallEventObj(); | |
345 | 347 | |
346 | 348 | let eleFocus = this.getFocusdElements(); |
347 | 349 | if (eleFocus.length < 2) return; |
348 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
349 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
350 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
351 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
352 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
353 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
350 | 354 | |
351 | 355 | let tmp3 = rotateZ(this.x1, this.y1, eleFocus[0].dataset.degree, evt.pageX, evt.pageY); |
352 | 356 | let tmp1 = rotateUD(this.y1, this.degUD, tmp3[0], tmp3[1]); |
@@ -411,7 +415,7 @@ | ||
411 | 415 | evt.preventDefault(); // 要素既定のdefault動作を止める |
412 | 416 | // Mouse eventをappAreaからRollerに渡してもらうように設定 |
413 | 417 | window.appArea.setSingleTouchEventObj(null, this.mouseMoveRoll.bind(this), this.mouseUpRoll.bind(this)); |
414 | - this.startRolling(evt.touches[0]); | |
418 | + this.startRolling(evt.targetTouches[0]); | |
415 | 419 | } |
416 | 420 | startRolling(evt){ |
417 | 421 | let eleFocus = this.getFocusdElements(); |
@@ -421,11 +425,13 @@ | ||
421 | 425 | this.degUD = parseInt(eleFocus[0].dataset.mirrorud); |
422 | 426 | this.degLR = parseInt(eleFocus[0].dataset.mirrorlr); |
423 | 427 | } |
424 | - mouseMoveRoll(evt) { | |
428 | + mouseMoveRoll(evt, touchevt) { | |
425 | 429 | let eleFocus = this.getFocusdElements(); |
426 | 430 | if (eleFocus.length < 2) return; |
427 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
428 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
431 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
432 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
433 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
434 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
429 | 435 | |
430 | 436 | // let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2; |
431 | 437 | // let y1 = parseInt(eleFocus[0].style.top) + parseInt(eleFocus[0].style.height) / 2; |
@@ -447,14 +453,16 @@ | ||
447 | 453 | |
448 | 454 | eleFocus[0].style.transform = 'rotateY(' + mirrorlr + 'deg) rotateX(' + mirrorud + 'deg) rotateZ(' + degree + 'deg)'; |
449 | 455 | } |
450 | - mouseUpRoll(evt) { | |
456 | + mouseUpRoll(evt, target, touchevt) { | |
451 | 457 | this.debuglog('mouseUpRoll'); |
452 | 458 | // Mouse event callback設定をクリア |
453 | - window.appArea.setMouseEventObj(null, null, null); | |
459 | + window.appArea.clearCallEventObj(); | |
454 | 460 | let eleFocus = this.getFocusdElements(); |
455 | 461 | if (eleFocus.length < 2) return; |
456 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
457 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
462 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
463 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
464 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
465 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
458 | 466 | |
459 | 467 | let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2; |
460 | 468 | let y1 = parseInt(eleFocus[0].style.top) + parseInt(eleFocus[0].style.height) / 2; |
@@ -490,22 +498,26 @@ | ||
490 | 498 | // Mouse eventをappAreaからRollerに渡してもらうように設定 |
491 | 499 | window.appArea.setSingleTouchEventObj(null, this.mouseMoveMirror.bind(this), this.mouseUpMirror.bind(this)); |
492 | 500 | } |
493 | - mouseMoveMirror(evt) { | |
501 | + mouseMoveMirror(evt, touchevt) { | |
494 | 502 | let eleFocus = this.getFocusdElements(); |
495 | 503 | if (eleFocus.length < 2) return; |
496 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
497 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
504 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
505 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
506 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
507 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
498 | 508 | |
499 | 509 | // 画像反転させるだけなのでmouse moveは処理しない |
500 | 510 | } |
501 | - mouseUpMirror(evt, target) { | |
511 | + mouseUpMirror(evt, target, touchevt) { | |
502 | 512 | this.debuglog('mouseUpMirror'); |
503 | 513 | // Mouse event callback設定をクリア |
504 | - window.appArea.setMouseEventObj(null, null, null); | |
514 | + window.appArea.clearCallEventObj(); | |
505 | 515 | let eleFocus = this.getFocusdElements(); |
506 | 516 | if (eleFocus.length < 2) return; |
507 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
508 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
517 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
518 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
519 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
520 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
509 | 521 | |
510 | 522 | let command = -1; |
511 | 523 | switch (evt.target.dataset.objid) { |
@@ -30,6 +30,9 @@ | ||
30 | 30 | this.DOMobject.addEventListener('touchmove', this.onTouchMove.bind(this), false); |
31 | 31 | this.DOMobject.addEventListener('touchstart', this.onTouchStart.bind(this), false); |
32 | 32 | this.DOMobject.addEventListener('touchend', this.onTouchEnd.bind(this), false); |
33 | + this.DOMobject.addEventListener('dragstart', prohibitDropHandler_dragStart.bind(this), false); | |
34 | + this.DOMobject.addEventListener('dragover', prohibitDropHandler_dragOver.bind(this), false); | |
35 | + this.DOMobject.addEventListener('drop', prohibitDropHandler_drop.bind(this), false); | |
33 | 36 | } |
34 | 37 | |
35 | 38 |
@@ -121,7 +124,7 @@ | ||
121 | 124 | // Callbackを上書きしてしまう場合はエラー出力し、ひとまず処理を継続 |
122 | 125 | if (null != touchMove || null != touchEnd) { |
123 | 126 | if (null != this.touchMoveFunc || null != this.touchEndFunc) { |
124 | - console.error('マウスイベント callback設定上書き \n\ | |
127 | + console.error('タッチイベント callback設定上書き \n\ | |
125 | 128 | Before strclass=' + this.strclass + 'callbackMove=' + (this.touchMoveFunc ? this.touchMoveFunc.name : 'null') + ', callbackUp=' + (this.touchEndFunc ? this.touchEndFunc.name : 'null') + '\n\ |
126 | 129 | After strclass=' + strclass + 'callbackMove=' + ((null != touchMove) ? touchMove.name : 'null') + ', callbackUp=' + ((null != touchEnd) ? touchEnd.name : 'null')); |
127 | 130 | } |
@@ -132,6 +135,15 @@ | ||
132 | 135 | this.touchEndFunc = touchEnd; |
133 | 136 | } |
134 | 137 | |
138 | + // 設定クリア | |
139 | + clearCallEventObj() { | |
140 | + this.debuglog('マウスとタッチ イベント転送設定クリア'); | |
141 | + this.strclass = null; | |
142 | + this.mouseMoveFunc = null; | |
143 | + this.mouseUpFunc = null; | |
144 | + this.touchMoveFunc = null; | |
145 | + this.touchEndFunc = null; | |
146 | + } | |
135 | 147 | // Event handler ------------------- |
136 | 148 | |
137 | 149 | // マウス左ボタン押下 (Drag処理) |
@@ -150,7 +162,7 @@ | ||
150 | 162 | } |
151 | 163 | onTouchMove(evt){ |
152 | 164 | if (null != this.touchMoveFunc) { |
153 | - this.touchMoveFunc(evt.touches[0]); | |
165 | + this.touchMoveFunc(evt.targetTouches[0], evt); | |
154 | 166 | } |
155 | 167 | } |
156 | 168 |
@@ -169,7 +181,7 @@ | ||
169 | 181 | } |
170 | 182 | onTouchEnd(evt){ |
171 | 183 | this.debuglog('タッチエンド onTouchEnd() findClass=' + this.strclass + ', callback move=' + (this.touchMoveFunc ? this.touchMoveFunc.name : 'null') + ', End=' + (this.touchEndFunc ? this.touchEndFunc.name : 'null')); |
172 | - let e = findClassNameParent(this.strclass, evt.touches[0].target); | |
184 | + let e = findClassNameParent(this.strclass, evt.changedTouches[0].target); | |
173 | 185 | if (null == e) { |
174 | 186 | console.error('入力完了処理 指定要素が見つからない findClass=' + this.strclass + ', callback move=' + (this.touchMoveFunc ? this.touchMoveFunc.name : 'null') + ', End=' + (this.touchEndFunc ? this.touchEndFunc.name : 'null')); |
175 | 187 | // ひとまず処理を継続する |
@@ -176,7 +188,7 @@ | ||
176 | 188 | } |
177 | 189 | |
178 | 190 | if (null != this.touchEndFunc) { |
179 | - this.touchEndFunc(evt.touches[0], e); | |
191 | + this.touchEndFunc(evt.changedTouches[0], e, evt); | |
180 | 192 | } |
181 | 193 | } |
182 | 194 |
@@ -225,7 +225,7 @@ | ||
225 | 225 | evt.preventDefault(); // 要素既定のdefault動作を止める |
226 | 226 | // Mouse eventをappAreaからCSSPalに渡してもらうように設定 (evt.targetは必ずpalette要素である前提。子要素なし。) |
227 | 227 | window.appArea.setSingleTouchEventObj(evt.target.dataset.objid, this.mouseMove.bind(this), this.mouseUp.bind(this)); |
228 | - this.startMovingElement(evt.touches[0]); | |
228 | + this.startMovingElement(evt.targetTouches[0]); | |
229 | 229 | } |
230 | 230 | startMovingElement(evt){ |
231 | 231 | // Drag対象を保持 |
@@ -237,10 +237,12 @@ | ||
237 | 237 | this.startDragX = evt.pageX; |
238 | 238 | this.startDragY = evt.pageY; |
239 | 239 | } |
240 | - mouseMove(evt) { | |
240 | + mouseMove(evt, touchevt) { | |
241 | 241 | if (null == this.draggingDOM) return; |
242 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
243 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
242 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
243 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
244 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
245 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
244 | 246 | |
245 | 247 | // 画像の仮移動 |
246 | 248 | this.endDragX = evt.pageX; |
@@ -263,10 +265,12 @@ | ||
263 | 265 | if (1.0 == this.draggingDOM.style.opacity) |
264 | 266 | this.draggingDOM.style.opacity = 0.4; |
265 | 267 | } |
266 | - mouseUp(evt) { | |
268 | + mouseUp(evt, target, touchevt) { | |
267 | 269 | if (null == this.draggingDOM) return; |
268 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
269 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
270 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
271 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
272 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
273 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
270 | 274 | this.endMovingElement(evt); |
271 | 275 | } |
272 | 276 | touchEnd(evt) { |
@@ -273,7 +277,7 @@ | ||
273 | 277 | if (null == this.draggingDOM) return; |
274 | 278 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
275 | 279 | evt.preventDefault(); // 要素既定のdefault動作を止める |
276 | - this.endMovingElement(evt.touches[0]); | |
280 | + this.endMovingElement(evt.changedTouches[0]); | |
277 | 281 | } |
278 | 282 | endMovingElement(evt){ |
279 | 283 | let palobjid = this.draggingDOM.dataset.objid; |
@@ -287,7 +291,7 @@ | ||
287 | 291 | // Drag中 element情報をクリア |
288 | 292 | this.draggingDOM = null; |
289 | 293 | // Mouse event callback設定をクリア |
290 | - window.appArea.setMouseEventObj(null, null, null); | |
294 | + window.appArea.clearCallEventObj(); | |
291 | 295 | |
292 | 296 | // マウス座標直下にある要素を検索 |
293 | 297 | // (evt.targetは自分を指してしまうため) |
@@ -339,15 +343,17 @@ | ||
339 | 343 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
340 | 344 | evt.preventDefault(); // 要素既定のdefault動作を止める |
341 | 345 | } |
342 | - mouseUpSetting(evt) { | |
343 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
344 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
346 | + mouseUpSetting(evt, touchevt) { | |
347 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
348 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
349 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
350 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
345 | 351 | this.executeSettingButton(evt); |
346 | 352 | } |
347 | 353 | touchEndSetting(evt){ |
348 | 354 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
349 | 355 | evt.preventDefault(); // 要素既定のdefault動作を止める |
350 | - this.executeSettingButton(evt.touches[0]); | |
356 | + this.executeSettingButton(evt.changedTouches[0]); | |
351 | 357 | } |
352 | 358 | executeSettingButton(evt){ |
353 | 359 | switch (evt.target.dataset.objid) { |
@@ -30,6 +30,9 @@ | ||
30 | 30 | this.DOMobject[cnt].addEventListener('mouseup', this.mouseUp.bind(this), false); |
31 | 31 | this.DOMobject[cnt].addEventListener('touchstart', this.onTouchStart.bind(this), false); |
32 | 32 | this.DOMobject[cnt].addEventListener('touchend', this.touchEnd.bind(this), false); |
33 | + this.DOMobject[cnt].addEventListener('dragstart', prohibitDropHandler_dragStart.bind(this), false); | |
34 | + this.DOMobject[cnt].addEventListener('dragover', prohibitDropHandler_dragOver.bind(this), false); | |
35 | + this.DOMobject[cnt].addEventListener('drop', prohibitDropHandler_drop.bind(this), false); | |
33 | 36 | } |
34 | 37 | } |
35 | 38 |
@@ -55,8 +58,8 @@ | ||
55 | 58 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
56 | 59 | evt.preventDefault(); // 要素既定のdefault動作を止める |
57 | 60 | // Mouse eventをappAreaからCSSPalに渡してもらうように設定 |
58 | - window.appArea.setMouseEventObj('palgroup', this.touchMove.bind(this), null); | |
59 | - this.startMovingPalette(evt.touches[0].target, evt.touches[0].pageX, evt.touches[0].pageY); | |
61 | + window.appArea.setSingleTouchEventObj('palgroup', this.mouseMove.bind(this), null); | |
62 | + this.startMovingPalette(evt.targetTouches[0].target, evt.targetTouches[0].pageX, evt.targetTouches[0].pageY); | |
60 | 63 | } |
61 | 64 | startMovingPalette(eletarget, x, y){ |
62 | 65 |
@@ -75,22 +78,16 @@ | ||
75 | 78 | this.startDragX = x; |
76 | 79 | this.startDragY = y; |
77 | 80 | } |
78 | - mouseMove(evt) { | |
81 | + mouseMove(evt, touchevt) { | |
79 | 82 | if (null == this.draggingDOM) return; |
80 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
81 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
82 | - this.movingPalette(evt.target, evt.pageX, evt.pageY); | |
83 | - } | |
84 | - touchMove(evt) { | |
85 | - if (null == this.draggingDOM) return; | |
86 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
87 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
88 | - this.movingPalette(evt.touches[0].target, evt.touches[0].pageX, evt.touches[0].pageY); | |
89 | - } | |
90 | - movingPalette(eletarget, x, y) { | |
83 | + if (evt.stopPropagation ) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
84 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
85 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
86 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
87 | + | |
91 | 88 | // 画像の仮移動 |
92 | - this.endDragX = x; | |
93 | - this.endDragY = y; | |
89 | + this.endDragX = evt.pageX; | |
90 | + this.endDragY = evt.pageY; | |
94 | 91 | // 移動量取得 |
95 | 92 | let moveX = this.endDragX - this.startDragX; |
96 | 93 | let moveY = this.endDragY - this.startDragY; |
@@ -113,7 +110,7 @@ | ||
113 | 110 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
114 | 111 | evt.preventDefault(); // 要素既定のdefault動作を止める |
115 | 112 | // Mouse event callback設定をクリア |
116 | - window.appArea.setMouseEventObj(null, null, null); | |
113 | + window.appArea.clearCallEventObj(); | |
117 | 114 | this.endMovingPalette(); |
118 | 115 | } |
119 | 116 | touchEnd(evt) { |
@@ -121,7 +118,7 @@ | ||
121 | 118 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
122 | 119 | evt.preventDefault(); // 要素既定のdefault動作を止める |
123 | 120 | // Mouse event callback設定をクリア |
124 | - window.appArea.setMouseEventObj(null, null, null); | |
121 | + window.appArea.clearCallEventObj(); | |
125 | 122 | this.endMovingPalette(); |
126 | 123 | } |
127 | 124 | endMovingPalette(){ |
@@ -218,6 +218,7 @@ | ||
218 | 218 | </div> <!-- apparea --> |
219 | 219 | |
220 | 220 | <script type="text/javascript" src="js/numeric-1.2.6.min.js"></script> |
221 | + <script type="text/javascript" src="js/settings.js"></script> | |
221 | 222 | <script type="text/javascript" src="js/Common.js"></script> |
222 | 223 | <script type="text/javascript" src="js/Queue.js"></script> |
223 | 224 | <script type="text/javascript" src="js/CommandObj.js"></script> |
@@ -326,7 +326,7 @@ | ||
326 | 326 | window.appArea.setSingleTouchEventObj('DispBase',this.mouseMove.bind(this), this.mouseUp.bind(this)); |
327 | 327 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
328 | 328 | evt.preventDefault(); // 要素既定のdefault動作を止める |
329 | - this.startMovingElement(evt.touches[0]); | |
329 | + this.startMovingElement(evt.targetTouches[0]); | |
330 | 330 | } |
331 | 331 | startMovingElement(evt){ |
332 | 332 | /* test |
@@ -354,9 +354,11 @@ | ||
354 | 354 | window.partsFocus.setClingingPartner(this.DOMbase); |
355 | 355 | |
356 | 356 | } |
357 | - mouseMove(evt, xy) { | |
358 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
359 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
357 | + mouseMove(evt, touchevt) { | |
358 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
359 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
360 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
361 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
360 | 362 | |
361 | 363 | /* test |
362 | 364 | let matp = matPerspective(1); |
@@ -388,12 +390,14 @@ | ||
388 | 390 | this.DOMbase.style.top = y + "px"; |
389 | 391 | this.DOMobject.style.opacity = 0.4; |
390 | 392 | } |
391 | - mouseUp(evt, target) { | |
393 | + mouseUp(evt, target, touchevt) { | |
392 | 394 | this.debuglog("mouseUp"); |
393 | 395 | // Mouse event処理対象をクリア |
394 | - window.appArea.setMouseEventObj(null, null, null); | |
395 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
396 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
396 | + window.appArea.clearCallEventObj(); | |
397 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
398 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
399 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
400 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
397 | 401 | |
398 | 402 | |
399 | 403 | // 移動元として座標を保持 |
@@ -197,7 +197,7 @@ | ||
197 | 197 | evt.preventDefault(); // 要素既定のdefault動作を止める |
198 | 198 | // Mouse eventをappAreaからScalerに渡してもらうように設定 |
199 | 199 | window.appArea.setSingleTouchEventObj(null, this.mouseMoveScale.bind(this), this.mouseUpScale.bind(this)); |
200 | - this.startScaling(evt.touches[0]); | |
200 | + this.startScaling(evt.targetTouches[0]); | |
201 | 201 | } |
202 | 202 | startScaling(evt){ |
203 | 203 | let eleFocus = this.getFocusdElements(); |
@@ -219,11 +219,13 @@ | ||
219 | 219 | this.startDragX = tmp2[0]; |
220 | 220 | this.startDragY = tmp1[1]; |
221 | 221 | } |
222 | - mouseMoveScale(evt) { | |
222 | + mouseMoveScale(evt, touchevt) { | |
223 | 223 | let eleFocus = this.getFocusdElements(); |
224 | 224 | if (eleFocus.length < 2) return; |
225 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
226 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
225 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
226 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
227 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
228 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
227 | 229 | |
228 | 230 | // 画像を反転している場合、マウス入力座標も反転させる |
229 | 231 | // let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2; |
@@ -338,15 +340,17 @@ | ||
338 | 340 | eleFocus[1].style.fontSize = scalefont + '%'; |
339 | 341 | } |
340 | 342 | |
341 | - mouseUpScale(evt) { | |
343 | + mouseUpScale(evt, target, touchevt) { | |
342 | 344 | this.debuglog('mouseUpScale'); |
343 | 345 | // Mouse event callback設定をクリア |
344 | - window.appArea.setMouseEventObj(null, null, null); | |
346 | + window.appArea.clearCallEventObj(); | |
345 | 347 | |
346 | 348 | let eleFocus = this.getFocusdElements(); |
347 | 349 | if (eleFocus.length < 2) return; |
348 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
349 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
350 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
351 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
352 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
353 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
350 | 354 | |
351 | 355 | let tmp3 = rotateZ(this.x1, this.y1, eleFocus[0].dataset.degree, evt.pageX, evt.pageY); |
352 | 356 | let tmp1 = rotateUD(this.y1, this.degUD, tmp3[0], tmp3[1]); |
@@ -411,7 +415,7 @@ | ||
411 | 415 | evt.preventDefault(); // 要素既定のdefault動作を止める |
412 | 416 | // Mouse eventをappAreaからRollerに渡してもらうように設定 |
413 | 417 | window.appArea.setSingleTouchEventObj(null, this.mouseMoveRoll.bind(this), this.mouseUpRoll.bind(this)); |
414 | - this.startRolling(evt.touches[0]); | |
418 | + this.startRolling(evt.targetTouches[0]); | |
415 | 419 | } |
416 | 420 | startRolling(evt){ |
417 | 421 | let eleFocus = this.getFocusdElements(); |
@@ -421,11 +425,13 @@ | ||
421 | 425 | this.degUD = parseInt(eleFocus[0].dataset.mirrorud); |
422 | 426 | this.degLR = parseInt(eleFocus[0].dataset.mirrorlr); |
423 | 427 | } |
424 | - mouseMoveRoll(evt) { | |
428 | + mouseMoveRoll(evt, touchevt) { | |
425 | 429 | let eleFocus = this.getFocusdElements(); |
426 | 430 | if (eleFocus.length < 2) return; |
427 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
428 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
431 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
432 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
433 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
434 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
429 | 435 | |
430 | 436 | // let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2; |
431 | 437 | // let y1 = parseInt(eleFocus[0].style.top) + parseInt(eleFocus[0].style.height) / 2; |
@@ -447,14 +453,16 @@ | ||
447 | 453 | |
448 | 454 | eleFocus[0].style.transform = 'rotateY(' + mirrorlr + 'deg) rotateX(' + mirrorud + 'deg) rotateZ(' + degree + 'deg)'; |
449 | 455 | } |
450 | - mouseUpRoll(evt) { | |
456 | + mouseUpRoll(evt, target, touchevt) { | |
451 | 457 | this.debuglog('mouseUpRoll'); |
452 | 458 | // Mouse event callback設定をクリア |
453 | - window.appArea.setMouseEventObj(null, null, null); | |
459 | + window.appArea.clearCallEventObj(); | |
454 | 460 | let eleFocus = this.getFocusdElements(); |
455 | 461 | if (eleFocus.length < 2) return; |
456 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
457 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
462 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
463 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
464 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
465 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
458 | 466 | |
459 | 467 | let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2; |
460 | 468 | let y1 = parseInt(eleFocus[0].style.top) + parseInt(eleFocus[0].style.height) / 2; |
@@ -490,22 +498,26 @@ | ||
490 | 498 | // Mouse eventをappAreaからRollerに渡してもらうように設定 |
491 | 499 | window.appArea.setSingleTouchEventObj(null, this.mouseMoveMirror.bind(this), this.mouseUpMirror.bind(this)); |
492 | 500 | } |
493 | - mouseMoveMirror(evt) { | |
501 | + mouseMoveMirror(evt, touchevt) { | |
494 | 502 | let eleFocus = this.getFocusdElements(); |
495 | 503 | if (eleFocus.length < 2) return; |
496 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
497 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
504 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
505 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
506 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
507 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
498 | 508 | |
499 | 509 | // 画像反転させるだけなのでmouse moveは処理しない |
500 | 510 | } |
501 | - mouseUpMirror(evt, target) { | |
511 | + mouseUpMirror(evt, target, touchevt) { | |
502 | 512 | this.debuglog('mouseUpMirror'); |
503 | 513 | // Mouse event callback設定をクリア |
504 | - window.appArea.setMouseEventObj(null, null, null); | |
514 | + window.appArea.clearCallEventObj(); | |
505 | 515 | let eleFocus = this.getFocusdElements(); |
506 | 516 | if (eleFocus.length < 2) return; |
507 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
508 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
517 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
518 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
519 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
520 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
509 | 521 | |
510 | 522 | let command = -1; |
511 | 523 | switch (evt.target.dataset.objid) { |
@@ -30,6 +30,9 @@ | ||
30 | 30 | this.DOMobject.addEventListener('touchmove', this.onTouchMove.bind(this), false); |
31 | 31 | this.DOMobject.addEventListener('touchstart', this.onTouchStart.bind(this), false); |
32 | 32 | this.DOMobject.addEventListener('touchend', this.onTouchEnd.bind(this), false); |
33 | + this.DOMobject.addEventListener('dragstart', prohibitDropHandler_dragStart.bind(this), false); | |
34 | + this.DOMobject.addEventListener('dragover', prohibitDropHandler_dragOver.bind(this), false); | |
35 | + this.DOMobject.addEventListener('drop', prohibitDropHandler_drop.bind(this), false); | |
33 | 36 | } |
34 | 37 | |
35 | 38 |
@@ -121,7 +124,7 @@ | ||
121 | 124 | // Callbackを上書きしてしまう場合はエラー出力し、ひとまず処理を継続 |
122 | 125 | if (null != touchMove || null != touchEnd) { |
123 | 126 | if (null != this.touchMoveFunc || null != this.touchEndFunc) { |
124 | - console.error('マウスイベント callback設定上書き \n\ | |
127 | + console.error('タッチイベント callback設定上書き \n\ | |
125 | 128 | Before strclass=' + this.strclass + 'callbackMove=' + (this.touchMoveFunc ? this.touchMoveFunc.name : 'null') + ', callbackUp=' + (this.touchEndFunc ? this.touchEndFunc.name : 'null') + '\n\ |
126 | 129 | After strclass=' + strclass + 'callbackMove=' + ((null != touchMove) ? touchMove.name : 'null') + ', callbackUp=' + ((null != touchEnd) ? touchEnd.name : 'null')); |
127 | 130 | } |
@@ -132,6 +135,15 @@ | ||
132 | 135 | this.touchEndFunc = touchEnd; |
133 | 136 | } |
134 | 137 | |
138 | + // 設定クリア | |
139 | + clearCallEventObj() { | |
140 | + this.debuglog('マウスとタッチ イベント転送設定クリア'); | |
141 | + this.strclass = null; | |
142 | + this.mouseMoveFunc = null; | |
143 | + this.mouseUpFunc = null; | |
144 | + this.touchMoveFunc = null; | |
145 | + this.touchEndFunc = null; | |
146 | + } | |
135 | 147 | // Event handler ------------------- |
136 | 148 | |
137 | 149 | // マウス左ボタン押下 (Drag処理) |
@@ -150,7 +162,7 @@ | ||
150 | 162 | } |
151 | 163 | onTouchMove(evt){ |
152 | 164 | if (null != this.touchMoveFunc) { |
153 | - this.touchMoveFunc(evt.touches[0]); | |
165 | + this.touchMoveFunc(evt.targetTouches[0], evt); | |
154 | 166 | } |
155 | 167 | } |
156 | 168 |
@@ -169,7 +181,7 @@ | ||
169 | 181 | } |
170 | 182 | onTouchEnd(evt){ |
171 | 183 | this.debuglog('タッチエンド onTouchEnd() findClass=' + this.strclass + ', callback move=' + (this.touchMoveFunc ? this.touchMoveFunc.name : 'null') + ', End=' + (this.touchEndFunc ? this.touchEndFunc.name : 'null')); |
172 | - let e = findClassNameParent(this.strclass, evt.touches[0].target); | |
184 | + let e = findClassNameParent(this.strclass, evt.changedTouches[0].target); | |
173 | 185 | if (null == e) { |
174 | 186 | console.error('入力完了処理 指定要素が見つからない findClass=' + this.strclass + ', callback move=' + (this.touchMoveFunc ? this.touchMoveFunc.name : 'null') + ', End=' + (this.touchEndFunc ? this.touchEndFunc.name : 'null')); |
175 | 187 | // ひとまず処理を継続する |
@@ -176,7 +188,7 @@ | ||
176 | 188 | } |
177 | 189 | |
178 | 190 | if (null != this.touchEndFunc) { |
179 | - this.touchEndFunc(evt.touches[0], e); | |
191 | + this.touchEndFunc(evt.changedTouches[0], e, evt); | |
180 | 192 | } |
181 | 193 | } |
182 | 194 |
@@ -225,7 +225,7 @@ | ||
225 | 225 | evt.preventDefault(); // 要素既定のdefault動作を止める |
226 | 226 | // Mouse eventをappAreaからCSSPalに渡してもらうように設定 (evt.targetは必ずpalette要素である前提。子要素なし。) |
227 | 227 | window.appArea.setSingleTouchEventObj(evt.target.dataset.objid, this.mouseMove.bind(this), this.mouseUp.bind(this)); |
228 | - this.startMovingElement(evt.touches[0]); | |
228 | + this.startMovingElement(evt.targetTouches[0]); | |
229 | 229 | } |
230 | 230 | startMovingElement(evt){ |
231 | 231 | // Drag対象を保持 |
@@ -237,10 +237,12 @@ | ||
237 | 237 | this.startDragX = evt.pageX; |
238 | 238 | this.startDragY = evt.pageY; |
239 | 239 | } |
240 | - mouseMove(evt) { | |
240 | + mouseMove(evt, touchevt) { | |
241 | 241 | if (null == this.draggingDOM) return; |
242 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
243 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
242 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
243 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
244 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
245 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
244 | 246 | |
245 | 247 | // 画像の仮移動 |
246 | 248 | this.endDragX = evt.pageX; |
@@ -263,10 +265,12 @@ | ||
263 | 265 | if (1.0 == this.draggingDOM.style.opacity) |
264 | 266 | this.draggingDOM.style.opacity = 0.4; |
265 | 267 | } |
266 | - mouseUp(evt) { | |
268 | + mouseUp(evt, target, touchevt) { | |
267 | 269 | if (null == this.draggingDOM) return; |
268 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
269 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
270 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
271 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
272 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
273 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
270 | 274 | this.endMovingElement(evt); |
271 | 275 | } |
272 | 276 | touchEnd(evt) { |
@@ -273,7 +277,7 @@ | ||
273 | 277 | if (null == this.draggingDOM) return; |
274 | 278 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
275 | 279 | evt.preventDefault(); // 要素既定のdefault動作を止める |
276 | - this.endMovingElement(evt.touches[0]); | |
280 | + this.endMovingElement(evt.changedTouches[0]); | |
277 | 281 | } |
278 | 282 | endMovingElement(evt){ |
279 | 283 | let palobjid = this.draggingDOM.dataset.objid; |
@@ -287,7 +291,7 @@ | ||
287 | 291 | // Drag中 element情報をクリア |
288 | 292 | this.draggingDOM = null; |
289 | 293 | // Mouse event callback設定をクリア |
290 | - window.appArea.setMouseEventObj(null, null, null); | |
294 | + window.appArea.clearCallEventObj(); | |
291 | 295 | |
292 | 296 | // マウス座標直下にある要素を検索 |
293 | 297 | // (evt.targetは自分を指してしまうため) |
@@ -339,15 +343,17 @@ | ||
339 | 343 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
340 | 344 | evt.preventDefault(); // 要素既定のdefault動作を止める |
341 | 345 | } |
342 | - mouseUpSetting(evt) { | |
343 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
344 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
346 | + mouseUpSetting(evt, touchevt) { | |
347 | + if (evt.stopPropagation) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
348 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
349 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
350 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
345 | 351 | this.executeSettingButton(evt); |
346 | 352 | } |
347 | 353 | touchEndSetting(evt){ |
348 | 354 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
349 | 355 | evt.preventDefault(); // 要素既定のdefault動作を止める |
350 | - this.executeSettingButton(evt.touches[0]); | |
356 | + this.executeSettingButton(evt.changedTouches[0]); | |
351 | 357 | } |
352 | 358 | executeSettingButton(evt){ |
353 | 359 | switch (evt.target.dataset.objid) { |
@@ -30,6 +30,9 @@ | ||
30 | 30 | this.DOMobject[cnt].addEventListener('mouseup', this.mouseUp.bind(this), false); |
31 | 31 | this.DOMobject[cnt].addEventListener('touchstart', this.onTouchStart.bind(this), false); |
32 | 32 | this.DOMobject[cnt].addEventListener('touchend', this.touchEnd.bind(this), false); |
33 | + this.DOMobject[cnt].addEventListener('dragstart', prohibitDropHandler_dragStart.bind(this), false); | |
34 | + this.DOMobject[cnt].addEventListener('dragover', prohibitDropHandler_dragOver.bind(this), false); | |
35 | + this.DOMobject[cnt].addEventListener('drop', prohibitDropHandler_drop.bind(this), false); | |
33 | 36 | } |
34 | 37 | } |
35 | 38 |
@@ -55,8 +58,8 @@ | ||
55 | 58 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
56 | 59 | evt.preventDefault(); // 要素既定のdefault動作を止める |
57 | 60 | // Mouse eventをappAreaからCSSPalに渡してもらうように設定 |
58 | - window.appArea.setMouseEventObj('palgroup', this.touchMove.bind(this), null); | |
59 | - this.startMovingPalette(evt.touches[0].target, evt.touches[0].pageX, evt.touches[0].pageY); | |
61 | + window.appArea.setSingleTouchEventObj('palgroup', this.mouseMove.bind(this), null); | |
62 | + this.startMovingPalette(evt.targetTouches[0].target, evt.targetTouches[0].pageX, evt.targetTouches[0].pageY); | |
60 | 63 | } |
61 | 64 | startMovingPalette(eletarget, x, y){ |
62 | 65 |
@@ -75,22 +78,16 @@ | ||
75 | 78 | this.startDragX = x; |
76 | 79 | this.startDragY = y; |
77 | 80 | } |
78 | - mouseMove(evt) { | |
81 | + mouseMove(evt, touchevt) { | |
79 | 82 | if (null == this.draggingDOM) return; |
80 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
81 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
82 | - this.movingPalette(evt.target, evt.pageX, evt.pageY); | |
83 | - } | |
84 | - touchMove(evt) { | |
85 | - if (null == this.draggingDOM) return; | |
86 | - evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
87 | - evt.preventDefault(); // 要素既定のdefault動作を止める | |
88 | - this.movingPalette(evt.touches[0].target, evt.touches[0].pageX, evt.touches[0].pageY); | |
89 | - } | |
90 | - movingPalette(eletarget, x, y) { | |
83 | + if (evt.stopPropagation ) evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) | |
84 | + if (evt.preventDefault) evt.preventDefault(); // 要素既定のdefault動作を止める | |
85 | + if (touchevt && touchevt.stopPropagation) touchevt.stopPropagation(); | |
86 | + if (touchevt && touchevt.preventDefault) touchevt.preventDefault(); | |
87 | + | |
91 | 88 | // 画像の仮移動 |
92 | - this.endDragX = x; | |
93 | - this.endDragY = y; | |
89 | + this.endDragX = evt.pageX; | |
90 | + this.endDragY = evt.pageY; | |
94 | 91 | // 移動量取得 |
95 | 92 | let moveX = this.endDragX - this.startDragX; |
96 | 93 | let moveY = this.endDragY - this.startDragY; |
@@ -113,7 +110,7 @@ | ||
113 | 110 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
114 | 111 | evt.preventDefault(); // 要素既定のdefault動作を止める |
115 | 112 | // Mouse event callback設定をクリア |
116 | - window.appArea.setMouseEventObj(null, null, null); | |
113 | + window.appArea.clearCallEventObj(); | |
117 | 114 | this.endMovingPalette(); |
118 | 115 | } |
119 | 116 | touchEnd(evt) { |
@@ -121,7 +118,7 @@ | ||
121 | 118 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
122 | 119 | evt.preventDefault(); // 要素既定のdefault動作を止める |
123 | 120 | // Mouse event callback設定をクリア |
124 | - window.appArea.setMouseEventObj(null, null, null); | |
121 | + window.appArea.clearCallEventObj(); | |
125 | 122 | this.endMovingPalette(); |
126 | 123 | } |
127 | 124 | endMovingPalette(){ |