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.
- package/dist/bundle.js +1 -1
- package/dist/cjs/tools/SelectionTool/TransformMode.d.ts +1 -0
- package/dist/cjs/tools/SelectionTool/TransformMode.js +10 -4
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/tools/SelectionTool/TransformMode.d.ts +1 -0
- package/dist/mjs/tools/SelectionTool/TransformMode.mjs +10 -4
- package/dist/mjs/version.mjs +1 -1
- package/package.json +2 -2
@@ -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
|
143
|
-
|
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();
|
package/dist/cjs/version.js
CHANGED
@@ -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
|
135
|
-
|
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();
|
package/dist/mjs/version.mjs
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "js-draw",
|
3
|
-
"version": "1.7.
|
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": "
|
89
|
+
"gitHead": "2b3787fac2ddb580948f049eb43186e19a65c882"
|
90
90
|
}
|