prevent scroll from stopping above when decrypting messages change view
height
This commit is contained in:
parent
f7a610adaf
commit
cfde8f20ee
2 changed files with 6 additions and 4 deletions
|
|
@ -201,6 +201,7 @@ export function RoomTimeline({ eventId, roomInputRef, editor, timeline }: RoomTi
|
|||
const { markerTs } = useUnreadMarker(atBottomLazy, focused, readReceipt?.ts);
|
||||
|
||||
useTimelineContainerResizeStickBottom(
|
||||
timeline,
|
||||
getScrollElement,
|
||||
useCallback(() => timelineContainerRef.current, []),
|
||||
atBottomObservable,
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ export const useRestoreScrollToBottom = (
|
|||
};
|
||||
|
||||
export const useTimelineContainerResizeStickBottom = (
|
||||
timeline: TimelineView,
|
||||
getScrollElement: () => HTMLElement | null,
|
||||
getContainerElement: () => HTMLElement | null,
|
||||
atBottomObservable: ObservableValue<boolean>,
|
||||
|
|
@ -199,12 +200,12 @@ export const useTimelineContainerResizeStickBottom = (
|
|||
if (!containerEntry || !scrollElement) return;
|
||||
|
||||
if (atBottomObservable.read) {
|
||||
requestAnimationFrame(() => {
|
||||
scrollToBottom(scrollElement, 'smooth');
|
||||
});
|
||||
const batchChange = timeline.batch.read.change;
|
||||
const messageArrived = batchChange.type === 'Grow' && batchChange.dir === 'f';
|
||||
scrollToBottom(scrollElement, messageArrived ? 'smooth' : 'instant');
|
||||
}
|
||||
};
|
||||
}, [getContainerElement, getScrollElement, atBottomObservable]),
|
||||
}, [timeline, getContainerElement, getScrollElement, atBottomObservable]),
|
||||
enable ? getContainerElement : undefined
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue