feat: scrollTop 기능 추가 #35
@ -5,9 +5,16 @@ import { usePathname } from 'next/navigation'
|
|||||||
export default function FloatBtn() {
|
export default function FloatBtn() {
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
|
|
||||||
|
const scrollToTop = () => {
|
||||||
|
window.scrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior: 'smooth',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (pathname === '/login' || pathname === '/') {
|
if (pathname === '/login' || pathname === '/') {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return <button className="top-btn"></button>
|
return <button className="top-btn" onClick={scrollToTop}></button>
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user