(body, el)
| 6 | let zeroElement = null; |
| 7 | |
| 8 | export function getBounds(body, el) { |
| 9 | let doc; |
| 10 | if (el === document) { |
| 11 | doc = document; |
| 12 | el = document.documentElement; |
| 13 | } else { |
| 14 | doc = el.ownerDocument; |
| 15 | } |
| 16 | |
| 17 | const docEl = doc.documentElement; |
| 18 | |
| 19 | const box = _getActualBoundingClientRect(el); |
| 20 | |
| 21 | const origin = _getOrigin(body); |
| 22 | |
| 23 | box.top -= origin.top; |
| 24 | box.left -= origin.left; |
| 25 | |
| 26 | if (isUndefined(box.width)) { |
| 27 | box.width = document.body.scrollWidth - box.left - box.right; |
| 28 | } |
| 29 | if (isUndefined(box.height)) { |
| 30 | box.height = document.body.scrollHeight - box.top - box.bottom; |
| 31 | } |
| 32 | |
| 33 | box.top = box.top - docEl.clientTop; |
| 34 | box.left = box.left - docEl.clientLeft; |
| 35 | box.right = doc.body.clientWidth - box.width - box.left; |
| 36 | box.bottom = doc.body.clientHeight - box.height - box.top; |
| 37 | |
| 38 | return box; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Gets bounds for when target modifiier is 'scroll-handle' |
no test coverage detected
searching dependent graphs…