MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / overflowingAncestor

Function overflowingAncestor

scripts/smoothScroll.js:633–662  ·  view source on GitHub ↗
(el, x)

Source from the content-addressed store, hash-verified

631 // scroll | no | YES | YES | YES |
632 // auto | no | YES | YES | YES |
633 function overflowingAncestor(el, x) {
634 let elems = [];
635 let body = document.body;
636 let rootScrollHeight = root.scrollHeight;
637 let rootScrollWidth = root.scrollWidth;
638 do {
639 let cached = getCache(el, x);
640 if (cached) {
641 return setCache(elems, cached, x);
642 }
643 elems.push(el);
644 if (
645 (x && rootScrollWidth === el.scrollWidth) ||
646 (!x && rootScrollHeight === el.scrollHeight)
647 ) {
648 let topOverflowsNotHidden =
649 overflowNotHidden(root, x) && overflowNotHidden(body, x);
650 let isOverflowCSS =
651 topOverflowsNotHidden || overflowAutoOrScroll(root, x);
652 if (
653 (isFrame && isContentOverflowing(root, x)) ||
654 (!isFrame && isOverflowCSS)
655 ) {
656 return setCache(elems, getScrollRoot(), x);
657 }
658 } else if (isContentOverflowing(el, x) && overflowAutoOrScroll(el, x)) {
659 return setCache(elems, el, x);
660 }
661 } while ((el = el.parentElement));
662 }
663 function isContentOverflowing(el, x) {
664 return x
665 ? el.clientWidth + 10 < el.scrollWidth

Callers 3

wheelFunction · 0.85
keydownFunction · 0.85
mousedownFunction · 0.85

Calls 6

overflowNotHiddenFunction · 0.85
overflowAutoOrScrollFunction · 0.85
isContentOverflowingFunction · 0.85
getScrollRootFunction · 0.85
getCacheFunction · 0.70
setCacheFunction · 0.70

Tested by

no test coverage detected