Browse Source

fix: ios页面无法滚动的bug

master
xsx 7 months ago
parent
commit
20b8fb2397
  1. 22
      im-uniapp/pages/chat/chat-box.vue

22
im-uniapp/pages/chat/chat-box.vue

@ -866,12 +866,13 @@ export default {
return;
}
if (uni.getSystemInfoSync().platform == 'ios') {
// ios h5
window.addEventListener('focusin', this.focusInListener);
window.addEventListener('focusout', this.focusOutListener);
// ios13
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', this.resizeListener);
} else {
// ios h5
window.addEventListener('focusin', this.focusInListener);
window.addEventListener('focusout', this.focusOutListener);
}
} else {
// h5
@ -885,9 +886,12 @@ export default {
},
unListenKeyboard() {
// #ifdef H5
window.removeEventListener('resize', this.resizeListener);
window.removeEventListener('focusin', this.focusInListener);
window.removeEventListener('focusout', this.focusOutListener);
window.removeEventListener('resize', this.resizeListener);
if (window.visualViewport) {
window.visualViewport.removeEventListener('resize', this.resizeListener);
}
// #endif
// #ifndef H5
uni.offKeyboardHeightChange(this.keyBoardListener);
@ -906,12 +910,14 @@ export default {
if (window.visualViewport && uni.getSystemInfoSync().platform == 'ios') {
keyboardHeight = this.initHeight - window.visualViewport.height;
}
console.log("resizeListener:", window.visualViewport.height)
this.isShowKeyBoard = keyboardHeight > 150;
if (this.isShowKeyBoard) {
let isShowKeyBoard = keyboardHeight > 150;
if (isShowKeyBoard) {
this.keyboardHeight = keyboardHeight;
}
setTimeout(() => this.reCalChatMainHeight(), 30);
if (this.isShowKeyBoard != isShowKeyBoard) {
this.isShowKeyBoard = isShowKeyBoard;
setTimeout(() => this.reCalChatMainHeight(), 30);
}
},
focusInListener() {
this.isShowKeyBoard = true;

Loading…
Cancel
Save