konva 9.3.15 → 9.3.17
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 +821 -801
- package/konva.min.js +3 -3
- package/lib/Animation.js +1 -1
- package/lib/BezierFunctions.js +1 -2
- package/lib/Canvas.js +9 -9
- package/lib/Container.d.ts +1 -1
- package/lib/Container.js +29 -29
- package/lib/Context.d.ts +2 -2
- package/lib/Context.js +28 -28
- package/lib/DragAndDrop.d.ts +2 -2
- package/lib/DragAndDrop.js +6 -4
- package/lib/Factory.d.ts +18 -8
- package/lib/Factory.js +17 -16
- package/lib/Global.js +1 -1
- package/lib/Group.js +1 -1
- package/lib/Layer.js +17 -17
- package/lib/Node.d.ts +2 -2
- package/lib/Node.js +89 -89
- package/lib/PointerEvents.js +5 -6
- package/lib/Shape.d.ts +5 -0
- package/lib/Shape.js +37 -37
- package/lib/Stage.d.ts +2 -2
- package/lib/Stage.js +32 -31
- package/lib/Tween.js +31 -27
- package/lib/Util.d.ts +4 -4
- package/lib/Util.js +66 -65
- package/lib/Validators.d.ts +9 -9
- package/lib/Validators.js +12 -13
- package/lib/_CoreInternals.d.ts +8 -8
- package/lib/_FullInternals.d.ts +8 -8
- package/lib/filters/Blur.js +7 -6
- package/lib/filters/Brighten.js +2 -2
- package/lib/filters/Contrast.js +4 -3
- package/lib/filters/Emboss.js +22 -21
- package/lib/filters/Enhance.js +8 -7
- package/lib/filters/Grayscale.js +3 -3
- package/lib/filters/HSL.js +7 -7
- package/lib/filters/HSV.js +7 -7
- package/lib/filters/Invert.js +2 -2
- package/lib/filters/Kaleidoscope.js +44 -44
- package/lib/filters/Mask.js +58 -57
- package/lib/filters/Noise.js +2 -2
- package/lib/filters/Pixelate.js +1 -1
- package/lib/filters/Posterize.js +2 -2
- package/lib/filters/RGB.js +3 -4
- package/lib/filters/RGBA.js +3 -3
- package/lib/filters/Sepia.js +5 -5
- package/lib/filters/Solarize.js +8 -7
- package/lib/filters/Threshold.js +2 -2
- package/lib/shapes/Arc.js +1 -1
- package/lib/shapes/Arrow.js +12 -12
- package/lib/shapes/Ellipse.js +1 -1
- package/lib/shapes/Image.js +3 -3
- package/lib/shapes/Label.d.ts +3 -1
- package/lib/shapes/Label.js +6 -6
- package/lib/shapes/Line.d.ts +1 -1
- package/lib/shapes/Line.js +14 -14
- package/lib/shapes/Path.js +62 -62
- package/lib/shapes/Rect.js +1 -1
- package/lib/shapes/RegularPolygon.js +6 -6
- package/lib/shapes/Ring.js +1 -1
- package/lib/shapes/Sprite.js +9 -9
- package/lib/shapes/Star.js +5 -5
- package/lib/shapes/Text.js +48 -44
- package/lib/shapes/TextPath.js +25 -25
- package/lib/shapes/Transformer.d.ts +1 -1
- package/lib/shapes/Transformer.js +64 -64
- package/package.json +15 -17
package/lib/Group.js
CHANGED
|
@@ -6,7 +6,7 @@ const Container_1 = require("./Container");
|
|
|
6
6
|
const Global_1 = require("./Global");
|
|
7
7
|
class Group extends Container_1.Container {
|
|
8
8
|
_validateAdd(child) {
|
|
9
|
-
|
|
9
|
+
const type = child.getType();
|
|
10
10
|
if (type !== 'Group' && type !== 'Shape') {
|
|
11
11
|
Util_1.Util.throw('You may only add groups and shapes to groups.');
|
|
12
12
|
}
|
package/lib/Layer.js
CHANGED
|
@@ -9,7 +9,7 @@ const Canvas_1 = require("./Canvas");
|
|
|
9
9
|
const Validators_1 = require("./Validators");
|
|
10
10
|
const Shape_1 = require("./Shape");
|
|
11
11
|
const Global_1 = require("./Global");
|
|
12
|
-
|
|
12
|
+
const HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
|
|
13
13
|
{ x: 0, y: 0 },
|
|
14
14
|
{ x: -1, y: -1 },
|
|
15
15
|
{ x: 1, y: -1 },
|
|
@@ -52,7 +52,7 @@ class Layer extends Container_1.Container {
|
|
|
52
52
|
}
|
|
53
53
|
setZIndex(index) {
|
|
54
54
|
super.setZIndex(index);
|
|
55
|
-
|
|
55
|
+
const stage = this.getStage();
|
|
56
56
|
if (stage && stage.content) {
|
|
57
57
|
stage.content.removeChild(this.getNativeCanvasElement());
|
|
58
58
|
if (index < stage.children.length - 1) {
|
|
@@ -66,7 +66,7 @@ class Layer extends Container_1.Container {
|
|
|
66
66
|
}
|
|
67
67
|
moveToTop() {
|
|
68
68
|
Node_1.Node.prototype.moveToTop.call(this);
|
|
69
|
-
|
|
69
|
+
const stage = this.getStage();
|
|
70
70
|
if (stage && stage.content) {
|
|
71
71
|
stage.content.removeChild(this.getNativeCanvasElement());
|
|
72
72
|
stage.content.appendChild(this.getNativeCanvasElement());
|
|
@@ -74,11 +74,11 @@ class Layer extends Container_1.Container {
|
|
|
74
74
|
return true;
|
|
75
75
|
}
|
|
76
76
|
moveUp() {
|
|
77
|
-
|
|
77
|
+
const moved = Node_1.Node.prototype.moveUp.call(this);
|
|
78
78
|
if (!moved) {
|
|
79
79
|
return false;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
const stage = this.getStage();
|
|
82
82
|
if (!stage || !stage.content) {
|
|
83
83
|
return false;
|
|
84
84
|
}
|
|
@@ -93,9 +93,9 @@ class Layer extends Container_1.Container {
|
|
|
93
93
|
}
|
|
94
94
|
moveDown() {
|
|
95
95
|
if (Node_1.Node.prototype.moveDown.call(this)) {
|
|
96
|
-
|
|
96
|
+
const stage = this.getStage();
|
|
97
97
|
if (stage) {
|
|
98
|
-
|
|
98
|
+
const children = stage.children;
|
|
99
99
|
if (stage.content) {
|
|
100
100
|
stage.content.removeChild(this.getNativeCanvasElement());
|
|
101
101
|
stage.content.insertBefore(this.getNativeCanvasElement(), children[this.index + 1].getCanvas()._canvas);
|
|
@@ -107,9 +107,9 @@ class Layer extends Container_1.Container {
|
|
|
107
107
|
}
|
|
108
108
|
moveToBottom() {
|
|
109
109
|
if (Node_1.Node.prototype.moveToBottom.call(this)) {
|
|
110
|
-
|
|
110
|
+
const stage = this.getStage();
|
|
111
111
|
if (stage) {
|
|
112
|
-
|
|
112
|
+
const children = stage.children;
|
|
113
113
|
if (stage.content) {
|
|
114
114
|
stage.content.removeChild(this.getNativeCanvasElement());
|
|
115
115
|
stage.content.insertBefore(this.getNativeCanvasElement(), children[1].getCanvas()._canvas);
|
|
@@ -123,7 +123,7 @@ class Layer extends Container_1.Container {
|
|
|
123
123
|
return this;
|
|
124
124
|
}
|
|
125
125
|
remove() {
|
|
126
|
-
|
|
126
|
+
const _canvas = this.getNativeCanvasElement();
|
|
127
127
|
Node_1.Node.prototype.remove.call(this);
|
|
128
128
|
if (_canvas && _canvas.parentNode && Util_1.Util._isInDocument(_canvas)) {
|
|
129
129
|
_canvas.parentNode.removeChild(_canvas);
|
|
@@ -140,7 +140,7 @@ class Layer extends Container_1.Container {
|
|
|
140
140
|
return this;
|
|
141
141
|
}
|
|
142
142
|
_validateAdd(child) {
|
|
143
|
-
|
|
143
|
+
const type = child.getType();
|
|
144
144
|
if (type !== 'Group' && type !== 'Shape') {
|
|
145
145
|
Util_1.Util.throw('You may only add groups and shapes to a layer.');
|
|
146
146
|
}
|
|
@@ -196,8 +196,8 @@ class Layer extends Container_1.Container {
|
|
|
196
196
|
if (!this.isListening() || !this.isVisible()) {
|
|
197
197
|
return null;
|
|
198
198
|
}
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
let spiralSearchDistance = 1;
|
|
200
|
+
let continueSearch = false;
|
|
201
201
|
while (true) {
|
|
202
202
|
for (let i = 0; i < INTERSECTION_OFFSETS_LEN; i++) {
|
|
203
203
|
const intersectionOffset = INTERSECTION_OFFSETS[i];
|
|
@@ -246,7 +246,7 @@ class Layer extends Container_1.Container {
|
|
|
246
246
|
return {};
|
|
247
247
|
}
|
|
248
248
|
drawScene(can, top) {
|
|
249
|
-
|
|
249
|
+
const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());
|
|
250
250
|
this._fire(BEFORE_DRAW, {
|
|
251
251
|
node: this,
|
|
252
252
|
});
|
|
@@ -260,7 +260,7 @@ class Layer extends Container_1.Container {
|
|
|
260
260
|
return this;
|
|
261
261
|
}
|
|
262
262
|
drawHit(can, top) {
|
|
263
|
-
|
|
263
|
+
const layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas);
|
|
264
264
|
if (layer && layer.clearBeforeDraw()) {
|
|
265
265
|
layer.getHitCanvas().getContext().clear();
|
|
266
266
|
}
|
|
@@ -287,8 +287,8 @@ class Layer extends Container_1.Container {
|
|
|
287
287
|
if (!this.parent || !this.parent['content']) {
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
const parent = this.parent;
|
|
291
|
+
const added = !!this.hitCanvas._canvas.parentNode;
|
|
292
292
|
if (added) {
|
|
293
293
|
parent.content.removeChild(this.hitCanvas._canvas);
|
|
294
294
|
}
|
package/lib/Node.d.ts
CHANGED
|
@@ -180,7 +180,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
180
180
|
toObject(): {
|
|
181
181
|
attrs: Config & Record<string, any>;
|
|
182
182
|
className: string;
|
|
183
|
-
children?: any
|
|
183
|
+
children?: Array<any>;
|
|
184
184
|
};
|
|
185
185
|
toJSON(): string;
|
|
186
186
|
getParent(): Container<Node<NodeConfig>> | null;
|
|
@@ -310,7 +310,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
310
310
|
opacity: GetSet<number, this>;
|
|
311
311
|
rotation: GetSet<number, this>;
|
|
312
312
|
zIndex: GetSet<number, this>;
|
|
313
|
-
scale: GetSet<Vector2d
|
|
313
|
+
scale: GetSet<Vector2d, this>;
|
|
314
314
|
scaleX: GetSet<number, this>;
|
|
315
315
|
scaleY: GetSet<number, this>;
|
|
316
316
|
skew: GetSet<Vector2d, this>;
|