scinote-web/app/javascript/vue/shared/isInViewPort.js
2023-10-04 12:48:31 +02:00

14 lines
338 B
JavaScript

export default function isInViewPort(el) {
const rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <=
(window.innerHeight ||
document.documentElement.clientHeight) &&
rect.right <=
(window.innerWidth ||
document.documentElement.clientWidth)
);
}