[問題] 手動touchevent

看板Ajax作者 (不痛)時間5年前 (2018/10/11 18:59), 編輯推噓0(002)
留言2則, 1人參與, 5年前最新討論串1/1
各位前輩好,我設備的訊號是TUIO,不是手機的觸控,所以我需要自己產生touchevent 我輸入兩個點,但touchlist只會有一個點,移動還行,縮放就不行了, 請問要怎麼把觸控點加進去呢? https://jsbin.com/zaxogifino/1/edit?js,console,output myElement = document.querySelector('#g2'); sendTouchEvent(247, 379, myElement, 'touchstart'); sendTouchEvent(317, 591, myElement, 'touchstart'); sendTouchEvent(257, 389, myElement, 'touchmove'); sendTouchEvent(307, 581, myElement, 'touchmove'); sendTouchEvent(267, 399, myElement, 'touchmove'); sendTouchEvent(297, 571, myElement, 'touchmove'); 以上縮放無效 function sendTouchEvent(x, y, element, eventType) { const touchObj = new Touch({ identifier: Date.now(), target: element, clientX: x, clientY: y, pageX: x, pageY: y, screenX: x, screenY: y, radiusX: 25, radiusY: 25, rotationAngle: 0, force: 0.5, }); const touchEvent = new TouchEvent(eventType, { cancelable: true, bubbles: true, touches: [touchObj], targetTouches: [], changedTouches: [touchObj], shiftKey: true, }); element.dispatchEvent(touchEvent); } -- jQuery做事,開口不談$後面啥都別想動。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.26.232.79 ※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1539255576.A.480.html

10/12 03:07, 5年前 , 1F
10/12 03:07, 1F

10/12 03:07, 5年前 , 2F
ent用的,參考一下+用手機拉拉看,就大概知道要怎麼寫了
10/12 03:07, 2F
文章代碼(AID): #1RloqOI0 (Ajax)