1 | export function getScroll(node, isVertical) {
|
2 | if (typeof window === 'undefined') {
|
3 | return 0;
|
4 | }
|
5 | var windowProp = isVertical ? 'pageYOffset' : 'pageXOffset';
|
6 | var elementProp = isVertical ? 'scrollTop' : 'scrollLeft';
|
7 | return node === window ? node[windowProp] : node[elementProp];
|
8 | }
|
9 |
|
10 | export function getRect(node) {
|
11 | return node !== window ? node.getBoundingClientRect() : { top: 0, left: 0, bottom: 0 };
|
12 | }
|
13 |
|
14 | export function getNodeHeight(node) {
|
15 | if (!node) {
|
16 | return 0;
|
17 | }
|
18 | if (node === window) {
|
19 | return window.innerHeight;
|
20 | }
|
21 | return node.clientHeight;
|
22 | } |
\ | No newline at end of file |