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