37
37
</div >
38
38
</transition >
39
39
</div >
40
- <div id =" container-scroll" >
40
+ <div ref = " scrollContainer " class =" container-scroll" >
41
41
<div class =" messages-container" >
42
42
<chat-loader :show =" loadingMessages" ></chat-loader >
43
43
<transition name =" fade-message" >
@@ -258,14 +258,12 @@ export default {
258
258
if (e .keyCode === 13 && ! e .shiftKey ) this .sendMessage ()
259
259
})
260
260
261
- document
262
- .getElementById (' container-scroll' )
263
- .addEventListener (' scroll' , e => {
264
- this .hideOptions = true
265
- this .scrollIcon =
266
- e .target .scrollHeight > 500 &&
267
- e .target .scrollHeight - e .target .scrollTop > 1000
268
- })
261
+ this .$refs .scrollContainer .addEventListener (' scroll' , e => {
262
+ this .hideOptions = true
263
+ this .scrollIcon =
264
+ e .target .scrollHeight > 500 &&
265
+ e .target .scrollHeight - e .target .scrollTop > 1000
266
+ })
269
267
270
268
const emojisTable = Object .keys (emojis).map (key => emojis[key])
271
269
this .emojisList = Object .assign ({}, ... emojisTable)
@@ -281,7 +279,7 @@ export default {
281
279
this .resetMessage ()
282
280
},
283
281
messages (newVal , oldVal ) {
284
- const element = document . getElementById ( ' container-scroll ' )
282
+ const element = this . $refs . scrollContainer
285
283
if (! element) return
286
284
287
285
const options = { top: element .scrollHeight }
@@ -418,7 +416,7 @@ export default {
418
416
setTimeout (() => this .resizeTextarea (this .$refs [' roomTextarea' ]), 0 )
419
417
},
420
418
scrollToBottom () {
421
- const element = document . getElementById ( ' container-scroll ' )
419
+ const element = this . $refs . scrollContainer
422
420
element .scrollTo ({ top: element .scrollHeight , behavior: ' smooth' })
423
421
},
424
422
autoGrow (el ) {
@@ -519,7 +517,7 @@ export default {
519
517
margin-left : auto ;
520
518
}
521
519
522
- # container-scroll {
520
+ . container-scroll {
523
521
background : var (--chat-content-bg-color );
524
522
height : calc (100% - 110px );
525
523
overflow-y : auto ;
0 commit comments