vue-hooks-plus
Version:
Vue hooks library
22 lines (21 loc) • 620 B
JavaScript
const getScrollTop = (el) => {
if (el === document || el === document.documentElement || el === document.body) {
return Math.max(
window.pageYOffset,
document.documentElement.scrollTop,
document.body.scrollTop
);
}
return el.scrollTop;
};
const getScrollHeight = (el) => {
return el.scrollHeight || Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
};
const getClientHeight = (el) => {
return el.clientHeight || Math.max(document.documentElement.clientHeight, document.body.clientHeight);
};
export {
getClientHeight,
getScrollHeight,
getScrollTop
};