mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 03:04:40 +02:00
Only scroll keyboard if necessary
This commit is contained in:
parent
dd8eac8cb2
commit
03da2f0946
1 changed files with 7 additions and 8 deletions
|
@ -44,15 +44,14 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
function scheduleBringToView(timeout) {
|
function scheduleBringToView(timeout) {
|
||||||
|
setTimeout(function () {
|
||||||
var timer = setTimeout(function () {
|
// If the element is not visible because the keyboard has been raised over the top of it, scroll it into view.
|
||||||
clearTimeout(timer);
|
|
||||||
|
|
||||||
var elementRect = document.activeElement.getBoundingClientRect();
|
var elementRect = document.activeElement.getBoundingClientRect();
|
||||||
var absoluteElementTop = elementRect.top + window.scrollY;
|
var VISUAL_MARGIN = 3
|
||||||
var middle = absoluteElementTop - (window.innerHeight / 2);
|
var delta = elementRect.y + elementRect.height + VISUAL_MARGIN - window.innerHeight;
|
||||||
|
if (delta > 0) {
|
||||||
window.scrollTo(0, middle);
|
window.scrollBy(0, delta);
|
||||||
|
}
|
||||||
}, timeout);
|
}, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue