mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-02 23:37:04 +00:00
25 lines
635 B
JavaScript
25 lines
635 B
JavaScript
export function getScroll(node, isVertical) {
|
|
if (typeof window === 'undefined') {
|
|
return 0;
|
|
}
|
|
const windowProp = isVertical ? 'pageYOffset' : 'pageXOffset';
|
|
const elementProp = isVertical ? 'scrollTop' : 'scrollLeft';
|
|
return node === window ? node[windowProp] : node[elementProp];
|
|
}
|
|
|
|
export function getRect(node) {
|
|
return node !== window
|
|
? node.getBoundingClientRect()
|
|
: { top: 0, left: 0, bottom: 0 };
|
|
}
|
|
|
|
export function getNodeHeight(node) {
|
|
if (!node) {
|
|
return 0;
|
|
}
|
|
if (node === window) {
|
|
return window.innerHeight;
|
|
}
|
|
return node.clientHeight;
|
|
}
|