const getViewportWidth = ( window , document ) => { return window ?. innerWidth || document ?. documentElement ?. clientWidth ; } ; const getViewportHeight = ( window , document ) => { return window ?. innerHeight || document ?. documentElement ?. clientHeight ; } ; const isInViewport = ( element , viewportWidth , viewportHeight ) : boolean => { const boundingClientRect = element . getBoundingClientRect ( ) ; return ( boundingClientRect . top >= 0 && boundingClientRect . left >= 0 && boundingClientRect . right <= viewportWidth && boundingClientRect . bottom <= viewportHeight ) ; } ; export { getViewportWidth , getViewportHeight , isInViewport } ;