chore: remove unused getScroller

This commit is contained in:
chenjiahan 2020-09-27 16:37:11 +08:00
parent 05866514db
commit a3a8f2961c

View File

@ -4,41 +4,6 @@ function isWindow(val: unknown): val is Window {
return val === window;
}
// get nearest scroll element
// http://w3help.org/zh-cn/causes/SD9013
// http://stackoverflow.com/questions/17016740/onscroll-function-is-not-working-for-chrome
const overflowScrollReg = /scroll|auto/i;
export function getScroller(el: HTMLElement, root: ScrollElement = window) {
let node = el;
while (
node &&
node.tagName !== 'HTML' &&
node.nodeType === 1 &&
node !== root
) {
const { overflowY } = window.getComputedStyle(node);
if (overflowScrollReg.test(overflowY)) {
if (node.tagName !== 'BODY') {
return node;
}
// see: https://github.com/youzan/vant/issues/3823
const { overflowY: htmlOverflowY } = window.getComputedStyle(
node.parentNode as Element
);
if (overflowScrollReg.test(htmlOverflowY)) {
return node;
}
}
node = node.parentNode as HTMLElement;
}
return root;
}
export function getScrollTop(el: ScrollElement): number {
const top = 'scrollTop' in el ? el.scrollTop : el.pageYOffset;