Leaflet Map DomUtil—用于处理DOM树的实用程序函数由Leaflet 内部使用

Leaflet Map DomUtil—用于处理DOM树的实用程序函数由Leaflet 内部使用

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.

大多数期望或返回HTMLElement的函数也适用于SVG元素。唯一的区别是类引用HTML中的CSS类和SVG中的SVG类。

Functions

FunctionReturnsDescription
get(<String|HTMLElement> id)HTMLElementReturns an element given its DOM id, or returns the element itself if it was passed directly.
返回给定DOM id的元素,如果直接传递,则返回元素本身。
getStyle(<HTMLElement> el, <String> 
styleAttrib)
StringReturns the value for a certain style attribute on an element, including computed values or values set through CSS.
返回元素上特定样式属性的值,包括计算值或通过CSS设置的值。
create(<String> tagName, <String> 
className?, <HTMLElement> container?)
HTMLElementCreates an HTML element with tagName, sets its class to className, and optionally appends it to container element.
使用tagName创建HTML元素,将其类设置为className,并可选地将其附加到容器元素。
remove(<HTMLElement> el)Removes el from its parent element
从其父元素中删除el
empty(<HTMLElement> el)Removes all of el‘s children elements from el
从el中删除el的所有子元素
toFront(<HTMLElement> el)Makes el the last child of its parent, so it renders in front of the other children.
使el成为其父对象的最后一个子对象,从而在其他子对象之前进行渲染。
toBack(<HTMLElement> el)Makes el the first child of its parent, so it renders behind the other children.
使el成为其父对象的第一个子对象,因此它在其他子对象之后进行渲染。
hasClass(<HTMLElement> el
<String> name)
BooleanReturns true if the element’s class attribute contains name.
如果元素的class属性包含name,则返回true。
addClass(<HTMLElement> el
<String> name)
Adds name to the element’s class attribute.
将名称添加到元素的class属性。
removeClass(<HTMLElement> 
el, <String> name)
Removes name from the element’s class attribute.
从元素的类属性中删除名称。
setClass(<HTMLElement> 
el, <String> name)
Sets the element’s class.
设置元素的类。
getClass(<HTMLElement> el)StringReturns the element’s class.
返回元素的类。
setOpacity(<HTMLElement> 
el, <Number> opacity)
Set the opacity of an element (including old IE support). opacity must be a number from 0 to 1.
设置元素的不透明度(包括旧的IE支持)。不透明度必须是从0到1的数字。
testProp(<String[]> props)String|falseGoes 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.
遍历样式名数组并返回元素的有效样式名的第一个名称。如果找不到这样的名称,则返回false。适用于供应商前缀样式,如转换。
setTransform(<HTMLElement> 
el, <Pointoffset, <Number>
 scale?)
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.
重置el的3D CSS变换,使其按偏移像素平移,并可选择按比例缩放。如果浏览器不支持3D CSS转换,则不会产生效果。
setPosition(<HTMLElement> 
el, <Pointposition)
Sets the position of el to coordinates specified by position, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers).
将el的位置设置为由位置指定的坐标,根据浏览器使用CSS平移或上/左定位(由传单内部用于定位其图层)。
getPosition(<HTMLElement> el)PointReturns the coordinates of an element previously positioned with setPosition.
返回先前使用setPosition定位的元素的坐标。
disableTextSelection()Prevents the user from generating selectstart DOM events, usually generated when the user drags the mouse through a page with text. Used internally by Leaflet to override the behaviour of any click-and-drag interaction on the map. Affects drag interactions on the whole document.
防止用户生成selectstart DOM事件,该事件通常在用户拖动鼠标通过带有文本的页面时生成。由传单内部使用,以覆盖地图上任何单击和拖动交互的行为。影响整个文档上的拖动交互。
enableTextSelection()Cancels the effects of a previous L.DomUtil.disableTextSelection.
取消先前L.DomUtil.disableTextSelection的效果。
disableImageDrag()As L.DomUtil.disableTextSelection, but for dragstart DOM events, usually generated when the user drags an image.
作为L.DomUtil.disableTextSelection,但对于dragstart DOM事件,通常在用户拖动图像时生成。
enableImageDrag()Cancels the effects of a previous L.DomUtil.disableImageDrag.
取消上一个[UNK]L.DomUtil.disableImageDrag的效果。
preventOutline(<HTMLElement> 
el)
Makes the outline of the element el invisible. Used internally by Leaflet to prevent focusable elements from displaying an outline when the user performs a drag interaction on them.
使元素el的轮廓不可见。由传单内部使用,以防止用户在可聚焦元素上执行拖动交互时显示轮廓。
restoreOutline()Cancels the effects of a previous L.DomUtil.preventOutline.
取消先前L.DomUtil.preventOutline的效果。
getSizedParentNode(<HTMLElement>
 el)
HTMLElementFinds the closest parent node which size (width and height) is not null.
查找大小(宽度和高度)不为空的最近父节点。
getScale(<HTMLElement> el)ObjectComputes 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().
计算当前应用于元素的CSS比例。返回一个对象,x和y成员分别为水平和垂直比例,boundingClientRect作为getBoundingClientRect()的结果。

Properties

PropertyTypeDescription
TRANSFORMStringVendor-prefixed transform style name (e.g. 'webkitTransform' for WebKit).
供应商前缀的转换样式名称(例如[UNK]’webkitTransform[UNK]for WebKit)。
TRANSITIONStringVendor-prefixed transition style name.
供应商前缀的过渡样式名称。
TRANSITION_ENDStringVendor-prefixed transitionend event name.
供应商前缀为transitioned和事件名称。
0 0 投票数
文章评分
订阅评论
提醒
0 评论
最旧
最新 最多投票
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x