Skip to content

Commit 8d98fca

Browse files
committed
(fix) auto scroll when loading messages
1 parent 7167bc4 commit 8d98fca

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ChatWindow/Room.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export default {
308308
const options = { top: element.scrollHeight }
309309
310310
if (oldVal && newVal && oldVal.length === newVal.length - 1) {
311-
setTimeout(() => {
311+
return setTimeout(() => {
312312
options.behavior = 'smooth'
313313
element.scrollTo(options)
314314
}, 50)
@@ -317,8 +317,10 @@ export default {
317317
if (this.infiniteState) {
318318
this.infiniteState.loaded()
319319
} else if (newVal.length) {
320-
this.loadingMessages = false
321-
setTimeout(() => element.scrollTo(options), 50)
320+
setTimeout(() => {
321+
element.scrollTo(options)
322+
this.loadingMessages = false
323+
}, 0)
322324
}
323325
},
324326
messagesLoaded(val) {

0 commit comments

Comments
 (0)