Skip to content

Instantly share code, notes, and snippets.

View l-portet's full-sized avatar
🤙

Lucas Portet l-portet

🤙
View GitHub Profile
import { RefObject, useEffect, useRef } from 'react';
function getScrollParent(node: HTMLElement | null): HTMLElement | null {
const isElement = node instanceof HTMLElement;
const overflowY = isElement && window.getComputedStyle(node).overflowY;
const isScrollable = overflowY !== 'visible' && overflowY !== 'hidden';
if (!node) {
return null;
} else if (isScrollable && node.scrollHeight >= node.clientHeight) {