Looking to create a mobile interactivity where users can move an image by touching the screen, similar to a web cursor. Currently using this code:
document.addEventListener('touchmove', this.onMouseMove);
document.addEventListener('touchStart', this.onMouseMove);
document.addEventListener('touchEnd', this.onMouseMove);
In addition to:
onMouseMove = (e) => {
const img = document.getElementById('drawing-mouse-pointer');
img.style.left = `${e.touches[0].clientX}px`;
img.style.top = `${e.touches[0].clientY }px`;
console.log(e.touches[0] && e.touches[0].clientY);
}
The issue is that currently the image only moves once when clicked and then stops. How can I ensure the image continuously moves with touch?