How to describe the event that occurs when the mouse with the left button held down enters the element and there (above the element) the button is released?

    1 answer 1

    I suppose that you want to implement drag and drop? If yes, then I would advise this: as soon as an element is dragged, write a value (object or boolean value) to a global variable. Then it will be necessary to track only onmouseup, where to check the value of the variable and if there is something there, then it is dragging.

    Otherwise, I think I will have to hang up the event handlers for three events: onmousedown — write to a variable that we clicked inside the object and ignore all subsequent events (ie, we didn’t come from the outside with the button pressed, but already here we did it) button (although this method can be skipped). It is needed to understand whether it was dragged over an element or just hung (use the last coordinates above the element). onmouseup - if our button and the variable processed by the method or not processed by the mousedown method are empty, then we were dragged and released.