1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| const isScrollable = function (ele) {
const hasScrollableContent = ele.scrollHeight > ele.clientHeight;
const overflowYStyle = window.getComputedStyle(ele).overflowY;
const isOverflowHidden = overflowYStyle.indexOf('hidden') !== -1;
return hasScrollableContent && !isOverflowHidden;
};
const getScrollableParent = function (ele) {
return !ele || ele === document.body
? document.body
: isScrollable(ele)
? ele
: getScrollableParent(ele.parentNode);
};
|