Ghost/ghost/admin/app/utils/get-scroll-parent.js
Sanne de Vries 7a56ded8d0 Updated About/What's new? page (#1872)
Merged About and What's new? page.
2021-09-08 14:00:24 +02:00

14 lines
455 B
JavaScript

export default function getScrollParent(node) {
const isElement = node instanceof HTMLElement;
const overflowY = isElement && window.getComputedStyle(node).overflowY;
const isScrollable = overflowY !== 'visible' && overflowY !== 'hidden';
if (!node) {
return null;
} else if (isScrollable && node.scrollHeight >= node.clientHeight) {
return node;
}
return getScrollParent(node.parentNode) || document.body;
}