From ece17b2aeec557295a4183e18c2dfe1e154336eb Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 12 May 2022 08:31:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ios=E9=94=AE=E7=9B=98=E9=81=AE=E6=8C=A1?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/functions/common.js | 5 ++++ .../manage/components/ChatInput/index.vue | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/resources/assets/js/functions/common.js b/resources/assets/js/functions/common.js index a2d0bf556..4a3e7891b 100755 --- a/resources/assets/js/functions/common.js +++ b/resources/assets/js/functions/common.js @@ -993,6 +993,11 @@ if (!element) { return; } + if (typeof options === "undefined" || options === true) { + options = {block: "start", inline: "nearest"} + } else if (options === false) { + options = {block: "end", inline: "nearest"} + } if (typeof options.scrollMode !== "undefined" && typeof window.scrollIntoView === "function") { window.scrollIntoView(element, options) return; diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index 76281ed04..9198d8980 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -116,6 +116,9 @@ export default { observer: null, wrapperWidth: 0, editorHeight: 0, + + timerScroll: null, + isSpecVersion: this.checkIOSVersion(), }; }, mounted() { @@ -295,10 +298,24 @@ export default { // Mark model as touched if editor lost focus this.quill.on('selection-change', range => { + if (this.timerScroll) { + clearInterval(this.timerScroll); + } if (!range) { this.$emit('on-blur', this.quill) } else { this.$emit('on-focus', this.quill) + if (this.isSpecVersion) { + // ios11.0-11.3 对scrollTop及scrolIntoView解释有bug + // 直接执行会导致输入框滚到底部被遮挡 + } else { + setTimeout(() => { + $A.scrollToView(this.$refs.editor, true) + this.timerScroll = setInterval(() => { + $A.scrollToView(this.$refs.editor, true) + }, 300); + }, 300); + } } }) @@ -554,6 +571,14 @@ export default { } }) }, + + checkIOSVersion() { + let ua = window && window.navigator && window.navigator.userAgent; + let match = ua.match(/OS ((\d+_?){2,3})\s/i); + let IOSVersion = match ? match[1].replace(/_/g, ".") : "unknown"; + const iosVsn = IOSVersion.split("."); + return +iosVsn[0] == 11 && +iosVsn[1] >= 0 && +iosVsn[1] < 3; + } } }