js_fake_touch
Posted Dai Hanlong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js_fake_touch相关的知识,希望对你有一定的参考价值。
let ele = document.getElementById('GameCanvas');
let rect = ele.getBoundingClientRect();
let touch = new Touch({
"identifier" : 0,
"target" : ele,
"clientX" : (rect.left + rect.right)/2,
"clientY" : (rect.top + rect.bottom)/2,
"screenX" : (rect.left + rect.right)/2,
"screenY" : (rect.top + rect.bottom)/2,
"pageX" : (rect.left + rect.right)/2,
"pageY" : (rect.top + rect.bottom)/2,
"radiusX" : 11.5,
"radiusY" : 11.5,
"rotationAngle" : 0.0,
"force" : 1});
let touchstart = new TouchEvent("touchstart", {
cancelable: true,
bubbles: true,
composed: true,
touches: [touch],
targetTouches: [touch],
changedTouches: [touch]
});
let touchend = new TouchEvent("touchend", {
cancelable: true,
bubbles: true,
composed: true,
touches: [touch],
targetTouches: [touch],
changedTouches: [touch]
});
ele.dispatchEvent(touchstart);
ele.dispatchEvent(touchend);
以上是关于js_fake_touch的主要内容,如果未能解决你的问题,请参考以下文章