|
1117 | 1117 | function _addDOMEvents() { |
1118 | 1118 | this.canvas.addEventListener('mousedown', this._mouseDownEventListener); |
1119 | 1119 | this.canvas.addEventListener('mouseup', this._mouseUpEventListener); |
1120 | | - this.canvas.addEventListener('mouseenter', this._mouseEnterEventListener); |
1121 | 1120 | this.canvas.addEventListener('mouseleave', this._mouseLeaveEventListener); |
1122 | 1121 | this.canvas.addEventListener('touchstart', this._touchStartEventListener); |
1123 | 1122 | this.canvas.addEventListener('touchmove', this._touchMoveEventListener); |
|
1127 | 1126 | function _removeDOMEvents() { |
1128 | 1127 | this.canvas.removeEventListener('mousedown', this._mouseDownEventListener); |
1129 | 1128 | this.canvas.removeEventListener('mouseup', this._mouseUpEventListener); |
1130 | | - this.canvas.removeEventListener('mouseenter', this._mouseEnterEventListener); |
1131 | 1129 | this.canvas.removeEventListener('mouseexit', this._mouseLeaveEventListener); |
1132 | 1130 | this.canvas.removeEventListener('touchstart', this._touchStartEventListener); |
1133 | 1131 | this.canvas.removeEventListener('touchmove', this._touchMoveEventListener); |
|
1161 | 1159 | if (this._lastCoords.get(identifier)[0] === endCoords[0] && |
1162 | 1160 | this._lastCoords.get(identifier)[1] === endCoords[1]) { |
1163 | 1161 | this._plot.apply(this, endCoords); |
1164 | | - this._drawnPaths[this._pathIndex + 1].pathCoords.push(__spreadArrays(endCoords, [true])); |
| 1162 | + if (this._drawnPaths[this._pathIndex + 1]) |
| 1163 | + this._drawnPaths[this._pathIndex + 1].pathCoords.push(__spreadArrays(endCoords, [true])); |
1165 | 1164 | } |
1166 | 1165 | this._lastCoords.delete(identifier); |
1167 | 1166 | if (this._drawnPaths[this._pathIndex + 1].pathCoords.length === 0) |
|
1296 | 1295 | _this.canvas.removeEventListener('mousemove', _this._mouseMoveEventListener); |
1297 | 1296 | } |
1298 | 1297 | }; |
1299 | | - _this._mouseEnterEventListener = function (e) { |
1300 | | - _this._lastCoords.set('mouse', _this._getMouseCoords(e)); |
1301 | | - }; |
1302 | 1298 | _this._mouseLeaveEventListener = function (e) { |
1303 | 1299 | _this.canvas.removeEventListener('mousemove', _this._mouseMoveEventListener); |
1304 | | - _this._endStroke(_this._getMouseCoords(e), 'mouse'); |
| 1300 | + if (_this._lastCoords.has('mouse')) |
| 1301 | + _this._endStroke(_this._getMouseCoords(e), 'mouse'); |
1305 | 1302 | }; |
1306 | 1303 | _this._mouseMoveEventListener = function (e) { |
1307 | 1304 | var coords = _this._getMouseCoords(e); |
|
0 commit comments