Add scroll handler
This commit is contained in:
parent
4399948445
commit
44c2c46da8
1 changed files with 5 additions and 10 deletions
|
|
@ -31,6 +31,11 @@ const ProfileRoute: React.FC = () => {
|
||||||
const [raidId, setRaidId] = useState<string | null>(null)
|
const [raidId, setRaidId] = useState<string | null>(null)
|
||||||
const [recencyInSeconds, setRecencyInSeconds] = useState<number | null>(null)
|
const [recencyInSeconds, setRecencyInSeconds] = useState<number | null>(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener("scroll", handleScroll)
|
||||||
|
return () => window.removeEventListener("scroll", handleScroll);
|
||||||
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (username)
|
if (username)
|
||||||
fetchProfile(username as string)
|
fetchProfile(username as string)
|
||||||
|
|
@ -93,16 +98,6 @@ const ProfileRoute: React.FC = () => {
|
||||||
setRecencyInSeconds(null)
|
setRecencyInSeconds(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
|
||||||
const content = (parties && parties.length > 0) ? renderGrids() : renderNoGrids()
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<ProfileHeader username={user.username} gender={true} />
|
|
||||||
{content}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleScroll() {
|
function handleScroll() {
|
||||||
if (window.pageYOffset > 90)
|
if (window.pageYOffset > 90)
|
||||||
setScrolled(true)
|
setScrolled(true)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue