DomUtil
Utility functions to work with the DOM tree, used by Leaflet internally.
Methods
Method | Returns | Description |
---|---|---|
get(
|
HTMLElement |
Returns an element with the given id if a string was passed, or just returns the element if it was passed directly. |
getStyle(
|
String |
Returns the value for a certain style attribute on an element, including computed values or values set through CSS. |
getViewportOffset(
|
Point |
Returns the offset to the viewport for the requested element. |
create(
|
HTMLElement |
Creates an element with tagName , sets the className , and optionally appends it to container element. |
disableTextSelection() |
- | Makes sure text cannot be selected, for example during dragging. |
enableTextSelection() |
- | Makes text selection possible again. |
hasClass(
|
Boolean |
Returns true if the element class attribute contains name . |
addClass(
|
- | Adds name to the element's class attribute. |
removeClass(
|
- | Removes name from the element's class attribute. |
setOpacity(
|
- | Set the opacity of an element (including old IE support). Value must be from 0 to 1 . |
testProp(
|
String or false |
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 . |
getTranslateString(
|
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. |
getScaleString(
|
String |
Returns a CSS transform string to scale an element (with the given scale origin). |
setPosition(
|
- | 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 . |
getPosition(
|
Point | Returns the coordinates of an element previously positioned with setPosition . |
Properties
Property | Type | Description |
---|---|---|
TRANSITION
|
String |
Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). |
TRANSFORM
|
String |
Vendor-prefixed transform style name. |