UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

39 lines (29 loc) 992 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var findStyle = function findStyle(node, prop) { if (node instanceof HTMLElement) { return getComputedStyle(node).getPropertyValue(prop); } return ""; }; var isScrollable = function isScrollable(node) { return /(auto|scroll)/.test(findStyle(node, "overflow") + findStyle(node, "overflow-y") + findStyle(node, "overflow-x")); }; // getScrollableParent recursively checking for CSS styles which would indicate that element is scrollable. // Element can be scrollable when it's parent has overflow auto or scroll set. var getScrollableParent = function getScrollableParent(node) { if (!node || node === document.body) { return document.body; } if (isScrollable(node)) { return node; } if (node && node.parentNode) { return getScrollableParent(node.parentNode); } return null; }; var _default = getScrollableParent; exports.default = _default;