@jeremyckahn/farmhand
Version:
A farming game
11 lines (9 loc) • 335 B
text/typescript
export const isInViewport = (element: Element): boolean => {
const { top, left, bottom, right } = element.getBoundingClientRect()
return (
top >= 0 &&
left >= 0 &&
bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
right <= (window.innerWidth || document.documentElement.clientWidth)
)
}