fix(web): segment.angle spec, move-based segment recognition

This commit is contained in:
Joshua A. Horton 2022-09-01 08:49:13 +07:00
parent 559a909ea8
commit 7b2da89e8d
2 changed files with 8 additions and 3 deletions

View file

@ -197,9 +197,10 @@ namespace com.keyman.osk {
// it's time to commit to classifying the in-construction Segment.
const alreadyElapsed = fullStatsWithIncoming.duration;
const recognitionWaitTime = this.classifier.config.holdMinimumDuration - alreadyElapsed;
const recognitionFromMove = (this.pathSegment.distance > this.classifier.config.holdMoveTolerance);
// `undefined` if and only if still unrecognized.
if(recognitionWaitTime <= 0 && !this._pathSegment.isRecognized) {
if((recognitionFromMove || recognitionWaitTime <= 0) && !this._pathSegment.isRecognized) {
const classification = this.classifier.classifySegment(fullStatsWithIncoming);
// Based on the specification for segment classification, there WILL be a classification

View file

@ -584,10 +584,10 @@ namespace com.keyman.osk {
*/
public get angle() {
if(this.sampleCount == 1 || !this.lastSample || !this.initialSample) {
return Number.NaN;
return undefined;
} else if(this.netDistance < 1) {
// < 1 px, thus sub-pixel, means we have nothing relevant enough to base an angle on.
return Number.NaN;
return undefined;
}
const xDelta = this.lastSample.targetX - this.initialSample.targetX;
@ -618,6 +618,10 @@ namespace com.keyman.osk {
return undefined;
}
if(isNaN(this.angle) || this.angle === null || this.angle === undefined) {
return undefined;
}
const buckets = ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'n'];
// We could be 'more efficient' and use radians here instead, but this