mirror of
https://github.com/docmost/docmost.git
synced 2026-05-25 03:42:44 +08:00
scroll
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
|||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import HistoryList from "@/features/page-history/components/history-list";
|
import HistoryList from "@/features/page-history/components/history-list";
|
||||||
import classes from "./history.module.css";
|
import classes from "./history.module.css";
|
||||||
import { useAtom, useSetAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import {
|
import {
|
||||||
activeHistoryIdAtom,
|
activeHistoryIdAtom,
|
||||||
activeHistoryPrevIdAtom,
|
activeHistoryPrevIdAtom,
|
||||||
@@ -30,8 +30,7 @@ export default function HistoryModalBody({ pageId }: Props) {
|
|||||||
activeHistoryPrevIdAtom,
|
activeHistoryPrevIdAtom,
|
||||||
);
|
);
|
||||||
const [highlightChanges, setHighlightChanges] = useAtom(highlightChangesAtom);
|
const [highlightChanges, setHighlightChanges] = useAtom(highlightChangesAtom);
|
||||||
const [diffCounts] = useAtom(diffCountsAtom);
|
const [diffCounts, setDiffCounts] = useAtom(diffCountsAtom);
|
||||||
const [, setDiffCounts] = useAtom(diffCountsAtom);
|
|
||||||
|
|
||||||
const [currentChangeIndex, setCurrentChangeIndex] = useState(0);
|
const [currentChangeIndex, setCurrentChangeIndex] = useState(0);
|
||||||
const scrollViewportRef = useRef<HTMLDivElement>(null);
|
const scrollViewportRef = useRef<HTMLDivElement>(null);
|
||||||
@@ -44,8 +43,13 @@ export default function HistoryModalBody({ pageId }: Props) {
|
|||||||
}, [pageId]);
|
}, [pageId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrentChangeIndex(0);
|
if (diffCounts && diffCounts.total > 0) {
|
||||||
}, [activeHistoryId]);
|
setCurrentChangeIndex(1);
|
||||||
|
requestAnimationFrame(() => scrollToChangeIndex(1));
|
||||||
|
} else {
|
||||||
|
setCurrentChangeIndex(0);
|
||||||
|
}
|
||||||
|
}, [diffCounts]);
|
||||||
|
|
||||||
const scrollToChangeIndex = (index: number) => {
|
const scrollToChangeIndex = (index: number) => {
|
||||||
const viewport = scrollViewportRef.current;
|
const viewport = scrollViewportRef.current;
|
||||||
|
|||||||
Reference in New Issue
Block a user