js-draw 1.7.0 → 1.7.2

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.
@@ -1129,12 +1129,12 @@ class Editor {
1129
1129
  if (this.settings.appInfo.description) {
1130
1130
  descriptionLines.push(this.settings.appInfo.description + '\n');
1131
1131
  }
1132
+ else {
1133
+ descriptionLines.push(`js-draw v${version_1.default.number}`);
1134
+ }
1132
1135
  notices.push({
1133
1136
  heading: `${this.settings.appInfo.name}`,
1134
- text: [
1135
- ...descriptionLines,
1136
- `(js-draw v${version_1.default.number})`,
1137
- ].join('\n'),
1137
+ text: descriptionLines.join('\n'),
1138
1138
  });
1139
1139
  }
1140
1140
  else {
@@ -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.2',
5
5
  };
@@ -1100,12 +1100,12 @@ export class Editor {
1100
1100
  if (this.settings.appInfo.description) {
1101
1101
  descriptionLines.push(this.settings.appInfo.description + '\n');
1102
1102
  }
1103
+ else {
1104
+ descriptionLines.push(`js-draw v${version.number}`);
1105
+ }
1103
1106
  notices.push({
1104
1107
  heading: `${this.settings.appInfo.name}`,
1105
- text: [
1106
- ...descriptionLines,
1107
- `(js-draw v${version.number})`,
1108
- ].join('\n'),
1108
+ text: descriptionLines.join('\n'),
1109
1109
  });
1110
1110
  }
1111
1111
  else {
@@ -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.2',
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.2",
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": "e1677b6e40bd385e1ce40643fd10f064847adf5b"
90
90
  }