Fixed the Computer updateFocus() interface to keep the page stable unless fScroll is explicitly set

This commit is contained in:
Jeff Parsons 2016-08-23 14:59:06 -07:00
commit 2b24e710d2
5 changed files with 385 additions and 379 deletions

View file

@ -1404,7 +1404,8 @@ Computer8080.prototype.getMachineComponent = function(sType, componentPrev)
* updateFocus(fScroll)
*
* NOTE: When soft keyboard buttons call us to return focus to the machine (and away from the button),
* the scroll feature has annoying effect on iOS, so we no longer do it by default (fScroll must be true).
* the browser's default behavior is to scroll the element into view, which can be annoying, especially on iOS,
* where the display is more constrained, so we no longer do it by default (fScroll must be true).
*
* @this {Computer8080}
* @param {boolean} [fScroll]
@ -1418,15 +1419,17 @@ Computer8080.prototype.updateFocus = function(fScroll)
* is to ensure that keyboard input is fielded properly.
*/
var x = 0, y = 0;
if (fScroll && window) {
if (!fScroll && window) {
x = window.scrollX;
y = window.scrollY;
}
/*
* TODO: We need a mechanism to determine the "active" display, instead of hard-coding this to aVideo[0].
*/
this.aVideo[0].setFocus();
if (fScroll && window) {
if (!fScroll && window) {
window.scrollTo(x, y);
}
}