Class DomEvent

Index

Methods

Methods

public static addListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent

Adds a listener fn to the element's DOM event of the specified type. this keyword inside the listener will point to context, or to the element if not specified.

Parameters

  • el: HTMLElement
  • type: string
  • fn: (e: Event) => void
  • context?: any optional

Returns

DomEvent

public static disableClickPropagation(el: HTMLElement): DomEvent

Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' and 'touchstart' events.

Parameters

  • el: HTMLElement

Returns

DomEvent

public static getMousePosition(e: Event, container?: HTMLElement): Point

Gets normalized mouse position from a DOM event relative to the container or to the whole page if not specified.

Parameters

  • e: Event
  • container?: HTMLElement optional

Returns

Point

public static getWheelDelta(e: Event): number

Gets normalized wheel delta from a mousewheel DOM event.

Parameters

  • e: Event

Returns

number

public static preventDefault(e: Event): DomEvent

Prevents the default action of the event from happening (such as following a link in the href of the a element, or doing a POST request with page reload when form is submitted). Use it inside listener functions.

Parameters

  • e: Event

Returns

DomEvent

public static removeListener(el: HTMLElement, type: string, fn: (e: Event) => void): DomEvent

Removes an event listener from the element.

Parameters

  • el: HTMLElement
  • type: string
  • fn: (e: Event) => void

Returns

DomEvent

public static stop(e: Event): DomEvent

Does stopPropagation and preventDefault at the same time.

Parameters

  • e: Event

Returns

DomEvent

public static stopPropagation(e: Event): DomEvent

Stop the given event from propagation to parent elements. Used inside the listener functions: L.DomEvent.addListener(div, 'click', function (e) { L.DomEvent.stopPropagation(e); });

Parameters

  • e: Event

Returns

DomEvent