File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
frontend/src/app/collaboration/components Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -117,9 +117,22 @@ const Question = ({
117
117
} , [ collaboratorId ] ) ;
118
118
119
119
useEffect ( ( ) => {
120
+ const scrollToPercentage = ( percentage : number ) => {
121
+ if ( chatLogsListRef . current && hasMoreMessages . current ) {
122
+ const chatContainer = chatLogsListRef . current ;
123
+ const targetPosition = chatContainer . scrollHeight * percentage ;
124
+ chatContainer . scrollTop = targetPosition - chatContainer . clientHeight ;
125
+ }
126
+ } ;
127
+
120
128
const handleScroll = ( ) => {
121
129
if ( chatLogsListRef . current && chatLogsListRef . current . scrollTop === 0 ) {
122
- fetchChatLogs ( ) ;
130
+ fetchChatLogs ( ) . then ( ( ) => {
131
+ requestAnimationFrame ( ( ) => {
132
+ const percentage = Math . min ( 1 - ( chatLogsPage - 1 ) / chatLogsPage ) ;
133
+ scrollToPercentage ( percentage ) ;
134
+ } ) ;
135
+ } ) ;
123
136
}
124
137
} ;
125
138
You can’t perform that action at this time.
0 commit comments