js-draw 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,7 @@ export declare class RotateTransformer {
31
31
  private targetRotation;
32
32
  private maximumDistFromStart;
33
33
  private startPoint;
34
+ private startTime;
34
35
  constructor(editor: Editor, selection: Selection);
35
36
  private getAngle;
36
37
  private roundAngle;
@@ -115,8 +115,10 @@ class RotateTransformer {
115
115
  this.startPoint = startPoint;
116
116
  this.selection.setTransform(math_1.Mat33.identity);
117
117
  this.startAngle = this.getAngle(startPoint);
118
- this.maximumDistFromStart = 0;
119
118
  this.targetRotation = 0;
119
+ // Used to determine whether the user clicked or not.
120
+ this.maximumDistFromStart = 0;
121
+ this.startTime = performance.now();
120
122
  }
121
123
  setRotationTo(angle) {
122
124
  // Transform in canvas space
@@ -138,9 +140,13 @@ class RotateTransformer {
138
140
  }
139
141
  }
140
142
  onDragEnd() {
141
- // Anything less than this is considered a click
142
- const clickThreshold = 15;
143
- if (this.maximumDistFromStart < clickThreshold && this.targetRotation === 0) {
143
+ // Anything with motion less than this is considered a click
144
+ const clickThresholdDist = 10;
145
+ const clickThresholdTime = 0.4; // s
146
+ const dragTimeSeconds = (performance.now() - this.startTime) / 1000;
147
+ if (dragTimeSeconds < clickThresholdTime
148
+ && this.maximumDistFromStart < clickThresholdDist
149
+ && this.targetRotation === 0) {
144
150
  this.setRotationTo(-Math.PI / 2);
145
151
  }
146
152
  return this.selection.finalizeTransform();
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
- number: '1.7.0',
4
+ number: '1.7.1',
5
5
  };
@@ -31,6 +31,7 @@ export declare class RotateTransformer {
31
31
  private targetRotation;
32
32
  private maximumDistFromStart;
33
33
  private startPoint;
34
+ private startTime;
34
35
  constructor(editor: Editor, selection: Selection);
35
36
  private getAngle;
36
37
  private roundAngle;
@@ -107,8 +107,10 @@ export class RotateTransformer {
107
107
  this.startPoint = startPoint;
108
108
  this.selection.setTransform(Mat33.identity);
109
109
  this.startAngle = this.getAngle(startPoint);
110
- this.maximumDistFromStart = 0;
111
110
  this.targetRotation = 0;
111
+ // Used to determine whether the user clicked or not.
112
+ this.maximumDistFromStart = 0;
113
+ this.startTime = performance.now();
112
114
  }
113
115
  setRotationTo(angle) {
114
116
  // Transform in canvas space
@@ -130,9 +132,13 @@ export class RotateTransformer {
130
132
  }
131
133
  }
132
134
  onDragEnd() {
133
- // Anything less than this is considered a click
134
- const clickThreshold = 15;
135
- if (this.maximumDistFromStart < clickThreshold && this.targetRotation === 0) {
135
+ // Anything with motion less than this is considered a click
136
+ const clickThresholdDist = 10;
137
+ const clickThresholdTime = 0.4; // s
138
+ const dragTimeSeconds = (performance.now() - this.startTime) / 1000;
139
+ if (dragTimeSeconds < clickThresholdTime
140
+ && this.maximumDistFromStart < clickThresholdDist
141
+ && this.targetRotation === 0) {
136
142
  this.setRotationTo(-Math.PI / 2);
137
143
  }
138
144
  return this.selection.finalizeTransform();
@@ -1,3 +1,3 @@
1
1
  export default {
2
- number: '1.7.0',
2
+ number: '1.7.1',
3
3
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-draw",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript. ",
5
5
  "types": "./dist/mjs/lib.d.ts",
6
6
  "main": "./dist/cjs/lib.js",
@@ -86,5 +86,5 @@
86
86
  "freehand",
87
87
  "svg"
88
88
  ],
89
- "gitHead": "e7d8a68e6a5ae3063de9c1f033ed8f08c567b393"
89
+ "gitHead": "2b3787fac2ddb580948f049eb43186e19a65c882"
90
90
  }