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