Skip to content

Instantly share code, notes, and snippets.

@TrekSoft
Last active February 8, 2022 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TrekSoft/b35b9b46cc82099a327eb35898d2add6 to your computer and use it in GitHub Desktop.
Save TrekSoft/b35b9b46cc82099a327eb35898d2add6 to your computer and use it in GitHub Desktop.
shouldFloatFooter function - mutationObserver
const onFooterContainerChange = useCallback(
node => {
if (node !== null) {
setFooterContainerElement(node);
if (mutationObserver) {
mutationObserver.observe(node, {
childList: true,
characterData: true,
attributes: true,
subtree: true,
});
if (scrollingElement) {
mutationObserver.observe(scrollingElement, {
childList: true,
characterData: true,
attributes: true,
subtree: true,
});
}
}
}
},
[mutationObserver, scrollingElement]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment