Skip to content

Commit 63a24ad

Browse files
committed
(fix) assign scrollHeight when DOM is loaded
1 parent dc7140b commit 63a24ad

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/ChatWindow/Room.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,9 @@ export default {
350350
const element = this.$refs.scrollContainer
351351
if (!element) return
352352
353-
const options = { top: element.scrollHeight }
354-
355353
if (oldVal && newVal && oldVal.length === newVal.length - 1) {
356354
return setTimeout(() => {
357-
options.behavior = 'smooth'
355+
const options = { top: element.scrollHeight, behavior: 'smooth' }
358356
element.scrollTo(options)
359357
}, 50)
360358
}
@@ -364,7 +362,7 @@ export default {
364362
setTimeout(() => (this.loadingMoreMessages = false), 0)
365363
} else if (newVal.length) {
366364
setTimeout(() => {
367-
element.scrollTo(options)
365+
element.scrollTo({ top: element.scrollHeight })
368366
this.loadingMessages = false
369367
}, 0)
370368
}

0 commit comments

Comments
 (0)