mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-15 21:56:12 +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)
|
|
);
|
|
}
|