Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

341 B
Raw Blame
export function isElementInViewport(element: HTMLElement) {
  const { top, left, width, height } = element.getBoundingClientRect()
  const { innerWidth, innerHeight } = window

  return (
    ((top >= 0 && top < innerHeight) || (top < 0 && top + height > 0)) &&
    ((left >= 0 && left < innerWidth) || (left < 0 && left + width > 0))
  )
}