salix-front/src/composables/elementIsVisibleInViewport.js

7 lines
255 B
JavaScript
Raw Normal View History

2024-02-27 13:55:45 +00:00
export const elementIsVisibleInViewport = (el) => {
const { top, left, bottom, right } = el.getBoundingClientRect();
const { innerHeight, innerWidth } = window;
return top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
};