Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DomUtil

Hierarchy

  • DomUtil

Index

Properties

Static TRANSFORM

TRANSFORM: string

Vendor-prefixed transform style name.

Static TRANSITION

TRANSITION: string

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

Methods

Static addClass

  • addClass(el: HTMLElement, name: string): void
  • Adds name to the element's class attribute.

    Parameters

    • el: HTMLElement
    • name: string

    Returns void

Static create

  • 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
    • Optional container: HTMLElement

    Returns HTMLElement

Static disableTextSelection

  • disableTextSelection(): void
  • Makes sure text cannot be selected, for example during dragging.

    Returns void

Static enableTextSelection

  • enableTextSelection(): void
  • Makes text selection possible again.

    Returns void

Static get

  • 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

Static getPosition

  • getPosition(el: HTMLElement): Point
  • Returns the coordinates of an element previously positioned with setPosition.

    Parameters

    • el: HTMLElement

    Returns Point

Static getScaleString

  • 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

Static getStyle

  • 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

Static getTranslateString

  • 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

Static getViewportOffset

  • getViewportOffset(el: HTMLElement): Point
  • Returns the offset to the viewport for the requested element.

    Parameters

    • el: HTMLElement

    Returns Point

Static hasClass

  • hasClass(el: HTMLElement, name: string): boolean
  • Returns true if the element class attribute contains name.

    Parameters

    • el: HTMLElement
    • name: string

    Returns boolean

Static removeClass

  • removeClass(el: HTMLElement, name: string): void
  • Removes name from the element's class attribute.

    Parameters

    • el: HTMLElement
    • name: string

    Returns void

Static setOpacity

  • setOpacity(el: HTMLElement, value: number): void
  • Set the opacity of an element (including old IE support). Value must be from 0 to 1.

    Parameters

    • el: HTMLElement
    • value: number

    Returns void

Static setPosition

  • setPosition(el: HTMLElement, point: Point, disable3D?: boolean): void
  • 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
    • Optional disable3D: boolean

    Returns void

Static testProp

  • testProp(props: 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: string[]

    Returns any