3737 </div >
3838 </transition >
3939 </div >
40- <div id =" container-scroll" >
40+ <div ref = " scrollContainer " class =" container-scroll" >
4141 <div class =" messages-container" >
4242 <chat-loader :show =" loadingMessages" ></chat-loader >
4343 <transition name =" fade-message" >
@@ -258,14 +258,12 @@ export default {
258258 if (e .keyCode === 13 && ! e .shiftKey ) this .sendMessage ()
259259 })
260260
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+ })
269267
270268 const emojisTable = Object .keys (emojis).map (key => emojis[key])
271269 this .emojisList = Object .assign ({}, ... emojisTable)
@@ -281,7 +279,7 @@ export default {
281279 this .resetMessage ()
282280 },
283281 messages (newVal , oldVal ) {
284- const element = document . getElementById ( ' container-scroll ' )
282+ const element = this . $refs . scrollContainer
285283 if (! element) return
286284
287285 const options = { top: element .scrollHeight }
@@ -418,7 +416,7 @@ export default {
418416 setTimeout (() => this .resizeTextarea (this .$refs [' roomTextarea' ]), 0 )
419417 },
420418 scrollToBottom () {
421- const element = document . getElementById ( ' container-scroll ' )
419+ const element = this . $refs . scrollContainer
422420 element .scrollTo ({ top: element .scrollHeight , behavior: ' smooth' })
423421 },
424422 autoGrow (el ) {
@@ -519,7 +517,7 @@ export default {
519517 margin-left : auto ;
520518}
521519
522- # container-scroll {
520+ . container-scroll {
523521 background : var (--chat-content-bg-color );
524522 height : calc (100% - 110px );
525523 overflow-y : auto ;
0 commit comments