From c952a0c720160a0c5bd121ea14b13080027c74e9 Mon Sep 17 00:00:00 2001 From: Yuan <294065614@qq.com> Date: Thu, 14 Mar 2024 19:17:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A7=E5=88=B6=E5=8F=B0?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/src/AutoRotation.js | 2 +- sdk/src/DirectionHandler.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sdk/src/AutoRotation.js b/sdk/src/AutoRotation.js index 23ad772..27b5430 100644 --- a/sdk/src/AutoRotation.js +++ b/sdk/src/AutoRotation.js @@ -278,7 +278,7 @@ export default class AutoRotation { if (this.directionHandler) { const keyboardEle = document.getElementById('keyboardInputContent'); - const currentDisplay = keyboardEle.style.display; + const currentDisplay = keyboardEle?.style?.display; this.directionHandler.update(this.orientation, this.displayBox, currentDisplay); } } diff --git a/sdk/src/DirectionHandler.js b/sdk/src/DirectionHandler.js index 05f0180..7521321 100644 --- a/sdk/src/DirectionHandler.js +++ b/sdk/src/DirectionHandler.js @@ -63,14 +63,16 @@ class DirectionHandler { let ctrlEleLeft = (this.containerEle.clientWidth - this.displayBox.width)/2 + this.ctrlEle.clientWidth/2; let ctrlEleTop = (this.containerEle.clientHeight - this.displayBox.height)/2 + this.netWorkInfo.clientHeight * 2.5; this.portraitAndportrait(ctrlEleLeft, ctrlEleTop); - this.keyboardInputContent.style.cssText = ` + if (this.keyboardInputContent) { + this.keyboardInputContent.style.cssText = ` display: ${this.currentDisplay ? this.currentDisplay : 'none'}; position: absolute; bottom: 5px; left: 0px; height: 0px; width: 10px; - `; + `; + } break; case PROTOCOL_CONFIG.ORIENTATION[16]: const keyboardInputLeft = this.containerEle.clientWidth; @@ -95,14 +97,16 @@ class DirectionHandler { let ctrlEleLeft = this.ctrlEle.clientWidth/2; let ctrlEleTop = this.netWorkInfo.clientHeight * 2.5; this.portraitAndportrait(ctrlEleLeft, ctrlEleTop); - this.keyboardInputContent.style.cssText = ` + if (this.keyboardInputContent) { + this.keyboardInputContent.style.cssText = ` display: ${this.currentDisplay ? this.currentDisplay : 'none'}; position: absolute; top: 50%; left: 0px; height: 40px; width: 100%; - `; + `; + } break; case PROTOCOL_CONFIG.ORIENTATION[16]: const keyboardInputLeft = this.containerEle.clientWidth; @@ -595,15 +599,16 @@ class DirectionHandler { border-radius: 5px; transform: translate(-50%, -50%); `; - - this.keyboardInputContent.style.cssText = ` + if (this.keyboardInputContent) { + this.keyboardInputContent.style.cssText = ` display: none; position: absolute; bottom: 5px; left: 0px; height: 40px; width: 100%; - `; + `; + } const left = (this.containerEle.clientWidth - this.displayBox.width)/2 + this.ctrlEle.clientWidth/2; const top = (this.containerEle.clientHeight - this.displayBox.height)/2 + this.netWorkInfo.clientHeight * 2.5; -- Gitee