mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:00:44 +02:00
Scroll HTML window if necessary when raise keyboard
This commit is contained in:
parent
a94d77ee12
commit
b60f649e0a
2 changed files with 25 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
||||||
var MAX_WARNINGS = 3;
|
var MAX_WARNINGS = 3;
|
||||||
var numWarnings = 0;
|
var numWarnings = 0;
|
||||||
var isKeyboardRaised = false;
|
var isKeyboardRaised = false;
|
||||||
|
var KEYBOARD_HEIGHT = 200;
|
||||||
|
|
||||||
function shouldRaiseKeyboard() {
|
function shouldRaiseKeyboard() {
|
||||||
if (document.activeElement.nodeName == "INPUT" || document.activeElement.nodeName == "TEXTAREA") {
|
if (document.activeElement.nodeName == "INPUT" || document.activeElement.nodeName == "TEXTAREA") {
|
||||||
|
@ -31,6 +32,15 @@
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
if (isKeyboardRaised !== shouldRaiseKeyboard()) {
|
if (isKeyboardRaised !== shouldRaiseKeyboard()) {
|
||||||
isKeyboardRaised = !isKeyboardRaised;
|
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") {
|
if (typeof EventBridge != "undefined") {
|
||||||
EventBridge.emitWebEvent(isKeyboardRaised ? "_RAISE_KEYBOARD" : "_LOWER_KEYBOARD");
|
EventBridge.emitWebEvent(isKeyboardRaised ? "_RAISE_KEYBOARD" : "_LOWER_KEYBOARD");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,18 +11,33 @@
|
||||||
function setUpKeyboardControl() {
|
function setUpKeyboardControl() {
|
||||||
|
|
||||||
var lowerTimer = null;
|
var lowerTimer = null;
|
||||||
|
var isRaised = false;
|
||||||
|
var KEYBOARD_HEIGHT = 200;
|
||||||
|
|
||||||
function raiseKeyboard() {
|
function raiseKeyboard() {
|
||||||
if (lowerTimer !== null) {
|
if (lowerTimer !== null) {
|
||||||
clearTimeout(lowerTimer);
|
clearTimeout(lowerTimer);
|
||||||
lowerTimer = null;
|
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");
|
EventBridge.emitWebEvent("_RAISE_KEYBOARD");
|
||||||
|
|
||||||
|
isRaised = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function doLowerKeyboard() {
|
function doLowerKeyboard() {
|
||||||
EventBridge.emitWebEvent("_LOWER_KEYBOARD");
|
EventBridge.emitWebEvent("_LOWER_KEYBOARD");
|
||||||
lowerTimer = null;
|
lowerTimer = null;
|
||||||
|
isRaised = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function lowerKeyboard() {
|
function lowerKeyboard() {
|
||||||
|
|
Loading…
Reference in a new issue