From 438f74fac918240342e1ba6ba888c5ae8ff8ab53 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Mon, 14 Jun 2021 17:52:17 +0800 Subject: [PATCH] no message --- resources/assets/js/components/ScrollerY.vue | 9 ++++++++- resources/assets/js/pages/manage/messenger.vue | 12 ++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/components/ScrollerY.vue b/resources/assets/js/components/ScrollerY.vue index a81d857b..c6cdf15a 100644 --- a/resources/assets/js/components/ScrollerY.vue +++ b/resources/assets/js/components/ScrollerY.vue @@ -124,7 +124,14 @@ export default { autoToBottom() { if (this.autoBottom && this.$refs.bottom) { - this.$refs.bottom.scrollIntoView(false); + try { + this.$refs.bottom.scrollIntoView(false); + } catch (e) { + scrollIntoView(this.$refs.bottom, { + behavior: 'instant', + inline: 'end', + }) + } } }, diff --git a/resources/assets/js/pages/manage/messenger.vue b/resources/assets/js/pages/manage/messenger.vue index 7f8e0353..7ca7fd12 100644 --- a/resources/assets/js/pages/manage/messenger.vue +++ b/resources/assets/js/pages/manage/messenger.vue @@ -14,7 +14,7 @@ v-for="(dialog, key) in dialogLists" :key="key" :class="{active: dialog.id == dialogId}" - @click="openDialog(dialog)"> + @click="openDialog(dialog, true)">
@@ -122,17 +122,17 @@ export default { }, methods: { - openDialog(dialog) { + openDialog(dialog, smooth) { this.$store.state.method.setStorage("messengerDialogId", dialog.id) this.$store.dispatch("getDialogMsgList", dialog.id); - this.scrollIntoActive(); + this.scrollIntoActive(smooth); }, openDialogStorage() { let tmpId = this.$store.state.method.getStorageInt("messengerDialogId") if (tmpId > 0) { const dialog = this.dialogList.find(({id}) => id === tmpId); - dialog && this.openDialog(dialog); + dialog && this.openDialog(dialog, false); } }, @@ -214,13 +214,13 @@ export default { return null; }, - scrollIntoActive() { + scrollIntoActive(smooth) { this.$nextTick(() => { if (this.$refs.list) { let active = this.$refs.list.querySelector(".active") if (active) { scrollIntoView(active, { - behavior: 'instant', + behavior: smooth === true ? 'smooth' : 'instant', scrollMode: 'if-needed', }); }