Skip to content

Commit

Permalink
fix: scroll state for mobile float bar
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Nov 28, 2024
1 parent 5bbfb2d commit 126206b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/renderer/src/modules/app-layout/entry-column/mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useGeneralSettingKey } from "~/atoms/settings/general"
import { ROUTE_FEED_PENDING } from "~/constants/app"
import { ENTRY_COLUMN_LIST_SCROLLER_ID, LOGO_MOBILE_ID } from "~/constants/dom"
import { navigateEntry } from "~/hooks/biz/useNavigateEntry"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
import { usePreventOverscrollBounce } from "~/hooks/common"
import { EntryColumn } from "~/modules/entry-column"

Expand All @@ -13,14 +14,15 @@ export const EntryColumnMobile = () => {
const isStartupTimeline = useGeneralSettingKey("startupScreen") === "timeline"

const [scrollContainer, setScrollContainer] = useState<null | HTMLDivElement>(null)
const view = useRouteParamsSelector((s) => s.view)
useEffect(() => {
const timer = setTimeout(() => {
setScrollContainer(
document.querySelector(`#${ENTRY_COLUMN_LIST_SCROLLER_ID}`) as HTMLDivElement,
)
}, 1000)
return () => clearTimeout(timer)
}, [])
}, [view])
usePreventOverscrollBounce()
return (
<div className="flex h-screen min-w-0 grow">
Expand Down
10 changes: 8 additions & 2 deletions apps/renderer/src/modules/entry-column/wrapper.mobile.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ScrollElementContext } from "@follow/components/ui/scroll-area/ctx.js"
import { views } from "@follow/constants"
import { FeedViewType, views } from "@follow/constants"
import { clsx } from "clsx"
import { forwardRef, useState } from "react"

import { PullToRefresh } from "~/components/ux/pull-to-refresh"
import { ENTRY_COLUMN_LIST_SCROLLER_ID } from "~/constants/dom"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"

import type { EntryColumnWrapperProps } from "./wrapper.shared"
Expand All @@ -21,7 +22,12 @@ export const EntryColumnWrapper = forwardRef<HTMLDivElement, EntryColumnWrapperP
<div ref={ref} className={clsx("grow overflow-hidden", views[view].wideMode ? "mt-2" : "")}>
<PullToRefresh className="h-full" onRefresh={onPullToRefresh || noop}>
<ScrollElementContext.Provider value={scrollElement}>
<div className="h-full overflow-y-auto" ref={setScrollElement}>
<div
className="h-full overflow-y-auto"
ref={setScrollElement}
// PictureMasonry do not have this id from VirtuosoGrid
id={view === FeedViewType.Pictures ? ENTRY_COLUMN_LIST_SCROLLER_ID : undefined}
>
{children}
</div>
</ScrollElementContext.Provider>
Expand Down

0 comments on commit 126206b

Please sign in to comment.