Class DomUtil

Index

Properties

Methods

Properties

public static TRANSFORM: string

Vendor-prefixed transform style name.

public static TRANSITION: string

Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit).

Methods

public static addClass(el: HTMLElement, name: string)

Adds name to the element's class attribute.

Parameters

  • el: HTMLElement
  • name: string

public static create(tagName: string, className: string, container?: HTMLElement): HTMLElement

Creates an element with tagName, sets the className, and optionally appends it to container element.

Parameters

  • tagName: string
  • className: string
  • container?: HTMLElement optional

Returns

HTMLElement

public static disableTextSelection()

Makes sure text cannot be selected, for example during dragging.

public static enableTextSelection()

Makes text selection possible again.

public static get(id: string): HTMLElement

Returns an element with the given id if a string was passed, or just returns the element if it was passed directly.

Parameters

  • id: string

Returns

HTMLElement

public static getPosition(el: HTMLElement): Point

Returns the coordinates of an element previously positioned with setPosition.

Parameters

  • el: HTMLElement

Returns

Point

public static getScaleString(scale: number, origin: Point): string

Returns a CSS transform string to scale an element (with the given scale origin).

Parameters

  • scale: number
  • origin: Point

Returns

string

public static getStyle(el: HTMLElement, style: string): string

Returns the value for a certain style attribute on an element, including computed values or values set through CSS.

Parameters

  • el: HTMLElement
  • style: string

Returns

string

public static getTranslateString(point: Point): string

Returns a CSS transform string to move an element by the offset provided in the given point. Uses 3D translate on WebKit for hardware-accelerated transforms and 2D on other browsers.

Parameters

Returns

string

public static getViewportOffset(el: HTMLElement): Point

Returns the offset to the viewport for the requested element.

Parameters

  • el: HTMLElement

Returns

Point

public static hasClass(el: HTMLElement, name: string): boolean

Returns true if the element class attribute contains name.

Parameters

  • el: HTMLElement
  • name: string

Returns

boolean

public static removeClass(el: HTMLElement, name: string)

Removes name from the element's class attribute.

Parameters

  • el: HTMLElement
  • name: string

public static setOpacity(el: HTMLElement, value: number)

Set the opacity of an element (including old IE support). Value must be from 0 to 1.

Parameters

  • el: HTMLElement
  • value: number

public static setPosition(el: HTMLElement, point: Point, disable3D?: boolean)

Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers). Forces top/left positioning if disable3D is true.

Parameters

  • el: HTMLElement
  • point: Point
  • disable3D?: boolean optional

public static testProp(props: Array<string>): any

Goes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform.

Parameters

  • props: Array<string>

Returns

any