mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 00:43:54 +00:00
15 lines
377 B
TypeScript
15 lines
377 B
TypeScript
export function getScrollParent(node: HTMLElement | null): HTMLElement | Window {
|
|
let parent = node?.parentElement ?? null;
|
|
|
|
while (parent) {
|
|
const { overflowY } = window.getComputedStyle(parent);
|
|
if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay') {
|
|
return parent;
|
|
}
|
|
|
|
parent = parent.parentElement;
|
|
}
|
|
|
|
return window;
|
|
}
|