const position = this.node.getBoundingClientRect();
const { top, bottom } = position;
if (bottom > window.innerHeight - BOTTOM_OFFSET) {
- window.scrollTo(0, bottom - window.innerHeight + window.scrollY + BOTTOM_OFFSET);
+ window.scrollTo(0, bottom - window.innerHeight + window.pageYOffset + BOTTOM_OFFSET);
} else if (top < TOP_OFFSET) {
- window.scrollTo(0, top + window.scrollY - TOP_OFFSET);
+ window.scrollTo(0, top + window.pageYOffset - TOP_OFFSET);
}
}
}
function getScrollPosition(element: HTMLElement | Window): number {
- return isWindow(element) ? window.scrollY : element.scrollTop;
+ return isWindow(element) ? window.pageYOffset : element.scrollTop;
}
function scrollElement(element: HTMLElement | Window, position: number): void {