You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/_util/getScroll.js

18 lines
447 B

export default function getScroll(target, top) {
7 years ago
if (typeof window === 'undefined') {
return 0;
7 years ago
}
const prop = top ? 'pageYOffset' : 'pageXOffset';
const method = top ? 'scrollTop' : 'scrollLeft';
const isWindow = target === window;
7 years ago
let ret = isWindow ? target[prop] : target[method];
7 years ago
// ie6,7,8 standard mode
if (isWindow && typeof ret !== 'number') {
ret = window.document.documentElement[method];
7 years ago
}
return ret;
7 years ago
}