(body, target)
| 109 | * @return {{top: *, left: *, width: *, height: *}} |
| 110 | */ |
| 111 | export function getVisibleBounds(body, target) { |
| 112 | if (target === document.body) { |
| 113 | return { top: pageYOffset, left: pageXOffset, height: innerHeight, width: innerWidth }; |
| 114 | } else { |
| 115 | const bounds = getBounds(body, target); |
| 116 | |
| 117 | const out = { |
| 118 | height: bounds.height, |
| 119 | width: bounds.width, |
| 120 | top: bounds.top, |
| 121 | left: bounds.left |
| 122 | }; |
| 123 | |
| 124 | out.height = Math.min(out.height, bounds.height - (pageYOffset - bounds.top)); |
| 125 | out.height = Math.min(out.height, bounds.height - ((bounds.top + bounds.height) - (pageYOffset + innerHeight))); |
| 126 | out.height = Math.min(innerHeight, out.height); |
| 127 | out.height -= 2; |
| 128 | |
| 129 | out.width = Math.min(out.width, bounds.width - (pageXOffset - bounds.left)); |
| 130 | out.width = Math.min(out.width, bounds.width - ((bounds.left + bounds.width) - (pageXOffset + innerWidth))); |
| 131 | out.width = Math.min(innerWidth, out.width); |
| 132 | out.width -= 2; |
| 133 | |
| 134 | if (out.top < pageYOffset) { |
| 135 | out.top = pageYOffset; |
| 136 | } |
| 137 | if (out.left < pageXOffset) { |
| 138 | out.left = pageXOffset; |
| 139 | } |
| 140 | |
| 141 | return out; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | export function removeUtilElements(body) { |
| 146 | if (zeroElement && zeroElement?.parentNode === body) { |
no test coverage detected
searching dependent graphs…