Skip to content

Instantly share code, notes, and snippets.

@TrekSoft
Last active February 8, 2022 23:36
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/8b9c7e5693a9b56d76657e3f1c7697ba to your computer and use it in GitHub Desktop.
Save TrekSoft/8b9c7e5693a9b56d76657e3f1c7697ba to your computer and use it in GitHub Desktop.
shouldFloatFooter function - scrollTop
const onScroll = useCallback(
(e: SyntheticEvent) => {
const target = e.target as HTMLDivElement;
if (target.scrollTop > 0) {
setFloatHeader(true);
} else {
setFloatHeader(false);
}
setScrollTop(target.scrollTop);
},
[setScrollTop, setFloatHeader]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment