(body)
| 183 | } |
| 184 | |
| 185 | function _getOrigin(body) { |
| 186 | // getBoundingClientRect is unfortunately too accurate. It introduces a pixel or two of |
| 187 | // jitter as the user scrolls that messes with our ability to detect if two positions |
| 188 | // are equivilant or not. We place an element at the top left of the page that will |
| 189 | // get the same jitter, so we can cancel the two out. |
| 190 | let node = zeroElement; |
| 191 | if (!node || !body.contains(node)) { |
| 192 | node = document.createElement('div'); |
| 193 | node.setAttribute('data-tether-id', uniqueId()); |
| 194 | extend(node.style, { |
| 195 | top: 0, |
| 196 | left: 0, |
| 197 | position: 'absolute' |
| 198 | }); |
| 199 | |
| 200 | body.appendChild(node); |
| 201 | |
| 202 | zeroElement = node; |
| 203 | } |
| 204 | |
| 205 | const id = node.getAttribute('data-tether-id'); |
| 206 | if (isUndefined(zeroPosCache[id])) { |
| 207 | zeroPosCache[id] = _getActualBoundingClientRect(node); |
| 208 | |
| 209 | // Clear the cache when this position call is done |
| 210 | defer(() => { |
| 211 | delete zeroPosCache[id]; |
| 212 | }); |
| 213 | } |
| 214 | |
| 215 | return zeroPosCache[id]; |
| 216 | } |
no test coverage detected
searching dependent graphs…