Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit 04ee568

Browse files
committed
[DEV] Fix timer and timeout initialisation
1 parent b0323f7 commit 04ee568

File tree

4 files changed

+15
-29
lines changed

4 files changed

+15
-29
lines changed

dist/myscript.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14232,10 +14232,8 @@ MyScript = {
1423214232
this._selectedRecognizer.resetWSRecognition();
1423314233
} else {
1423414234
clearTimeout(this._timerId);
14235-
if (this.getTimeout() > 0) {
14235+
if (this.getTimeout() > -1) {
1423614236
this._timerId = setTimeout(this.recognize.bind(this), this.getTimeout());
14237-
} else if (this.getTimeout() > -1) {
14238-
this.recognize();
1423914237
} else {
1424014238
this._onResult();
1424114239
}
@@ -14272,10 +14270,8 @@ MyScript = {
1427214270
} else {
1427314271
clearTimeout(this._timerId);
1427414272
this.isStarted = false;
14275-
if (this.getTimeout() > 0) {
14273+
if (this.getTimeout() > -1) {
1427614274
this._timerId = setTimeout(this.recognize.bind(this), this.getTimeout());
14277-
} else if (this.getTimeout() > -1) {
14278-
this.recognize();
1427914275
} else {
1428014276
this._onResult();
1428114277
}
@@ -14302,10 +14298,8 @@ MyScript = {
1430214298
this._selectedRecognizer.resetWSRecognition();
1430314299
} else {
1430414300
clearTimeout(this._timerId);
14305-
if (this.getTimeout() > 0) {
14301+
if (this.getTimeout() > -1) {
1430614302
this._timerId = setTimeout(this.recognize.bind(this), this.getTimeout());
14307-
} else if (this.getTimeout() > -1) {
14308-
this.recognize();
1430914303
} else {
1431014304
this._onResult();
1431114305
}
@@ -14327,6 +14321,7 @@ MyScript = {
1432714321
* @param {Date} [t] timeStamp
1432814322
*/
1432914323
InkPaper.prototype._down = function (x, y, t) {
14324+
clearTimeout(this._timerId);
1433014325
var sizeChanged = false;
1433114326
if (this._captureCanvas.clientHeight != this._captureCanvas.height) {
1433214327
this._captureCanvas.height = this._captureCanvas.clientHeight;
@@ -14394,10 +14389,8 @@ MyScript = {
1439414389
}
1439514390
} else {
1439614391
clearTimeout(this._timerId);
14397-
if (this.getTimeout() > 0) {
14392+
if (this.getTimeout() > -1) {
1439814393
this._timerId = setTimeout(this.recognize.bind(this), this.getTimeout());
14399-
} else if (this.getTimeout() > -1) {
14400-
this.recognize();
1440114394
}
1440214395
}
1440314396
};
@@ -14483,7 +14476,7 @@ MyScript = {
1448314476
element.addEventListener('pointerdown', function (e) {
1448414477
if (!pointerId) {
1448514478
pointerId = e.pointerId;
14486-
e.preventDefault();
14479+
e.preventDefault();pointerId
1448714480
var coord = _getCoordinates(e, element);
1448814481
self._down(coord.x, coord.y, coord.t);
1448914482
}

dist/myscript.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/myscript.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/inkPaper.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -743,10 +743,8 @@
743743
this._selectedRecognizer.resetWSRecognition();
744744
} else {
745745
clearTimeout(this._timerId);
746-
if (this.getTimeout() > 0) {
746+
if (this.getTimeout() > -1) {
747747
this._timerId = setTimeout(this.recognize.bind(this), this.getTimeout());
748-
} else if (this.getTimeout() > -1) {
749-
this.recognize();
750748
} else {
751749
this._onResult();
752750
}
@@ -783,10 +781,8 @@
783781
} else {
784782
clearTimeout(this._timerId);
785783
this.isStarted = false;
786-
if (this.getTimeout() > 0) {
784+
if (this.getTimeout() > -1) {
787785
this._timerId = setTimeout(this.recognize.bind(this), this.getTimeout());
788-
} else if (this.getTimeout() > -1) {
789-
this.recognize();
790786
} else {
791787
this._onResult();
792788
}
@@ -813,10 +809,8 @@
813809
this._selectedRecognizer.resetWSRecognition();
814810
} else {
815811
clearTimeout(this._timerId);
816-
if (this.getTimeout() > 0) {
812+
if (this.getTimeout() > -1) {
817813
this._timerId = setTimeout(this.recognize.bind(this), this.getTimeout());
818-
} else if (this.getTimeout() > -1) {
819-
this.recognize();
820814
} else {
821815
this._onResult();
822816
}
@@ -838,6 +832,7 @@
838832
* @param {Date} [t] timeStamp
839833
*/
840834
InkPaper.prototype._down = function (x, y, t) {
835+
clearTimeout(this._timerId);
841836
var sizeChanged = false;
842837
if (this._captureCanvas.clientHeight != this._captureCanvas.height) {
843838
this._captureCanvas.height = this._captureCanvas.clientHeight;
@@ -905,10 +900,8 @@
905900
}
906901
} else {
907902
clearTimeout(this._timerId);
908-
if (this.getTimeout() > 0) {
903+
if (this.getTimeout() > -1) {
909904
this._timerId = setTimeout(this.recognize.bind(this), this.getTimeout());
910-
} else if (this.getTimeout() > -1) {
911-
this.recognize();
912905
}
913906
}
914907
};
@@ -994,7 +987,7 @@
994987
element.addEventListener('pointerdown', function (e) {
995988
if (!pointerId) {
996989
pointerId = e.pointerId;
997-
e.preventDefault();
990+
e.preventDefault();pointerId
998991
var coord = _getCoordinates(e, element);
999992
self._down(coord.x, coord.y, coord.t);
1000993
}

0 commit comments

Comments
 (0)