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.
- package/dist/bundle.js +1 -1
- package/dist/cjs/Editor.js +4 -4
- 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/Editor.mjs +4 -4
- 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
package/dist/cjs/Editor.js
CHANGED
@@ -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 {
|
@@ -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
package/dist/mjs/Editor.mjs
CHANGED
@@ -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 {
|
@@ -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.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": "
|
89
|
+
"gitHead": "e1677b6e40bd385e1ce40643fd10f064847adf5b"
|
90
90
|
}
|