MCPcopy Create free account
hub / github.com/bugy/script-server / scrollToElement

Function scrollToElement

web-src/src/common/utils/common.js:488–502  ·  view source on GitHub ↗
(element, onlyWhenOutside = false)

Source from the content-addressed store, hash-verified

486}
487
488export function scrollToElement(element, onlyWhenOutside = false) {
489 if (onlyWhenOutside && isVisibleOnScroll(element, false)) {
490 return;
491 }
492
493 const scrollableParent = findScrollableParent(element);
494 let alignToTop;
495 if (isNull(scrollableParent)) {
496 alignToTop = true;
497 } else {
498 alignToTop = element.offsetTop < scrollableParent.scrollTop;
499 }
500
501 element.scrollIntoView(alignToTop);
502}
503
504function findScrollableParent(elem) {
505 let scrollableParent = elem.parentNode;

Callers

nothing calls this directly

Calls 3

isVisibleOnScrollFunction · 0.85
findScrollableParentFunction · 0.85
isNullFunction · 0.85

Tested by

no test coverage detected