-
Notifications
You must be signed in to change notification settings - Fork 88
Util
Wiki ▸ API Reference ▸ Util
Simple utility methods and helpers. Some jQuery-ish replacements.
# wb.area(elem)
Returns the area of an element.
- elem: The element which area will be calculated.
===
# wb.closest(elem, selector)
Finds the nearest parent, or self, which matches selector.
- elem: The parent element.
- selector: A selector for filtering out elements with specific patterns.
===
# wb.containedBy(target, container)
Returns true if the rect of target is at least 90% contained by the rect of container.
- target: The target element.
- container: The container element.
===
# wb.dist(x1, y1, x2, y2)
Returns the distance between two points using Pythagorean theorem.
- x1: X coordinate of the first point.
- y1: Y coordinate of the first point.
- x2: X coordinate of the second point.
- y2: Y coordinate of the second point.
===
# wb.elem(name, attributes, children)
Utility for dynamically creating DOM elements and structures.
- name: The tag name.
- attributes: An array of attributes in the element.
- children: The children elements.
===
# wb.find(elem, selector)
Returns the first descendant that matches selector.
- elem: The parent element.
- selector: A selector for filtering out elements with specific patterns.
===
# wb.findAll(elem, selector)
Returns a (true) array of all descendants that match selector.
- elem: The parent element.
- selector: A selector for filtering out elements with specific patterns.
===
# wb.findChild(elem, selector)
Finds the first child which matches selector.
- elem: The parent element.
- selector: A selector for filtering out elements with specific patterns.
===
# wb.findChildren(elem, selector)
Finds all direct children which match selector as an array.
- elem: The parent element.
- selector: A selector for filtering out elements with specific patterns.
===
# wb.hide()
Hides an element.
===
# wb.indexOf(elem)
Returns the index of this element in a list of its parents children.
- elem: The element in the list.
===
# wb.makeArray(arrayLike)
Turns an array-like into a true array.
- arrayLike: The array-like to be converted to a true array.
===
# wb.matches(elem, selector)
Returns true if the element matches selector.
- elem: The element to be checked.
- selector: The selector to be compared with element.
===
# wb.overlap(elem1, elem2)
Returns the area of overlap between two elements.
- elem1: The first element.
- elem2: The second element.
===
# wb.overlapRect(r1, r2)
Returns the area of overlap between two rects.
- r1: The first rectangle.
- r2: The second rectangle.
===
# wb.reposition(elem, pos)
Moves an absolutely positioned element.
- elem: The element to be moved.
- pos: The new position for the element.
===
# wb.show()
Shows a hidden element.
===
# wb.rect(elem)
Utility for calling elem.getBoundingClientRect()
.
-
elem: The element for calling
getBoundingClientRect
.
===
# wb.resize(elem)
Resizes a text input based on the length of its content.
- elem: The text input element to be resized.