UNPKG

@shopify/polaris

Version:

Shopify’s admin product component library

11 lines (9 loc) 245 B
export function isElementInViewport(element: Element) { const {top, left, bottom, right} = element.getBoundingClientRect(); return ( top >= 0 && right <= window.innerWidth && bottom <= window.innerHeight && left >= 0 ); }