|
| 1 | +The `$uibPosition` service provides a set of DOM utilities used internally to absolute-position an element in relation to another element (tooltips, popovers, typeaheads etc...). |
| 2 | + |
| 3 | +### getRawNode(element) |
| 4 | + Takes a jQuery/jqLite element and converts it to a raw DOM element. |
| 5 | + |
| 6 | +##### parameters |
| 7 | + |
| 8 | +* `element` _(Type 'object')_ - The element to convert. |
| 9 | + |
| 10 | +##### returns |
| 11 | + |
| 12 | + _(Type 'element')_ - A raw DOM element. |
| 13 | + |
| 14 | +### parseSyle(element) |
| 15 | + Parses a numeric style value to a number. Strips units and will return 0 for invalid (NaN) numbers. |
| 16 | + |
| 17 | +##### parameters |
| 18 | + |
| 19 | +* `value` _(Type 'string')_ - The style value to parse. |
| 20 | + |
| 21 | +##### returns |
| 22 | + |
| 23 | + _(Type 'number')_ - The numeric value of the style property. |
| 24 | + |
| 25 | +### offsetParent(element) |
| 26 | + Gets the closest positioned ancestor. |
| 27 | + |
| 28 | +##### parameters |
| 29 | + |
| 30 | +* `element` _(Type 'element')_ - The element to get the offset parent for. |
| 31 | + |
| 32 | +##### returns |
| 33 | + |
| 34 | + _(Type 'element')_ - The closest positioned ancestor. |
| 35 | + |
| 36 | +### scrollbarWidth() |
| 37 | + Calculates the browser scrollbar width and caches the result for future calls. Concept from the TWBS measureScrollbar() function in [modal.js](https://github.com/twbs/bootstrap/blob/master/js/modal.js). |
| 38 | + |
| 39 | +##### returns |
| 40 | + |
| 41 | + _(Type 'number')_ - The width of the browser scrollbar. |
| 42 | + |
| 43 | +### scrollParent(element, includeHidden) |
| 44 | + Gets the closest scrollable ancestor. Concept from the jQueryUI [scrollParent.js](https://github.com/jquery/jquery-ui/blob/master/ui/scroll-parent.js). |
| 45 | + |
| 46 | +##### parameters |
| 47 | + |
| 48 | +* `element` _(Type 'element')_ - The element to get the closest scrollable ancestor for. |
| 49 | + |
| 50 | +* `includeHidden` _(Type 'boolean', optional - default is false)_ - Should scroll style of 'hidden' be considered. |
| 51 | + |
| 52 | +##### returns |
| 53 | + |
| 54 | + _(Type 'element')_ - The closest scrollable ancestor. |
| 55 | + |
| 56 | +### position(element, includeMargins) |
| 57 | + A read-only equivalent of jQuery's [position](http://api.jquery.com/position/) function, distance to closest positioned ancestor. Does not account for margins by default like jQuery's position. |
| 58 | + |
| 59 | +##### parameters |
| 60 | + |
| 61 | +* `element` _(Type 'element')_ - The element to get the position for. |
| 62 | + |
| 63 | +* `includeMagins` _(Type 'boolean', optional - default is false)_ - Should margins be accounted for. |
| 64 | + |
| 65 | +##### returns |
| 66 | + |
| 67 | + _(Type 'object')_ - An object with the following properties: |
| 68 | + |
| 69 | +* width: _(Type 'number')_ The width of the element. |
| 70 | +* height: _(Type 'number')_ The height of the element. |
| 71 | +* top: _(Type 'number')_ Distance to top edge of offset parent. |
| 72 | +* left: _(Type 'number')_ Distance to left edge of offset parent. |
| 73 | + |
| 74 | +### offset(element) |
| 75 | + A read-only equivalent of jQuery's [offset](http://api.jquery.com/offset/) function, distance to viewport. |
| 76 | + |
| 77 | +##### parameters |
| 78 | + |
| 79 | +* `element` _(Type 'element')_ - The element to get the offset for. |
| 80 | + |
| 81 | +##### returns |
| 82 | + |
| 83 | + _(Type 'object')_ - An object with the following properties: |
| 84 | + |
| 85 | +* width: _(Type 'number')_ The width of the element. |
| 86 | +* height: _(Type 'number')_ The height of the element. |
| 87 | +* top: _(Type 'number')_ Distance to top edge of the viewport. |
| 88 | +* left: _(Type 'number')_ Distance to left edge of the viewport. |
| 89 | + |
| 90 | +### viewportOffset(element, useDocument, includePadding) |
| 91 | + Gets the elements available space relative to the closest scrollable ancestor. Accounts for padding, border, and scrollbar width. |
| 92 | + Right and bottom dimensions represent the distance to the respective edge of the viewport element, not the top and left edge. |
| 93 | + If the element edge extends beyond the viewport, a negative value will be reported. |
| 94 | + |
| 95 | +##### parameters |
| 96 | + |
| 97 | +* `element` _(Type 'element')_ - The element to get the viewport offset for. |
| 98 | +* `useDocument` _(Type 'boolean', optional - default is false)_ - Should the viewport be the document element instead of the first scrollable element. |
| 99 | +* `includePadding` _(Type 'boolean', optional - default is true)_ - Should the padding on the viewport element be accounted for, default is true. |
| 100 | + |
| 101 | +##### returns |
| 102 | + |
| 103 | + _(Type 'object')_ - An object with the following properties: |
| 104 | + |
| 105 | +* top: _(Type 'number')_ Distance to top content edge of the viewport. |
| 106 | +* bottom: _(Type 'number')_ Distance to bottom content edge of the viewport. |
| 107 | +* left: _(Type 'number')_ Distance to left content edge of the viewport. |
| 108 | +* right: _(Type 'number')_ Distance to right content edge of the viewport. |
| 109 | + |
| 110 | +### parsePlacement(placement) |
| 111 | + Gets an array of placement values parsed from a placement string. Along with the 'auto' indicator, supported placement strings are: |
| 112 | + |
| 113 | +* top: element on top, horizontally centered on host element. |
| 114 | +* top-left: element on top, left edge aligned with host element left edge. |
| 115 | +* top-right: element on top, right edge aligned with host element right edge. |
| 116 | +* bottom: element on bottom, horizontally centered on host element. |
| 117 | +* bottom-left: element on bottom, left edge aligned with host element left edge. |
| 118 | +* bottom-right: element on bottom, right edge aligned with host element right edge. |
| 119 | +* left: element on left, vertically centered on host element. |
| 120 | +* left-top: element on left, top edge aligned with host element top edge. |
| 121 | +* left-bottom: element on left, bottom edge aligned with host element bottom edge. |
| 122 | +* right: element on right, vertically centered on host element. |
| 123 | +* right-top: element on right, top edge aligned with host element top edge. |
| 124 | +* right-bottom: element on right, bottom edge aligned with host element bottom edge. |
| 125 | + |
| 126 | +A placement string with an 'auto' indicator is expected to be space separated from the placement, i.e: 'auto bottom-left'. |
| 127 | +If the primary and secondary placement values do not match 'top, bottom, left, right' then 'top' will be the primary placement and |
| 128 | +'center' will be the secondary placement. If 'auto' is passed, true will be returned as the 3rd value of the array. |
| 129 | + |
| 130 | +##### parameters |
| 131 | + |
| 132 | +* `placement` _(Type 'string', e.g. 'auto top-left')_ - The placement string to parse. |
| 133 | + |
| 134 | +##### returns |
| 135 | + |
| 136 | + _(Type 'array')_ - An array with the following values: |
| 137 | + |
| 138 | +* [0]: _(Type 'string')_ - The primary placement. |
| 139 | +* [1]: _(Type 'string')_ - The secondary placement. |
| 140 | +* [2]: _(Type 'boolean')_ - Is auto place enabled. |
| 141 | + |
| 142 | +### positionElements(hostElement, targetElement, placement, appendToBody) |
| 143 | + Gets gets coordinates for an element to be positioned relative to another element. |
| 144 | + |
| 145 | +##### parameters |
| 146 | + |
| 147 | + * `hostElement` _(Type 'element')_ - The element to position against. |
| 148 | + * `targetElement` _(Type 'element')_ - The element to position. |
| 149 | + * `placement` _(Type 'string', optional - default is top)_ - The placement for the target element. See the parsePlacement() function for |
| 150 | + available options. If 'auto' placement is used, the viewportOffset() function is used to decide where the targetElement will fit. |
| 151 | + * `appendToBody` _(Type 'boolean', optional - default is false)_ - Should the coordinates be cacluated from the body element. |
| 152 | + |
| 153 | +##### returns |
| 154 | + |
| 155 | + _(Type 'object')_ - An object with the following properties: |
| 156 | + |
| 157 | + * top: _(Type 'number')_ The targetElement top value. |
| 158 | + * left: _(Type 'number')_ The targetElement left value. |
| 159 | + * right: _(Type 'number')_ The resolved placement with 'auto' removed. |
| 160 | + |
| 161 | +### positionArrow(element, placement) |
| 162 | + Positions the tooltip and popover arrow elements when using placement options beyond the standard top, left, bottom, or right. |
| 163 | + |
| 164 | +##### parameters |
| 165 | + |
| 166 | + * `element` _(Type 'element')_ - The element to position the arrow element for. |
| 167 | + * `placement` _(Type 'string')_ - The placement for the element. |
0 commit comments