Sorry to comment here, but I was having difficulty with this too. I didnt want to make a new question, as my code is identical, but my problem is related to after having done a long click and moving the mouse around and then stopping moving, but maintaining the click, the code in the timer for mousedown
is no longer being called, or rather they don't start again when the mousemove
part stops:
let isMouseDown = false;
let intervalId = null;
canvas.addEventListener('mousedown', (event) => {
if (!isMouseDown) {
isMouseDown = true;
handleMouseClick(event);
intervalId = setInterval(() => {
handleMouseClick(event);
}, 30);
}
});
canvas.addEventListener('mouseup', () => {
isMouseDown = false;
clearInterval(intervalId);
});
canvas.addEventListener('mousemove', (event) => {
if (isMouseDown) {
handleMouseClick(event);
clearInterval(intervalId);
}
});
So can someone help me with this scenario, to reiterate, click and hold, move mouse, stop moving mouse, mousedown
calls cease. I consider this to be valuable to the question that was asked and so I maintain the validity of the comment.