Skip to content

Instantly share code, notes, and snippets.

@stokesman
Last active June 29, 2021 23:57
Show Gist options
  • Save stokesman/9820dbf1b6e1386aa6fc503b95f0be3c to your computer and use it in GitHub Desktop.
Save stokesman/9820dbf1b6e1386aa6fc503b95f0be3c to your computer and use it in GitHub Desktop.
Find parent scrolling context from DOM element
function getScrollContext( node ) {
let at = node;
let hasOverflow = false;
while ( at.parentNode !== at.ownerDocument ) {
at = at.parentNode;
if ( at.clientHeight < at.scrollHeight ) {
hasOverflow = true;
break;
}
}
return [ at, hasOverflow ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment