1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = isElementInViewport;
|
7 |
|
8 | function isElementInViewport(elem) {
|
9 | if (!elem.getBoundingClientRect) {
|
10 | return false;
|
11 | }
|
12 |
|
13 | const rect = elem.getBoundingClientRect();
|
14 | const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
15 | const windowWidth = window.innerWidth || document.documentElement.clientWidth;
|
16 | const vertInView = rect.top <= windowHeight && rect.top + rect.height > 0;
|
17 | const horInView = rect.left <= windowWidth && rect.left + rect.width > 0;
|
18 | return vertInView && horInView;
|
19 | } |
\ | No newline at end of file |