mirror of
https://github.com/docmost/docmost.git
synced 2026-05-20 00:14:10 +08:00
mobile scroll
This commit is contained in:
@@ -58,8 +58,15 @@ export default function HistoryModalMobile({ pageId, pageTitle }: Props) {
|
|||||||
|
|
||||||
const [currentChangeIndex, setCurrentChangeIndex] = useState(0);
|
const [currentChangeIndex, setCurrentChangeIndex] = useState(0);
|
||||||
const scrollViewportRef = useRef<HTMLDivElement>(null);
|
const scrollViewportRef = useRef<HTMLDivElement>(null);
|
||||||
|
const dropdownViewportRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const { data: pageHistoryData, isLoading } = usePageHistoryListQuery(pageId);
|
const {
|
||||||
|
data: pageHistoryData,
|
||||||
|
isLoading,
|
||||||
|
fetchNextPage,
|
||||||
|
hasNextPage,
|
||||||
|
isFetchingNextPage,
|
||||||
|
} = usePageHistoryListQuery(pageId);
|
||||||
const { data: activeHistoryData } = usePageHistoryQuery(activeHistoryId);
|
const { data: activeHistoryData } = usePageHistoryQuery(activeHistoryId);
|
||||||
|
|
||||||
const historyItems = useMemo(
|
const historyItems = useMemo(
|
||||||
@@ -113,6 +120,18 @@ export default function HistoryModalMobile({ pageId, pageTitle }: Props) {
|
|||||||
}
|
}
|
||||||
}, [diffCounts]);
|
}, [diffCounts]);
|
||||||
|
|
||||||
|
const handleDropdownScroll = useCallback(() => {
|
||||||
|
const viewport = dropdownViewportRef.current;
|
||||||
|
if (!viewport || !hasNextPage || isFetchingNextPage) return;
|
||||||
|
|
||||||
|
const { scrollTop, scrollHeight, clientHeight } = viewport;
|
||||||
|
const isNearBottom = scrollTop + clientHeight >= scrollHeight - 50;
|
||||||
|
|
||||||
|
if (isNearBottom) {
|
||||||
|
fetchNextPage();
|
||||||
|
}
|
||||||
|
}, [fetchNextPage, hasNextPage, isFetchingNextPage]);
|
||||||
|
|
||||||
const scrollToChangeIndex = (index: number) => {
|
const scrollToChangeIndex = (index: number) => {
|
||||||
const viewport = scrollViewportRef.current;
|
const viewport = scrollViewportRef.current;
|
||||||
if (!viewport || index < 1) return;
|
if (!viewport || index < 1) return;
|
||||||
@@ -212,6 +231,10 @@ export default function HistoryModalMobile({ pageId, pageTitle }: Props) {
|
|||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
comboboxProps={{ withinPortal: false }}
|
comboboxProps={{ withinPortal: false }}
|
||||||
|
scrollAreaProps={{
|
||||||
|
viewportRef: dropdownViewportRef,
|
||||||
|
onScrollPositionChange: handleDropdownScroll,
|
||||||
|
}}
|
||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
/>
|
/>
|
||||||
{diffCounts && (
|
{diffCounts && (
|
||||||
|
|||||||
Reference in New Issue
Block a user