Last active
June 29, 2021 23:57
-
-
Save stokesman/9820dbf1b6e1386aa6fc503b95f0be3c to your computer and use it in GitHub Desktop.
Find parent scrolling context from DOM element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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