| 247 | * Leser wirklich sieht. |
| 248 | */ |
| 249 | const visibleRectOf = (node) => { |
| 250 | const rect = node.getBoundingClientRect(); |
| 251 | let left = rect.left; |
| 252 | let top = rect.top; |
| 253 | let right = rect.right; |
| 254 | let bottom = rect.bottom; |
| 255 | for ( |
| 256 | let current = node.parentElement; |
| 257 | current !== null && current !== document.documentElement; |
| 258 | current = current.parentElement |
| 259 | ) { |
| 260 | const style = window.getComputedStyle(current); |
| 261 | if (style.overflowX === 'visible' && style.overflowY === 'visible') { |
| 262 | continue; |
| 263 | } |
| 264 | const box = current.getBoundingClientRect(); |
| 265 | if (style.overflowX !== 'visible') { |
| 266 | left = Math.max(left, box.left); |
| 267 | right = Math.min(right, box.right); |
| 268 | } |
| 269 | if (style.overflowY !== 'visible') { |
| 270 | top = Math.max(top, box.top); |
| 271 | bottom = Math.min(bottom, box.bottom); |
| 272 | } |
| 273 | } |
| 274 | left = Math.max(left, 0); |
| 275 | top = Math.max(top, 0); |
| 276 | right = Math.min(right, viewport.width); |
| 277 | bottom = Math.min(bottom, viewport.height); |
| 278 | return { x: left, y: top, width: right - left, height: bottom - top }; |
| 279 | }; |
| 280 | |
| 281 | for (const node of document.body.querySelectorAll('*')) { |
| 282 | if (excluded(node)) { |