mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-20 02:36:18 +08:00
14 lines
383 B
JavaScript
14 lines
383 B
JavaScript
export function isInViewPort(el) {
|
|
const rect = el.getBoundingClientRect();
|
|
|
|
return (
|
|
rect.top >= 0 &&
|
|
rect.left >= 0 &&
|
|
rect.bottom <=
|
|
(window.innerHeight ||
|
|
document.documentElement.clientHeight) /*or $(window).height() */ &&
|
|
rect.right <=
|
|
(window.innerWidth ||
|
|
document.documentElement.clientWidth) /*or $(window).width() */
|
|
);
|
|
}
|