Is there a way to manually trigger the touch event in TypeScript? In JavaScript, it was possible but I am struggling to achieve the same in TypeScript.
For example:
let touchStart: TouchEvent = document.createEvent('TouchEvent');
touchStart.initEvent('touchstart', true, true);
element.dispatchEvent(touchStart);
While I can trigger the touchStart event, I am unable to retrieve values for changedTouches[0].pageX
and changedTouches[0].pageY
.
I have attempted solutions suggested in this link, such as:
touchStart.changedTouches = [
pageX: x
pageY: y
]
However, assigning values to changedTouches
fails due to its readonly property. How can I work around this issue and successfully utilize changedTouches
in TypeScript?