fix: ios键盘遮挡输入框的问题

This commit is contained in:
kuaifan 2022-05-12 08:31:51 +08:00
parent 117fd62c44
commit ece17b2aee
2 changed files with 30 additions and 0 deletions

View File

@ -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;

View File

@ -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 scrollTopscrolIntoViewbug
//
} 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;
}
}
}
</script>