Skip to content

Instantly share code, notes, and snippets.

@TrekSoft
Last active February 8, 2022 23:36
Show Gist options
  • Save TrekSoft/cbf92964d7f1b69cd27b66558ce3c681 to your computer and use it in GitHub Desktop.
Save TrekSoft/cbf92964d7f1b69cd27b66558ce3c681 to your computer and use it in GitHub Desktop.
shouldFloatFooter function
const footerBottomPadding = 24;
const floatFooter = useMemo(() => {
if (scrollingElement && footerContainerElement) {
const {
clientHeight: parentHeight,
offsetTop: parentOffsetTop,
} = scrollingElement;
const {
clientHeight: footerHeight,
offsetTop: footerOffsetTop,
} = footerContainerElement;
return (
parentHeight + parentOffsetTop + scrollTop <
footerOffsetTop + footerHeight + footerBottomPadding
);
}
return false;
}, [
scrollTop,
scrollingElement,
footerContainerElement,
windowHeight,
lastMutation,
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment