UNPKG

funda-ui

Version:

React components using pure Bootstrap 5+ which does not contain any external style and script libraries.

21 lines (17 loc) 490 B
/** * Check if an element is in the viewport * @param {HTMLElement} elem * @returns {Boolean} */ function isInViewport(elem: HTMLElement) { const bounding = elem.getBoundingClientRect(); return ( bounding.top >= 0 && bounding.left >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && bounding.right <= (window.innerWidth || document.documentElement.clientWidth) ); } export { isInViewport }