utils.dom namespace
Enumerations
Enumeration | Description |
---|---|
NodeType | Node type constants. https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType |
Functions
Function | Description |
---|---|
addClass(element, className) | Add a CSS class to a element. Handles multiple space-separated classes for legacy reasons. |
createSvgElement(name, attrs, opt_parent) | Helper method for creating SVG elements. |
getFastTextWidth(textElement, fontSize, fontWeight, fontFamily) | Gets the width of a text element using a faster method than getTextWidth . This method requires that we know the text element's font family and size in advance. Similar to getTextWidth , we cache the width we compute. |
getFastTextWidthWithSizeString(textElement, fontSize, fontWeight, fontFamily) | Gets the width of a text element using a faster method than getTextWidth . This method requires that we know the text element's font family and size in advance. Similar to getTextWidth , we cache the width we compute. This method is similar to getFastTextWidth but expects the font size parameter to be a string. |
getTextWidth(textElement) | Gets the width of a text element, caching it in the process. |
hasClass(element, className) | Checks if an element has the specified CSS class. |
insertAfter(newNode, refNode) | Insert a node after a reference node. Contrast with node.insertBefore function. |
measureFontMetrics(text, fontSize, fontWeight, fontFamily) | Measure a font's metrics. The height and baseline values. |
removeClass(element, className) | Remove a CSS class from a element. Handles multiple space-separated classes for legacy reasons. |
removeClasses(element, classNames) | Removes multiple classes from an element. |
removeNode(node) | Removes a node from its parent. No-op if not attached to a parent. |
setCssTransform(element, transform) | Sets the CSS transform property on an element. This function sets the non-vendor-prefixed and vendor-prefixed versions for backwards compatibility with older browsers. See https://caniuse.com/#feat=transforms2d |
startTextWidthCache() | Start caching text widths. Every call to this function MUST also call stopTextWidthCache. Caches must not survive between execution threads. |
stopTextWidthCache() | Stop caching field widths. Unless caching was already on when the corresponding call to startTextWidthCache was made. |
Variables
Variable | Description |
---|---|
HTML_NS | Required name space for HTML elements. |
SVG_NS | Required name space for SVG elements. |
XLINK_NS | Required name space for XLINK elements. |