james changes
This commit is contained in:
parent
54b031ac35
commit
5aa889fb08
|
@ -7,15 +7,14 @@ export function ScrollToTopButton(props: { className?: string }) {
|
|||
const { className } = props
|
||||
const [visible, setVisible] = useState(false)
|
||||
|
||||
const onScroll = () => {
|
||||
if (window.scrollY > 500) {
|
||||
setVisible(true)
|
||||
} else {
|
||||
setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const onScroll = () => {
|
||||
if (window.scrollY > 500) {
|
||||
setVisible(true)
|
||||
} else {
|
||||
setVisible(false)
|
||||
}
|
||||
}
|
||||
window.addEventListener('scroll', onScroll, { passive: true })
|
||||
|
||||
return () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user