79227552

Date: 2024-11-26 16:36:25
Score: 4.5
Natty:
Report link

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.

Reasons:
  • Blacklisted phrase (1): help me
  • Blacklisted phrase (1): to comment
  • RegEx Blacklisted phrase (3): can someone help me
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Leigh Hobson