How does JS stop click events in mouseover

A BUTTON performs two actions, one is a move, the other is a click, and then the move is done with the mouseup+mousemove+mousedown event, and the click is click. But the click event is still triggered when I move it. The biggest difference between mobile and click is whether the mousemove event is executed, so I think I can stop the click event in the mousemove event. I don"t know if there is any way

Mar.30,2022

you can put a flag variable in the mousemove event to determine whether the variable is true in the click event, and if so, directly return


has been written for you, codepen example

the idea is that if the button is moving, the click event is prevent default, and if the button stops moving, it is clicked normally. Whether or not to stop moving is judged by a timer, and if the last mobile event passes through the 300ms and no longer triggers the mousemove event, it is judged to stop moving.


just answer from your title, isn't there a type in the e of the event method? According to type, then stoppropagation will be fine

.
Menu