feat: sticky list mode switcher

This commit is contained in:
codytseng
2025-01-24 16:53:01 +08:00
parent ee21e19625
commit 1df975dfc6
7 changed files with 175 additions and 183 deletions

View File

@@ -1,21 +1,22 @@
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
import { useDeepBrowsing } from '@/providers/DeepBrowsingProvider'
import { useScreenSize } from '@/providers/ScreenSizeProvider'
import { ChevronUp } from 'lucide-react'
export default function ScrollToTopButton({
scrollAreaRef,
className,
visible = true
className
}: {
scrollAreaRef: React.RefObject<HTMLDivElement>
scrollAreaRef?: React.RefObject<HTMLDivElement>
className?: string
visible?: boolean
}) {
const { isSmallScreen } = useScreenSize()
const { deepBrowsing, lastScrollTop } = useDeepBrowsing()
const visible = !deepBrowsing && lastScrollTop > 800
const handleScrollToTop = () => {
if (isSmallScreen) {
if (!scrollAreaRef) {
window.scrollTo({ top: 0, behavior: 'smooth' })
return
}