Skip to content

Commit

Permalink
feat: support pageup/pagedown to scroll up/down
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Sep 10, 2024
1 parent 2412d59 commit 6e0c3bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/renderer/src/constants/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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: {
Expand Down
10 changes: 10 additions & 0 deletions src/renderer/src/modules/entry-content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 6e0c3bc

Please sign in to comment.