sanity
Version:
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches
13 lines (9 loc) • 516 B
text/typescript
export function hasOverflowScroll(el: HTMLElement): boolean {
const overflow = getComputedStyle(el).overflow
return overflow.includes('auto') || overflow.includes('scroll')
}
// Check whether an element is currently scrollable (meaning it must both have overflow scroll *and* content overflowing)
export function isScrollable(el: HTMLElement): boolean {
const scrollableContent = el.scrollHeight !== el.offsetHeight || el.scrollWidth !== el.offsetWidth
return scrollableContent && hasOverflowScroll(el)
}