leaflet
Version:
JavaScript library for mobile-friendly interactive maps
69 lines (68 loc) • 3.33 kB
TypeScript
import { Point } from '../geometry/Point.js';
/**
* Utility functions to work with the [DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model)
* tree, used by Leaflet internally.
*
* Most functions expecting or returning a `HTMLElement` also work for SVG elements. The only
* difference is that classes refer to CSS classes in HTML and SVG classes in SVG.
* @module DomUtil
*/
/**
* Returns an element given its DOM id, or returns the element itself if it was passed directly.
* @param {string | HTMLElement} id
*/
export declare function get(id: string | HTMLElement): HTMLElement | null;
export declare function create<K extends keyof HTMLElementTagNameMap>(tagName: K, className?: string, container?: HTMLElement): HTMLElementTagNameMap[K];
export declare function create(tagName: string, className?: string, container?: HTMLElement): HTMLElement;
/**
* Makes `el` the last child of its parent, so it renders in front of the other children.
* @param {HTMLElement | SVGElement} el
*/
export declare function toFront(el: HTMLElement | SVGElement): void;
/**
* Makes `el` the first child of its parent, so it renders behind the other children.
* @param {HTMLElement | SVGElement} el
*/
export declare function toBack(el: HTMLElement | SVGElement): void;
/**
* Resets the 3D CSS transform of `el` so it is translated by `offset` pixels and optionally scaled
* by `scale`. Does not have an effect if the browser doesn't support 3D CSS transforms.
* @param {HTMLElement | SVGElement} el
* @param {Point} offset
* @param {number} [scale]
*/
export declare function setTransform(el: HTMLElement | SVGElement, offset: Point, scale?: number): void;
/**
* Sets the position of `el` to coordinates specified by `point` using a CSS translate (used
* by Leaflet internally to position its layers). With `flat`, the translate is 2D, so `el` is
* painted into its parent's compositor layer instead of getting a layer of its own.
* @param {HTMLElement | SVGElement} el
* @param {Point} point
* @param {boolean} [flat]
*/
export declare function setPosition(el: HTMLElement | SVGElement, point: Point, flat?: boolean): void;
/**
* Returns the coordinates of an element previously positioned with setPosition.
* @param {HTMLElement | SVGElement} el
*/
export declare function getPosition(el: HTMLElement | SVGElement): Point;
/** Prevents the user from generating `dragstart` DOM events, usually generated when the user drags an image. */
export declare function disableImageDrag(): void;
/** Cancels the effects of a previous [`DomUtil.disableImageDrag`](#domutil-disableimagedrag). */
export declare function enableImageDrag(): void;
/**
* Finds the closest parent node which size (width and height) is not null.
* @param {HTMLElement} element
*/
export declare function getSizedParentNode(element: HTMLElement): HTMLElement;
/**
* Computes the CSS scale currently applied on the element. Returns an object with `x` and `y` members as
* horizontal and vertical scales respectively, and `boundingClientRect` as the result of
* [`getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
* @param {HTMLElement} element
*/
export declare function getScale(element: HTMLElement): {
x: number;
y: number;
boundingClientRect: DOMRect;
};