File tree Expand file tree Collapse file tree
apps/meteor/client/views/room/MessageList Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ type MessageListProps = {
4343 handleDateScroll : ( topMessage : IMessage | undefined ) => void ;
4444} ;
4545
46- let lastViewportSize = 0 ;
46+ let lastScrollSize = 0 ;
4747
4848export const MessageList = function MessageList ( {
4949 rid,
@@ -84,7 +84,14 @@ export const MessageList = function MessageList({
8484 isPrepend . current = true ;
8585 }
8686
87- isAtBottom . current = offset - ( virtualizerRef . current ?. scrollSize ?? 0 ) + ( virtualizerRef . current ?. viewportSize ?? 0 ) >= - 20 ;
87+ const scrollSize = virtualizerRef . current ?. scrollSize ?? 0 ;
88+ const viewportSize = virtualizerRef . current ?. viewportSize ?? 0 ;
89+
90+ if ( scrollSize >= viewportSize ) {
91+ isAtBottom . current = true ;
92+ }
93+
94+ isAtBottom . current = offset - scrollSize + viewportSize >= - 60 ;
8895 if ( shouldJumpToBottom . current && isAtBottom . current ) {
8996 shouldJumpToBottom . current = false ;
9097 }
@@ -138,8 +145,8 @@ export const MessageList = function MessageList({
138145 } ) ;
139146 }
140147 // If new messages arrive and is at bottom, scroll to keep at bottom
141- if ( isAtBottom . current && lastViewportSize !== handle ?. viewportSize ) {
142- lastViewportSize = handle ?. viewportSize ?? 0 ;
148+ if ( isAtBottom . current && lastScrollSize !== handle ?. scrollSize ) {
149+ lastScrollSize = handle ?. scrollSize ?? 0 ;
143150 handle ?. scrollToIndex ( lastItemIndex + 1 , {
144151 align : 'end' ,
145152 } ) ;
You can’t perform that action at this time.
0 commit comments