mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 14:17:00 +08:00
16 lines
358 B
JavaScript
16 lines
358 B
JavaScript
export default function isInViewPort(el) {
|
|
if (!el) return;
|
|
|
|
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)
|
|
);
|
|
}
|