feat: support pageup/pagedown to scroll up/down

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-09-10 19:28:14 +08:00
parent 2412d59e3e
commit 6e0c3bc5e3
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
2 changed files with 18 additions and 12 deletions

View File

@ -2,18 +2,6 @@ import { COPY_MAP } from "@renderer/constants"
export const shortcuts = {
feeds: {
// previous: {
// name: "Previous Subscription",
// key: "P",
// },
// next: {
// name: "Next Subscription",
// key: "N",
// },
// toggleFolder: {
// name: "Toggle Folder",
// key: "X",
// },
add: {
name: "Add Subscription",
key: "Meta+T",
@ -85,6 +73,14 @@ export const shortcuts = {
name: "Share",
key: "Meta+Alt+S",
},
scrollUp: {
name: "Scroll Up",
key: "PageUp",
},
scrollDown: {
name: "Scroll Down",
key: "PageDown",
},
},
audio: {

View File

@ -16,6 +16,7 @@ import { useInPeekModal } from "@renderer/components/ui/modal/inspire/PeekModal"
import { RootPortal } from "@renderer/components/ui/portal"
import { ScrollArea } from "@renderer/components/ui/scroll-area"
import { isWebBuild, ROUTE_FEED_PENDING } from "@renderer/constants"
import { shortcuts } from "@renderer/constants/shortcuts"
import { useEntryReadabilityToggle } from "@renderer/hooks/biz/useEntryActions"
import { useRouteParamsSelector, useRouteParms } from "@renderer/hooks/biz/useRouteParams"
import { useAuthQuery, useTitle } from "@renderer/hooks/common"
@ -36,6 +37,7 @@ import type { FallbackRender } from "@sentry/react"
import { ErrorBoundary } from "@sentry/react"
import type { FC } from "react"
import { useEffect, useLayoutEffect, useRef } from "react"
import { useHotkeys } from "react-hotkeys-hook"
import { LoadingWithIcon } from "../../components/ui/loading"
import { EntryPlaceholderDaily } from "../ai/ai-daily/EntryPlaceholderDaily"
@ -125,6 +127,14 @@ export const EntryContentRender: Component<{ entryId: string }> = ({ entryId, cl
scrollerRef.current?.scrollTo(0, 0)
}, [entryId])
useHotkeys(shortcuts.entry.scrollDown.key, () => {
scrollerRef.current?.scrollBy(0, window.innerHeight / 2)
})
useHotkeys(shortcuts.entry.scrollUp.key, () => {
scrollerRef.current?.scrollBy(0, -window.innerHeight / 2)
})
const isPeekModal = useInPeekModal()
if (!entry) return null