ant-design-vue/components/_util/getScroll.js

18 lines
441 B
JavaScript
Raw Normal View History

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