Skip to content

DomEvent

@namespace DomEvent Utility functions to work with the DOM events, used by Leaflet internally.

Methods

MethodReturnsDescription
on(el: HTMLElement, types: String, fn: Function, context?: Object)thisAdds a listener function (fn) to a particular DOM event type of the
on(el: HTMLElement, eventMap: Object, context?: Object)thisAdds a set of type/listener pairs, e.g. {click: onClick, pointermove: onPointerMove}
off(el: HTMLElement, types: String, fn: Function, context?: Object)thisRemoves a previously added listener function.
off(el: HTMLElement, eventMap: Object, context?: Object)thisRemoves a set of type/listener pairs, e.g. {click: onClick, pointermove: onPointerMove}
off(el: HTMLElement, types: String)thisRemoves all previously added listeners of given types.
off(el: HTMLElement)thisRemoves all previously added listeners from given HTMLElement
stopPropagation(ev: DOMEvent)thisStop the given event from propagation to parent elements. Used inside the listener functions:
disableScrollPropagation(el: HTMLElement)thisAdds stopPropagation to the element's 'wheel' events (plus browser variants).
disableClickPropagation(el: HTMLElement)thisAdds stopPropagation to the element's 'click', 'dblclick', 'contextmenu'
preventDefault(ev: DOMEvent)thisPrevents the default action of the DOM Event ev from happening (such as
stop(ev: DOMEvent)thisDoes stopPropagation and preventDefault at the same time.
getPropagationPath(ev: DOMEvent)ArrayReturns an array containing the HTMLElements that the given DOM event
getPointerPosition(ev: DOMEvent, container?: HTMLElement)PointGets normalized pointer position from a DOM event relative to the
getWheelPxFactor()NumberGets the wheel pixel factor based on the devicePixelRatio
getWheelDelta(ev: DOMEvent)NumberGets normalized wheel delta from a wheel DOM event, in vertical