diff --git a/common/web/gesture-recognizer/src/constructingSegment.ts b/common/web/gesture-recognizer/src/constructingSegment.ts index b17dd6ff7d..85aade6250 100644 --- a/common/web/gesture-recognizer/src/constructingSegment.ts +++ b/common/web/gesture-recognizer/src/constructingSegment.ts @@ -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 diff --git a/common/web/gesture-recognizer/src/cumulativePathStats.ts b/common/web/gesture-recognizer/src/cumulativePathStats.ts index f03b92cd40..d7167ebf70 100644 --- a/common/web/gesture-recognizer/src/cumulativePathStats.ts +++ b/common/web/gesture-recognizer/src/cumulativePathStats.ts @@ -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