mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 13:45:25 +03:00
Handle page and arrow keys
This commit is contained in:
parent
0306391681
commit
b5a6413ad3
@ -20,6 +20,7 @@ import ActivityIndicator from "@/components/indicators/activity-indicator";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { MdVerticalAlignBottom } from "react-icons/md";
|
import { MdVerticalAlignBottom } from "react-icons/md";
|
||||||
import { parseLogLines } from "@/utils/logUtil";
|
import { parseLogLines } from "@/utils/logUtil";
|
||||||
|
import useKeyboardListener from "@/hooks/use-keyboard-listener";
|
||||||
|
|
||||||
type LogRange = { start: number; end: number };
|
type LogRange = { start: number; end: number };
|
||||||
|
|
||||||
@ -226,6 +227,40 @@ function Logs() {
|
|||||||
|
|
||||||
const [selectedLog, setSelectedLog] = useState<LogLine>();
|
const [selectedLog, setSelectedLog] = useState<LogLine>();
|
||||||
|
|
||||||
|
// interaction
|
||||||
|
|
||||||
|
useKeyboardListener(
|
||||||
|
["PageDown", "PageUp", "ArrowDown", "ArrowUp"],
|
||||||
|
(key, down, _) => {
|
||||||
|
if (!down) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case "PageDown":
|
||||||
|
contentRef.current?.scrollBy({
|
||||||
|
top: 480,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "PageUp":
|
||||||
|
contentRef.current?.scrollBy({
|
||||||
|
top: -480,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "ArrowDown":
|
||||||
|
contentRef.current?.scrollBy({
|
||||||
|
top: 48,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "ArrowUp":
|
||||||
|
contentRef.current?.scrollBy({
|
||||||
|
top: -48,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex size-full flex-col p-2">
|
<div className="flex size-full flex-col p-2">
|
||||||
<Toaster position="top-center" closeButton={true} />
|
<Toaster position="top-center" closeButton={true} />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user