Add scroll handler

This commit is contained in:
Justin Edmund 2022-03-01 01:14:25 -08:00
parent 4399948445
commit 44c2c46da8

View file

@ -31,6 +31,11 @@ const ProfileRoute: React.FC = () => {
const [raidId, setRaidId] = useState<string | null>(null)
const [recencyInSeconds, setRecencyInSeconds] = useState<number | null>(null)
useEffect(() => {
window.addEventListener("scroll", handleScroll)
return () => window.removeEventListener("scroll", handleScroll);
}, [])
useEffect(() => {
if (username)
fetchProfile(username as string)
@ -93,16 +98,6 @@ const ProfileRoute: React.FC = () => {
setRecencyInSeconds(null)
}
function render() {
const content = (parties && parties.length > 0) ? renderGrids() : renderNoGrids()
return (
<div>
<ProfileHeader username={user.username} gender={true} />
{content}
</div>
)
}
function handleScroll() {
if (window.pageYOffset > 90)
setScrolled(true)