purescriptmouse-listeners

Difference Between MouseEvents


I am new to Purescript. I am working with MouseEvents from "import DOM.HTML.Event.EventTypes" and I couldn't understand the difference between Mouseup, Mousedown,Mouseout and Mouseleave. I searched for documentation but couldn't find an explanation for it. I would like to know when each of it is getting triggered.


Solution

  • MouseDown occurs when a mouse button is pressed, MouseUp when the button is released. MouseLeave occurs when the mouse pointer leaves the element associated with the listener.

    You can see documentation for a list of Web events here: https://developer.mozilla.org/en-US/docs/Web/Events

    As noted at https://developer.mozilla.org/en-US/docs/Web/Events/mouseleave:

    mouseleave and mouseout are similar but differ in that mouseleave does not bubble and mouseout does. This means that mouseleave is fired when the pointer has exited the element and all of its descendants, whereas mouseout is fired when the pointer leaves the element or leaves one of the element's descendants (even if the pointer is still within the element).

    There is also the click event that is usually the easiest to use.