From 5974761ef58e4a539c0c44e532c3dae36a19438d Mon Sep 17 00:00:00 2001 From: Hepatica Date: Sat, 27 Jan 2024 03:30:22 +0100 Subject: [PATCH] Test scroll bar logic --- luckydiamond/src/components/ChatComponent.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/luckydiamond/src/components/ChatComponent.vue b/luckydiamond/src/components/ChatComponent.vue index 2e95057..7e55751 100644 --- a/luckydiamond/src/components/ChatComponent.vue +++ b/luckydiamond/src/components/ChatComponent.vue @@ -46,6 +46,12 @@ export default { }; }, methods: { + ScrollToBottom() { + this.$nextTick(() => { + const chatContent = this.$el.querySelector(".chat__content--users"); + chatContent.scrollTop = chatContent.scrollHeight; + }); + }, ClaimDatamsg(msg) { SendMessageToChat(msg[0]); @@ -70,6 +76,8 @@ export default { }; this.array.push(MsgUser); + + // this.ScrollToBottom(); } catch (error) { console.error("Error parsing JSON data:", error); } @@ -78,8 +86,7 @@ export default { created() { GetChatHistory().then((response) => { response.forEach((element) => { - let imageUrl = - "https://avatar.spworlds.ru/face/55/" + element.userName; + let imageUrl = "https://avatar.spworlds.ru/face/55/" + element.userName; const MsgUser = { id: this.id + 1, @@ -90,6 +97,7 @@ export default { this.array.push(MsgUser); }); + this.ScrollToBottom(); }); }, };