DomEvent
Utility functions to work with the DOM events, used by Leaflet internally.
Functions
Function | Returns | Description |
---|---|---|
on( |
this |
Adds a listener function (fn ) to a particular DOM event type of the
element el . You can optionally specify the context of the listener
(object the this keyword will point to). You can also pass several
space-separated types (e.g. 'click dblclick' ). |
on( |
this |
Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} |
off( |
this |
Removes a previously added listener function. If no function is specified,
it will remove all the listeners of that particular DOM event from the element.
Note that if you passed a custom context to on, you must pass the same
context to off in order to remove the listener. |
off( |
this |
Removes a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} |
stopPropagation( |
this |
Stop the given event from propagation to parent elements. Used inside the listener functions:
|
disableScrollPropagation( |
this |
Adds stopPropagation to the element's 'mousewheel' events (plus browser variants). |
disableClickPropagation( |
this |
Adds stopPropagation to the element's 'click' , 'doubleclick' ,
'mousedown' and 'touchstart' events (plus browser variants). |
preventDefault( |
this |
Prevents the default action of the DOM Event ev from happening (such as
following a link in the href of the a element, or doing a POST request
with page reload when a <form> is submitted).
Use it inside listener functions. |
stop(ev) |
this |
Does stopPropagation and preventDefault at the same time. |
getMousePosition( |
Point |
Gets normalized mouse position from a DOM event relative to the
container or to the whole page if not specified. |
getWheelDelta( |
Number |
Gets normalized wheel delta from a mousewheel DOM event, in vertical pixels scrolled (negative if scrolling down). Events from pointing devices without precise scrolling are mapped to a best guess of 60 pixels. |
addListener(…) |
this |
Alias to L.DomEvent.on |
removeListener(…) |
this |
Alias to L.DomEvent.off |