konva 9.2.2 → 9.3.0
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/konva.js +41 -33
- package/konva.min.js +3 -3
- package/lib/Global.js +1 -1
- package/lib/Node.js +1 -1
- package/lib/index-types.d.ts +9 -9
- package/lib/shapes/Transformer.d.ts +2 -0
- package/lib/shapes/Transformer.js +15 -21
- package/package.json +11 -11
package/lib/Global.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.glob = typeof global !== 'undefined'
|
|
|
16
16
|
: {};
|
|
17
17
|
exports.Konva = {
|
|
18
18
|
_global: exports.glob,
|
|
19
|
-
version: '9.
|
|
19
|
+
version: '9.3.0',
|
|
20
20
|
isBrowser: detectBrowser(),
|
|
21
21
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
22
22
|
dblClickWindow: 400,
|
package/lib/Node.js
CHANGED
|
@@ -997,7 +997,7 @@ class Node {
|
|
|
997
997
|
this.toCanvas(config).toBlob((blob) => {
|
|
998
998
|
resolve(blob);
|
|
999
999
|
callback === null || callback === void 0 ? void 0 : callback(blob);
|
|
1000
|
-
});
|
|
1000
|
+
}, config === null || config === void 0 ? void 0 : config.mimeType, config === null || config === void 0 ? void 0 : config.quality);
|
|
1001
1001
|
}
|
|
1002
1002
|
catch (err) {
|
|
1003
1003
|
reject(err);
|
package/lib/index-types.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ declare namespace Konva {
|
|
|
39
39
|
export let hitOnDragEnabled: boolean;
|
|
40
40
|
export const isDragging: () => boolean;
|
|
41
41
|
export const isDragReady: () => boolean;
|
|
42
|
+
export const getAngle: (angle: number) => number;
|
|
42
43
|
|
|
43
44
|
export type Vector2d = import('./types.js').Vector2d;
|
|
44
45
|
|
|
@@ -46,16 +47,13 @@ declare namespace Konva {
|
|
|
46
47
|
export type Node = import('./Node.js').Node;
|
|
47
48
|
export type NodeConfig = import('./Node.js').NodeConfig;
|
|
48
49
|
|
|
49
|
-
export type KonvaEventObject<
|
|
50
|
-
EventType
|
|
51
|
-
> = import('./Node.js').KonvaEventObject<EventType>;
|
|
50
|
+
export type KonvaEventObject<EventType> =
|
|
51
|
+
import('./Node.js').KonvaEventObject<EventType>;
|
|
52
52
|
|
|
53
53
|
export type KonvaPointerEvent = import('./PointerEvents.js').KonvaPointerEvent;
|
|
54
54
|
|
|
55
|
-
export type KonvaEventListener<
|
|
56
|
-
This,
|
|
57
|
-
EventType
|
|
58
|
-
> = import('./Node.js').KonvaEventListener<This, EventType>;
|
|
55
|
+
export type KonvaEventListener<This, EventType> =
|
|
56
|
+
import('./Node.js').KonvaEventListener<This, EventType>;
|
|
59
57
|
|
|
60
58
|
export const Container: typeof import('./Container.js').Container;
|
|
61
59
|
export type Container = import('./Container.js').Container<Node>;
|
|
@@ -132,7 +130,8 @@ declare namespace Konva {
|
|
|
132
130
|
export type RectConfig = import('./shapes/Rect.js').RectConfig;
|
|
133
131
|
export const RegularPolygon: typeof import('./shapes/RegularPolygon.js').RegularPolygon;
|
|
134
132
|
export type RegularPolygon = import('./shapes/RegularPolygon.js').RegularPolygon;
|
|
135
|
-
export type RegularPolygonConfig =
|
|
133
|
+
export type RegularPolygonConfig =
|
|
134
|
+
import('./shapes/RegularPolygon.js').RegularPolygonConfig;
|
|
136
135
|
export const Ring: typeof import('./shapes/Ring.js').Ring;
|
|
137
136
|
export type Ring = import('./shapes/Ring.js').Ring;
|
|
138
137
|
export type RingConfig = import('./shapes/Ring.js').RingConfig;
|
|
@@ -150,7 +149,8 @@ declare namespace Konva {
|
|
|
150
149
|
export type TextPathConfig = import('./shapes/TextPath.js').TextPathConfig;
|
|
151
150
|
export const Transformer: typeof import('./shapes/Transformer.js').Transformer;
|
|
152
151
|
export type Transformer = import('./shapes/Transformer.js').Transformer;
|
|
153
|
-
export type TransformerConfig =
|
|
152
|
+
export type TransformerConfig =
|
|
153
|
+
import('./shapes/Transformer.js').TransformerConfig;
|
|
154
154
|
export const Wedge: typeof import('./shapes/Wedge.js').Wedge;
|
|
155
155
|
export type Wedge = import('./shapes/Wedge.js').Wedge;
|
|
156
156
|
export type WedgeConfig = import('./shapes/Wedge.js').WedgeConfig;
|
|
@@ -10,6 +10,7 @@ export interface Box extends IRect {
|
|
|
10
10
|
export interface TransformerConfig extends ContainerConfig {
|
|
11
11
|
resizeEnabled?: boolean;
|
|
12
12
|
rotateEnabled?: boolean;
|
|
13
|
+
rotateLineVisible?: boolean;
|
|
13
14
|
rotationSnaps?: Array<number>;
|
|
14
15
|
rotationSnapTolerance?: number;
|
|
15
16
|
rotateAnchorOffset?: number;
|
|
@@ -96,6 +97,7 @@ export declare class Transformer extends Group {
|
|
|
96
97
|
anchorSize: GetSet<number, this>;
|
|
97
98
|
resizeEnabled: GetSet<boolean, this>;
|
|
98
99
|
rotateEnabled: GetSet<boolean, this>;
|
|
100
|
+
rotateLineVisible: GetSet<boolean, this>;
|
|
99
101
|
rotateAnchorOffset: GetSet<number, this>;
|
|
100
102
|
rotationSnapTolerance: GetSet<number, this>;
|
|
101
103
|
rotateAnchorCursor: GetSet<string, this>;
|
|
@@ -412,7 +412,7 @@ class Transformer extends Group_1.Group {
|
|
|
412
412
|
ctx.beginPath();
|
|
413
413
|
ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);
|
|
414
414
|
ctx.moveTo(shape.width() / 2, -padding);
|
|
415
|
-
if (tr.rotateEnabled()) {
|
|
415
|
+
if (tr.rotateEnabled() && tr.rotateLineVisible()) {
|
|
416
416
|
ctx.lineTo(shape.width() / 2, -tr.rotateAnchorOffset() * Util_1.Util._sign(shape.height()) - padding);
|
|
417
417
|
}
|
|
418
418
|
ctx.fillStrokeShape(shape);
|
|
@@ -688,7 +688,6 @@ class Transformer extends Group_1.Group {
|
|
|
688
688
|
this.update();
|
|
689
689
|
return;
|
|
690
690
|
}
|
|
691
|
-
const allowNegativeScale = this.flipEnabled();
|
|
692
691
|
var t = new Util_1.Transform();
|
|
693
692
|
t.rotate(Global_1.Konva.getAngle(this.rotation()));
|
|
694
693
|
if (this._movingAnchorName &&
|
|
@@ -704,10 +703,6 @@ class Transformer extends Group_1.Group {
|
|
|
704
703
|
this._movingAnchorName = this._movingAnchorName.replace('left', 'right');
|
|
705
704
|
this._anchorDragOffset.x -= offset.x;
|
|
706
705
|
this._anchorDragOffset.y -= offset.y;
|
|
707
|
-
if (!allowNegativeScale) {
|
|
708
|
-
this.update();
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
706
|
}
|
|
712
707
|
else if (this._movingAnchorName &&
|
|
713
708
|
newAttrs.width < 0 &&
|
|
@@ -720,10 +715,6 @@ class Transformer extends Group_1.Group {
|
|
|
720
715
|
this._anchorDragOffset.x -= offset.x;
|
|
721
716
|
this._anchorDragOffset.y -= offset.y;
|
|
722
717
|
newAttrs.width += this.padding() * 2;
|
|
723
|
-
if (!allowNegativeScale) {
|
|
724
|
-
this.update();
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
718
|
}
|
|
728
719
|
if (this._movingAnchorName &&
|
|
729
720
|
newAttrs.height < 0 &&
|
|
@@ -738,10 +729,6 @@ class Transformer extends Group_1.Group {
|
|
|
738
729
|
this._anchorDragOffset.x -= offset.x;
|
|
739
730
|
this._anchorDragOffset.y -= offset.y;
|
|
740
731
|
newAttrs.height += this.padding() * 2;
|
|
741
|
-
if (!allowNegativeScale) {
|
|
742
|
-
this.update();
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
732
|
}
|
|
746
733
|
else if (this._movingAnchorName &&
|
|
747
734
|
newAttrs.height < 0 &&
|
|
@@ -754,10 +741,6 @@ class Transformer extends Group_1.Group {
|
|
|
754
741
|
this._anchorDragOffset.x -= offset.x;
|
|
755
742
|
this._anchorDragOffset.y -= offset.y;
|
|
756
743
|
newAttrs.height += this.padding() * 2;
|
|
757
|
-
if (!allowNegativeScale) {
|
|
758
|
-
this.update();
|
|
759
|
-
return;
|
|
760
|
-
}
|
|
761
744
|
}
|
|
762
745
|
if (this.boundBoxFunc()) {
|
|
763
746
|
const bounded = this.boundBoxFunc()(oldAttrs, newAttrs);
|
|
@@ -774,9 +757,19 @@ class Transformer extends Group_1.Group {
|
|
|
774
757
|
oldTr.rotate(oldAttrs.rotation);
|
|
775
758
|
oldTr.scale(oldAttrs.width / baseSize, oldAttrs.height / baseSize);
|
|
776
759
|
const newTr = new Util_1.Transform();
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
760
|
+
const newScaleX = newAttrs.width / baseSize;
|
|
761
|
+
const newScaleY = newAttrs.height / baseSize;
|
|
762
|
+
if (this.flipEnabled() === false) {
|
|
763
|
+
newTr.translate(newAttrs.x, newAttrs.y);
|
|
764
|
+
newTr.rotate(newAttrs.rotation);
|
|
765
|
+
newTr.translate(newAttrs.width < 0 ? newAttrs.width : 0, newAttrs.height < 0 ? newAttrs.height : 0);
|
|
766
|
+
newTr.scale(Math.abs(newScaleX), Math.abs(newScaleY));
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
newTr.translate(newAttrs.x, newAttrs.y);
|
|
770
|
+
newTr.rotate(newAttrs.rotation);
|
|
771
|
+
newTr.scale(newScaleX, newScaleY);
|
|
772
|
+
}
|
|
780
773
|
const delta = newTr.multiply(oldTr.invert());
|
|
781
774
|
this._nodes.forEach((node) => {
|
|
782
775
|
var _a;
|
|
@@ -967,6 +960,7 @@ Factory_1.Factory.addGetterSetter(Transformer, 'flipEnabled', true, (0, Validato
|
|
|
967
960
|
Factory_1.Factory.addGetterSetter(Transformer, 'resizeEnabled', true);
|
|
968
961
|
Factory_1.Factory.addGetterSetter(Transformer, 'anchorSize', 10, (0, Validators_1.getNumberValidator)());
|
|
969
962
|
Factory_1.Factory.addGetterSetter(Transformer, 'rotateEnabled', true);
|
|
963
|
+
Factory_1.Factory.addGetterSetter(Transformer, 'rotateLineVisible', true);
|
|
970
964
|
Factory_1.Factory.addGetterSetter(Transformer, 'rotationSnaps', []);
|
|
971
965
|
Factory_1.Factory.addGetterSetter(Transformer, 'rotateAnchorOffset', 50, (0, Validators_1.getNumberValidator)());
|
|
972
966
|
Factory_1.Factory.addGetterSetter(Transformer, 'rotateAnchorCursor', 'crosshair');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "konva",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"author": "Anton Lavrenov",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
}
|
|
60
60
|
],
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@parcel/transformer-image": "2.
|
|
63
|
-
"@size-limit/preset-big-lib": "^
|
|
64
|
-
"@types/mocha": "^10.0.
|
|
62
|
+
"@parcel/transformer-image": "2.10.1",
|
|
63
|
+
"@size-limit/preset-big-lib": "^11.0.1",
|
|
64
|
+
"@types/mocha": "^10.0.6",
|
|
65
65
|
"canvas": "^2.11.2",
|
|
66
|
-
"chai": "4.3.
|
|
66
|
+
"chai": "4.3.10",
|
|
67
67
|
"filehound": "^1.17.6",
|
|
68
68
|
"gulp": "^4.0.2",
|
|
69
69
|
"gulp-concat": "^2.6.1",
|
|
@@ -78,17 +78,17 @@
|
|
|
78
78
|
"gulp-util": "^3.0.8",
|
|
79
79
|
"mocha": "10.2.0",
|
|
80
80
|
"mocha-headless-chrome": "^4.0.0",
|
|
81
|
-
"parcel": "2.
|
|
81
|
+
"parcel": "2.10.1",
|
|
82
82
|
"process": "^0.11.10",
|
|
83
|
-
"rollup": "^
|
|
83
|
+
"rollup": "^4.9.1",
|
|
84
84
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
85
85
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
86
86
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
87
|
-
"rollup-plugin-typescript2": "^0.
|
|
88
|
-
"size-limit": "^
|
|
87
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
88
|
+
"size-limit": "^11.0.1",
|
|
89
89
|
"ts-mocha": "^10.0.0",
|
|
90
|
-
"ts-node": "^10.9.
|
|
91
|
-
"typescript": "^5.
|
|
90
|
+
"ts-node": "^10.9.2",
|
|
91
|
+
"typescript": "^5.3.3"
|
|
92
92
|
},
|
|
93
93
|
"keywords": [
|
|
94
94
|
"canvas",
|