diff --git a/interface/resources/html/raiseAndLowerKeyboard.js b/interface/resources/html/raiseAndLowerKeyboard.js index 84a166ace3..a4138d1627 100644 --- a/interface/resources/html/raiseAndLowerKeyboard.js +++ b/interface/resources/html/raiseAndLowerKeyboard.js @@ -12,6 +12,7 @@ var MAX_WARNINGS = 3; var numWarnings = 0; var isKeyboardRaised = false; + var KEYBOARD_HEIGHT = 200; function shouldRaiseKeyboard() { if (document.activeElement.nodeName == "INPUT" || document.activeElement.nodeName == "TEXTAREA") { @@ -31,6 +32,15 @@ setInterval(function () { if (isKeyboardRaised !== shouldRaiseKeyboard()) { isKeyboardRaised = !isKeyboardRaised; + + if (isKeyboardRaised) { + var delta = document.activeElement.getBoundingClientRect().bottom + 10 + - (document.body.clientHeight - KEYBOARD_HEIGHT); + if (delta > 0) { + document.body.scrollTop += delta; + } + } + if (typeof EventBridge != "undefined") { EventBridge.emitWebEvent(isKeyboardRaised ? "_RAISE_KEYBOARD" : "_LOWER_KEYBOARD"); } else { diff --git a/scripts/system/html/js/keyboardControl.js b/scripts/system/html/js/keyboardControl.js index e33b0c8159..4041687c25 100644 --- a/scripts/system/html/js/keyboardControl.js +++ b/scripts/system/html/js/keyboardControl.js @@ -11,18 +11,33 @@ function setUpKeyboardControl() { var lowerTimer = null; + var isRaised = false; + var KEYBOARD_HEIGHT = 200; function raiseKeyboard() { if (lowerTimer !== null) { clearTimeout(lowerTimer); lowerTimer = null; } + + if (isRaised) { + return; + } + + var delta = this.getBoundingClientRect().bottom + 10 - (document.body.clientHeight - KEYBOARD_HEIGHT); + if (delta > 0) { + document.body.scrollTop += delta; + } + EventBridge.emitWebEvent("_RAISE_KEYBOARD"); + + isRaised = true; } function doLowerKeyboard() { EventBridge.emitWebEvent("_LOWER_KEYBOARD"); lowerTimer = null; + isRaised = false; } function lowerKeyboard() {