zent
Version:
一套前端设计语言和基于React的实现
22 lines (19 loc) • 483 B
JavaScript
/**
* Get current scroll position in page
*/
export default function getScrollPosition() {
const x =
window.pageXOffset !== undefined
? window.pageXOffset
: (document.documentElement || document.body.parentNode || document.body)
.scrollLeft;
const y =
window.pageYOffset !== undefined
? window.pageYOffset
: (document.documentElement || document.body.parentNode || document.body)
.scrollTop;
return {
x,
y
};
}