chore(web): Apply suggestions from code review

Co-authored-by: Marc Durdin <marc@durdin.net>
This commit is contained in:
Joshua Horton 2021-06-30 10:11:46 +07:00 committed by GitHub
parent 74dc8ad115
commit e0cf57d508
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 23 deletions

View file

@ -23,12 +23,9 @@ namespace com.keyman.osk.browser {
let _this = this;
this.promise = new Promise<SubkeyPopup>(function(resolve, reject) {
_this.resolver = resolve;
_this.timerId = window.setTimeout(
function() {
// It's no longer deferred; it's being fulfilled.
// Even if the actual subkey itself is still async.
_this.resolve();
}, _this.popupDelay);
// After the timeout, it's no longer deferred; it's being fulfilled.
// Even if the actual subkey itself is still async.
_this.timerId = window.setTimeout(_this.resolve, _this.popupDelay);
});
}
@ -50,4 +47,4 @@ namespace com.keyman.osk.browser {
}
}
}
}
}

View file

@ -240,9 +240,9 @@ namespace com.keyman.osk.browser {
for(let i=0; i < this.baseKey['subKeys'].length; i++) {
try {
let sk= this.element.childNodes[i].firstChild as KeyElement;
let sk = this.element.childNodes[i].firstChild as KeyElement;
let onKey = sk.key.isUnderTouch(touch)
let onKey = sk.key.isUnderTouch(touch);
if(onKey) {
this.baseKey.key.highlight(false);
this.currentSelection = sk;
@ -259,4 +259,4 @@ namespace com.keyman.osk.browser {
}
}
}
}
}

View file

@ -34,7 +34,7 @@ namespace com.keyman.osk.embedded {
this.baseKey.key.highlight(false);
} else {
// This is set with the base key of our current subkey elsewhere within the engine.
var baseKey: OSKKeySpec = this.baseKey.key.spec;
let baseKey: OSKKeySpec = this.baseKey.key.spec;
var found = false;
let selectedKey: OSKKeySpec;
@ -53,10 +53,8 @@ namespace com.keyman.osk.embedded {
throw new Error("Could not find subkey '" + keyCoreID + "' under base key '" + baseKey.coreID + "'!");
}
if(selectedKey) {
keyEvent = this.vkbd.keyEventFromSpec(selectedKey as keyboards.ActiveKey, null);
keyEvent.vkCode=keyEvent.Lcode;
}
keyEvent = this.vkbd.keyEventFromSpec(selectedKey as keyboards.ActiveKey, null);
keyEvent.vkCode=keyEvent.Lcode;
}
this.resolver(keyEvent);
@ -73,15 +71,14 @@ namespace com.keyman.osk.embedded {
}
updateTouch(touch: Touch) {
let baseKeyTouched = this.baseKey.key.isUnderTouch(touch);
this.baseKeySelected = this.baseKey.key.isUnderTouch(touch)
this.baseKeySelected = this.baseKey.key.isUnderTouch(touch);
// Prevent highlighting & selection before the touch has moved from the base key.
if(this.movedFromBaseKey) {
this.baseKey.key.highlight(this.baseKeySelected);
} else {
this.movedFromBaseKey = !baseKeyTouched;
this.movedFromBaseKey = !this.baseKeySelected;
}
}
}
}
}

View file

@ -439,10 +439,10 @@ namespace com.keyman.osk {
let x0 = dom.Utils.getAbsoluteX(btn);
let y0 = dom.Utils.getAbsoluteY(btn);//-document.body.scrollTop;
let x1=x0 + btn.offsetWidth;
let y1=y0 + btn.offsetHeight;
let x1 = x0 + btn.offsetWidth;
let y1 = y0 + btn.offsetHeight;
return (x > x0 && x < x1 && y > y0 && y < y1);
}
}
}
}

View file

@ -626,7 +626,6 @@ namespace com.keyman.osk {
// Process and clear highlighting of pending target
if(this.keyPending) {
this.highlightKey(this.keyPending,false);
// Output character unless moved off key
if(this.keyPending.className.indexOf('hidden') < 0 && tc > 0 && !beyondEdge) {
this.modelKeyClick(this.keyPending, e.changedTouches[0]);