konva 8.3.1 → 8.3.4
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/README.md +3 -0
- package/cmj/Node.js +5 -5
- package/cmj/Shape.js +15 -16
- package/cmj/Util.js +6 -1
- package/cmj/index-node.js +1 -0
- package/cmj/shapes/Arc.js +16 -24
- package/cmj/shapes/Image.d.ts +1 -1
- package/cmj/shapes/Image.js +2 -1
- package/cmj/shapes/Path.d.ts +2 -2
- package/cmj/shapes/Path.js +4 -4
- package/cmj/shapes/Text.d.ts +1 -0
- package/cmj/shapes/Text.js +10 -3
- package/cmj/shapes/TextPath.js +1 -1
- package/cmj/shapes/Transformer.js +2 -2
- package/konva.js +80 -65
- package/konva.min.js +3 -3
- package/lib/Animation.js +0 -1
- package/lib/Canvas.js +0 -1
- package/lib/Container.js +0 -1
- package/lib/Context.js +0 -1
- package/lib/Core.js +0 -1
- package/lib/DragAndDrop.js +0 -1
- package/lib/Factory.js +0 -1
- package/lib/FastLayer.js +0 -1
- package/lib/Global.js +1 -2
- package/lib/Group.js +0 -1
- package/lib/Layer.js +0 -1
- package/lib/Node.js +5 -6
- package/lib/PointerEvents.js +0 -1
- package/lib/Shape.js +15 -17
- package/lib/Stage.js +0 -1
- package/lib/Tween.js +0 -1
- package/lib/Util.js +6 -2
- package/lib/Validators.js +0 -1
- package/lib/_CoreInternals.js +0 -1
- package/lib/_FullInternals.js +0 -1
- package/lib/filters/Blur.js +0 -1
- package/lib/filters/Brighten.js +0 -1
- package/lib/filters/Contrast.js +0 -1
- package/lib/filters/Emboss.js +0 -1
- package/lib/filters/Enhance.js +0 -1
- package/lib/filters/Grayscale.js +0 -1
- package/lib/filters/HSL.js +0 -1
- package/lib/filters/HSV.js +0 -1
- package/lib/filters/Invert.js +0 -1
- package/lib/filters/Kaleidoscope.js +0 -1
- package/lib/filters/Mask.js +0 -1
- package/lib/filters/Noise.js +0 -1
- package/lib/filters/Pixelate.js +0 -1
- package/lib/filters/Posterize.js +0 -1
- package/lib/filters/RGB.js +0 -1
- package/lib/filters/RGBA.js +0 -1
- package/lib/filters/Sepia.js +0 -1
- package/lib/filters/Solarize.js +0 -1
- package/lib/filters/Threshold.js +0 -1
- package/lib/index-node.js +1 -1
- package/lib/index.js +0 -1
- package/lib/shapes/Arc.js +16 -25
- package/lib/shapes/Arrow.js +0 -1
- package/lib/shapes/Circle.js +0 -1
- package/lib/shapes/Ellipse.js +0 -1
- package/lib/shapes/Image.d.ts +1 -1
- package/lib/shapes/Image.js +2 -2
- package/lib/shapes/Label.js +0 -1
- package/lib/shapes/Line.js +0 -1
- package/lib/shapes/Path.d.ts +2 -2
- package/lib/shapes/Path.js +4 -5
- package/lib/shapes/Rect.js +0 -1
- package/lib/shapes/RegularPolygon.js +0 -1
- package/lib/shapes/Ring.js +0 -1
- package/lib/shapes/Sprite.js +0 -1
- package/lib/shapes/Star.js +0 -1
- package/lib/shapes/Text.d.ts +1 -0
- package/lib/shapes/Text.js +10 -4
- package/lib/shapes/TextPath.js +1 -2
- package/lib/shapes/Transformer.js +2 -3
- package/lib/shapes/Wedge.js +0 -1
- package/lib/types.js +0 -1
- package/package.json +15 -14
- package/lib/Animation.js.map +0 -1
- package/lib/Canvas.js.map +0 -1
- package/lib/Container.js.map +0 -1
- package/lib/Context.js.map +0 -1
- package/lib/Core.js.map +0 -1
- package/lib/DragAndDrop.js.map +0 -1
- package/lib/Factory.js.map +0 -1
- package/lib/FastLayer.js.map +0 -1
- package/lib/Global.js.map +0 -1
- package/lib/Group.js.map +0 -1
- package/lib/Layer.js.map +0 -1
- package/lib/Node.js.map +0 -1
- package/lib/PointerEvents.js.map +0 -1
- package/lib/Shape.js.map +0 -1
- package/lib/Stage.js.map +0 -1
- package/lib/Tween.js.map +0 -1
- package/lib/Util.js.map +0 -1
- package/lib/Validators.js.map +0 -1
- package/lib/_CoreInternals.js.map +0 -1
- package/lib/_FullInternals.js.map +0 -1
- package/lib/filters/Blur.js.map +0 -1
- package/lib/filters/Brighten.js.map +0 -1
- package/lib/filters/Contrast.js.map +0 -1
- package/lib/filters/Emboss.js.map +0 -1
- package/lib/filters/Enhance.js.map +0 -1
- package/lib/filters/Grayscale.js.map +0 -1
- package/lib/filters/HSL.js.map +0 -1
- package/lib/filters/HSV.js.map +0 -1
- package/lib/filters/Invert.js.map +0 -1
- package/lib/filters/Kaleidoscope.js.map +0 -1
- package/lib/filters/Mask.js.map +0 -1
- package/lib/filters/Noise.js.map +0 -1
- package/lib/filters/Pixelate.js.map +0 -1
- package/lib/filters/Posterize.js.map +0 -1
- package/lib/filters/RGB.js.map +0 -1
- package/lib/filters/RGBA.js.map +0 -1
- package/lib/filters/Sepia.js.map +0 -1
- package/lib/filters/Solarize.js.map +0 -1
- package/lib/filters/Threshold.js.map +0 -1
- package/lib/index-node.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/shapes/Arc.js.map +0 -1
- package/lib/shapes/Arrow.js.map +0 -1
- package/lib/shapes/Circle.js.map +0 -1
- package/lib/shapes/Ellipse.js.map +0 -1
- package/lib/shapes/Image.js.map +0 -1
- package/lib/shapes/Label.js.map +0 -1
- package/lib/shapes/Line.js.map +0 -1
- package/lib/shapes/Path.js.map +0 -1
- package/lib/shapes/Rect.js.map +0 -1
- package/lib/shapes/RegularPolygon.js.map +0 -1
- package/lib/shapes/Ring.js.map +0 -1
- package/lib/shapes/Sprite.js.map +0 -1
- package/lib/shapes/Star.js.map +0 -1
- package/lib/shapes/Text.js.map +0 -1
- package/lib/shapes/TextPath.js.map +0 -1
- package/lib/shapes/Transformer.js.map +0 -1
- package/lib/shapes/Wedge.js.map +0 -1
- package/lib/types.js.map +0 -1
package/lib/Animation.js
CHANGED
package/lib/Canvas.js
CHANGED
package/lib/Container.js
CHANGED
|
@@ -316,4 +316,3 @@ Factory.addGetterSetter(Container, 'clipY', undefined, getNumberValidator());
|
|
|
316
316
|
Factory.addGetterSetter(Container, 'clipWidth', undefined, getNumberValidator());
|
|
317
317
|
Factory.addGetterSetter(Container, 'clipHeight', undefined, getNumberValidator());
|
|
318
318
|
Factory.addGetterSetter(Container, 'clipFunc');
|
|
319
|
-
//# sourceMappingURL=Container.js.map
|
package/lib/Context.js
CHANGED
package/lib/Core.js
CHANGED
package/lib/DragAndDrop.js
CHANGED
package/lib/Factory.js
CHANGED
package/lib/FastLayer.js
CHANGED
package/lib/Global.js
CHANGED
|
@@ -13,7 +13,7 @@ export const glob = typeof global !== 'undefined'
|
|
|
13
13
|
: {};
|
|
14
14
|
export const Konva = {
|
|
15
15
|
_global: glob,
|
|
16
|
-
version: '8.3.
|
|
16
|
+
version: '8.3.4',
|
|
17
17
|
isBrowser: detectBrowser(),
|
|
18
18
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
19
19
|
dblClickWindow: 400,
|
|
@@ -54,4 +54,3 @@ export const _registerNode = (NodeClass) => {
|
|
|
54
54
|
Konva[NodeClass.prototype.getClassName()] = NodeClass;
|
|
55
55
|
};
|
|
56
56
|
Konva._injectGlobal(Konva);
|
|
57
|
-
//# sourceMappingURL=Global.js.map
|
package/lib/Group.js
CHANGED
package/lib/Layer.js
CHANGED
|
@@ -299,4 +299,3 @@ _registerNode(Layer);
|
|
|
299
299
|
Factory.addGetterSetter(Layer, 'imageSmoothingEnabled', true);
|
|
300
300
|
Factory.addGetterSetter(Layer, 'clearBeforeDraw', true);
|
|
301
301
|
Factory.addGetterSetter(Layer, 'hitGraphEnabled', true, getBooleanValidator());
|
|
302
|
-
//# sourceMappingURL=Layer.js.map
|
package/lib/Node.js
CHANGED
|
@@ -99,13 +99,13 @@ export class Node {
|
|
|
99
99
|
relativeTo: this.getParent(),
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? rect.x : conf.x, y = conf.y === undefined ? rect.y : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
|
|
102
|
+
var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
|
|
103
103
|
if (!width || !height) {
|
|
104
104
|
Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
width += offset * 2;
|
|
108
|
-
height += offset * 2;
|
|
107
|
+
width += offset * 2 + 1;
|
|
108
|
+
height += offset * 2 + 1;
|
|
109
109
|
x -= offset;
|
|
110
110
|
y -= offset;
|
|
111
111
|
var cachedSceneCanvas = new SceneCanvas({
|
|
@@ -1290,8 +1290,8 @@ export class Node {
|
|
|
1290
1290
|
const screenRect = {
|
|
1291
1291
|
x: -margin.x,
|
|
1292
1292
|
y: -margin.y,
|
|
1293
|
-
width: stage.width() + margin.x,
|
|
1294
|
-
height: stage.height() + margin.y,
|
|
1293
|
+
width: stage.width() + 2 * margin.x,
|
|
1294
|
+
height: stage.height() + 2 * margin.y,
|
|
1295
1295
|
};
|
|
1296
1296
|
return Util.haveIntersection(screenRect, this.getClientRect());
|
|
1297
1297
|
}
|
|
@@ -1382,4 +1382,3 @@ Factory.backCompat(Node, {
|
|
|
1382
1382
|
setRotationDeg: 'setRotation',
|
|
1383
1383
|
getRotationDeg: 'getRotation',
|
|
1384
1384
|
});
|
|
1385
|
-
//# sourceMappingURL=Node.js.map
|
package/lib/PointerEvents.js
CHANGED
package/lib/Shape.js
CHANGED
|
@@ -98,14 +98,17 @@ export class Shape extends Node {
|
|
|
98
98
|
tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
|
|
99
99
|
tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
|
|
100
100
|
const m = tr.getMatrix();
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
const matrix = typeof DOMMatrix === 'undefined'
|
|
102
|
+
? {
|
|
103
|
+
a: m[0],
|
|
104
|
+
b: m[1],
|
|
105
|
+
c: m[2],
|
|
106
|
+
d: m[3],
|
|
107
|
+
e: m[4],
|
|
108
|
+
f: m[5],
|
|
109
|
+
}
|
|
110
|
+
: new DOMMatrix(m);
|
|
111
|
+
pattern.setTransform(matrix);
|
|
109
112
|
}
|
|
110
113
|
return pattern;
|
|
111
114
|
}
|
|
@@ -270,17 +273,13 @@ export class Shape extends Node {
|
|
|
270
273
|
const blurRadius = (applyShadow && this.shadowBlur()) || 0;
|
|
271
274
|
const width = preWidth + blurRadius * 2;
|
|
272
275
|
const height = preHeight + blurRadius * 2;
|
|
273
|
-
let roundingOffset = 0;
|
|
274
|
-
if (Math.round(strokeWidth / 2) !== strokeWidth / 2) {
|
|
275
|
-
roundingOffset = 1;
|
|
276
|
-
}
|
|
277
276
|
const rect = {
|
|
278
|
-
width: width
|
|
279
|
-
height: height
|
|
280
|
-
x: -
|
|
277
|
+
width: width,
|
|
278
|
+
height: height,
|
|
279
|
+
x: -(strokeWidth / 2 + blurRadius) +
|
|
281
280
|
Math.min(shadowOffsetX, 0) +
|
|
282
281
|
fillRect.x,
|
|
283
|
-
y: -
|
|
282
|
+
y: -(strokeWidth / 2 + blurRadius) +
|
|
284
283
|
Math.min(shadowOffsetY, 0) +
|
|
285
284
|
fillRect.y,
|
|
286
285
|
};
|
|
@@ -513,4 +512,3 @@ Factory.backCompat(Shape, {
|
|
|
513
512
|
getDrawHitFunc: 'getHitFunc',
|
|
514
513
|
setDrawHitFunc: 'setHitFunc',
|
|
515
514
|
});
|
|
516
|
-
//# sourceMappingURL=Shape.js.map
|
package/lib/Stage.js
CHANGED
package/lib/Tween.js
CHANGED
package/lib/Util.js
CHANGED
|
@@ -474,7 +474,12 @@ export const Util = {
|
|
|
474
474
|
_rgbaColorToRGBA(str) {
|
|
475
475
|
if (str.indexOf('rgba(') === 0) {
|
|
476
476
|
str = str.match(/rgba\(([^)]+)\)/)[1];
|
|
477
|
-
var parts = str.split(/ *, */).map(
|
|
477
|
+
var parts = str.split(/ *, */).map((n, index) => {
|
|
478
|
+
if (n.slice(-1) === '%') {
|
|
479
|
+
return index === 3 ? parseInt(n) / 100 : (parseInt(n) / 100) * 255;
|
|
480
|
+
}
|
|
481
|
+
return Number(n);
|
|
482
|
+
});
|
|
478
483
|
return {
|
|
479
484
|
r: parts[0],
|
|
480
485
|
g: parts[1],
|
|
@@ -740,4 +745,3 @@ export const Util = {
|
|
|
740
745
|
}
|
|
741
746
|
},
|
|
742
747
|
};
|
|
743
|
-
//# sourceMappingURL=Util.js.map
|
package/lib/Validators.js
CHANGED
package/lib/_CoreInternals.js
CHANGED
package/lib/_FullInternals.js
CHANGED
package/lib/filters/Blur.js
CHANGED
package/lib/filters/Brighten.js
CHANGED
package/lib/filters/Contrast.js
CHANGED
package/lib/filters/Emboss.js
CHANGED
|
@@ -100,4 +100,3 @@ Factory.addGetterSetter(Node, 'embossStrength', 0.5, getNumberValidator(), Facto
|
|
|
100
100
|
Factory.addGetterSetter(Node, 'embossWhiteLevel', 0.5, getNumberValidator(), Factory.afterSetFilter);
|
|
101
101
|
Factory.addGetterSetter(Node, 'embossDirection', 'top-left', null, Factory.afterSetFilter);
|
|
102
102
|
Factory.addGetterSetter(Node, 'embossBlend', false, null, Factory.afterSetFilter);
|
|
103
|
-
//# sourceMappingURL=Emboss.js.map
|
package/lib/filters/Enhance.js
CHANGED
package/lib/filters/Grayscale.js
CHANGED
package/lib/filters/HSL.js
CHANGED
package/lib/filters/HSV.js
CHANGED
|
@@ -22,4 +22,3 @@ export const HSV = function (imageData) {
|
|
|
22
22
|
Factory.addGetterSetter(Node, 'hue', 0, getNumberValidator(), Factory.afterSetFilter);
|
|
23
23
|
Factory.addGetterSetter(Node, 'saturation', 0, getNumberValidator(), Factory.afterSetFilter);
|
|
24
24
|
Factory.addGetterSetter(Node, 'value', 0, getNumberValidator(), Factory.afterSetFilter);
|
|
25
|
-
//# sourceMappingURL=HSV.js.map
|
package/lib/filters/Invert.js
CHANGED
|
@@ -130,4 +130,3 @@ export const Kaleidoscope = function (imageData) {
|
|
|
130
130
|
};
|
|
131
131
|
Factory.addGetterSetter(Node, 'kaleidoscopePower', 2, getNumberValidator(), Factory.afterSetFilter);
|
|
132
132
|
Factory.addGetterSetter(Node, 'kaleidoscopeAngle', 0, getNumberValidator(), Factory.afterSetFilter);
|
|
133
|
-
//# sourceMappingURL=Kaleidoscope.js.map
|
package/lib/filters/Mask.js
CHANGED
package/lib/filters/Noise.js
CHANGED
package/lib/filters/Pixelate.js
CHANGED
package/lib/filters/Posterize.js
CHANGED
package/lib/filters/RGB.js
CHANGED
package/lib/filters/RGBA.js
CHANGED
package/lib/filters/Sepia.js
CHANGED
package/lib/filters/Solarize.js
CHANGED
package/lib/filters/Threshold.js
CHANGED
package/lib/index-node.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Konva } from './_FullInternals.js';
|
|
2
2
|
import * as Canvas from 'canvas';
|
|
3
3
|
const canvas = Canvas['default'] || Canvas;
|
|
4
|
+
global.DOMMatrix = canvas.DOMMatrix;
|
|
4
5
|
const isNode = typeof global.document === 'undefined';
|
|
5
6
|
if (isNode) {
|
|
6
7
|
Konva.Util['createCanvasElement'] = () => {
|
|
@@ -16,4 +17,3 @@ if (isNode) {
|
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
export default Konva;
|
|
19
|
-
//# sourceMappingURL=index-node.js.map
|
package/lib/index.js
CHANGED
package/lib/shapes/Arc.js
CHANGED
|
@@ -25,31 +25,23 @@ export class Arc extends Shape {
|
|
|
25
25
|
this.outerRadius(height / 2);
|
|
26
26
|
}
|
|
27
27
|
getSelfRect() {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
for (let i = 0; i < end; i += inc) {
|
|
41
|
-
xs.push(Math.cos(i));
|
|
42
|
-
ys.push(Math.sin(i));
|
|
43
|
-
}
|
|
44
|
-
const minX = Math.round(radius * Math.min(...xs));
|
|
45
|
-
const maxX = Math.round(radius * Math.max(...xs));
|
|
46
|
-
const minY = Math.round(radius * Math.min(...ys));
|
|
47
|
-
const maxY = Math.round(radius * Math.max(...ys));
|
|
28
|
+
const innerRadius = this.innerRadius();
|
|
29
|
+
const outerRadius = this.outerRadius();
|
|
30
|
+
const clockwise = this.clockwise();
|
|
31
|
+
const angle = Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
|
|
32
|
+
const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
|
|
33
|
+
const boundRightRatio = 1;
|
|
34
|
+
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
|
|
35
|
+
const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
|
|
36
|
+
const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
|
|
37
|
+
const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);
|
|
38
|
+
const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
|
|
39
|
+
const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
|
|
48
40
|
return {
|
|
49
|
-
x:
|
|
50
|
-
y:
|
|
51
|
-
width:
|
|
52
|
-
height:
|
|
41
|
+
x: boundLeft,
|
|
42
|
+
y: clockwise ? -1 * boundBottom : boundTop,
|
|
43
|
+
width: boundRight - boundLeft,
|
|
44
|
+
height: boundBottom - boundTop,
|
|
53
45
|
};
|
|
54
46
|
}
|
|
55
47
|
}
|
|
@@ -61,4 +53,3 @@ Factory.addGetterSetter(Arc, 'innerRadius', 0, getNumberValidator());
|
|
|
61
53
|
Factory.addGetterSetter(Arc, 'outerRadius', 0, getNumberValidator());
|
|
62
54
|
Factory.addGetterSetter(Arc, 'angle', 0, getNumberValidator());
|
|
63
55
|
Factory.addGetterSetter(Arc, 'clockwise', false, getBooleanValidator());
|
|
64
|
-
//# sourceMappingURL=Arc.js.map
|
package/lib/shapes/Arrow.js
CHANGED
|
@@ -97,4 +97,3 @@ Factory.addGetterSetter(Arrow, 'pointerLength', 10, getNumberValidator());
|
|
|
97
97
|
Factory.addGetterSetter(Arrow, 'pointerWidth', 10, getNumberValidator());
|
|
98
98
|
Factory.addGetterSetter(Arrow, 'pointerAtBeginning', false);
|
|
99
99
|
Factory.addGetterSetter(Arrow, 'pointerAtEnding', true);
|
|
100
|
-
//# sourceMappingURL=Arrow.js.map
|
package/lib/shapes/Circle.js
CHANGED
package/lib/shapes/Ellipse.js
CHANGED
|
@@ -35,4 +35,3 @@ _registerNode(Ellipse);
|
|
|
35
35
|
Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);
|
|
36
36
|
Factory.addGetterSetter(Ellipse, 'radiusX', 0, getNumberValidator());
|
|
37
37
|
Factory.addGetterSetter(Ellipse, 'radiusY', 0, getNumberValidator());
|
|
38
|
-
//# sourceMappingURL=Ellipse.js.map
|
package/lib/shapes/Image.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare class Image extends Shape<ImageConfig> {
|
|
|
13
13
|
_hitFunc(context: any): void;
|
|
14
14
|
getWidth(): any;
|
|
15
15
|
getHeight(): any;
|
|
16
|
-
static fromURL(url: any, callback: any): void;
|
|
16
|
+
static fromURL(url: any, callback: any, onError?: any): void;
|
|
17
17
|
image: GetSet<CanvasImageSource | undefined, this>;
|
|
18
18
|
crop: GetSet<IRect, this>;
|
|
19
19
|
cropX: GetSet<number, this>;
|
package/lib/shapes/Image.js
CHANGED
|
@@ -78,7 +78,7 @@ export class Image extends Shape {
|
|
|
78
78
|
var _a, _b;
|
|
79
79
|
return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
|
|
80
80
|
}
|
|
81
|
-
static fromURL(url, callback) {
|
|
81
|
+
static fromURL(url, callback, onError = null) {
|
|
82
82
|
var img = Util.createImageElement();
|
|
83
83
|
img.onload = function () {
|
|
84
84
|
var image = new Image({
|
|
@@ -86,6 +86,7 @@ export class Image extends Shape {
|
|
|
86
86
|
});
|
|
87
87
|
callback(image);
|
|
88
88
|
};
|
|
89
|
+
img.onerror = onError;
|
|
89
90
|
img.crossOrigin = 'Anonymous';
|
|
90
91
|
img.src = url;
|
|
91
92
|
}
|
|
@@ -98,4 +99,3 @@ Factory.addGetterSetter(Image, 'cropX', 0, getNumberValidator());
|
|
|
98
99
|
Factory.addGetterSetter(Image, 'cropY', 0, getNumberValidator());
|
|
99
100
|
Factory.addGetterSetter(Image, 'cropWidth', 0, getNumberValidator());
|
|
100
101
|
Factory.addGetterSetter(Image, 'cropHeight', 0, getNumberValidator());
|
|
101
|
-
//# sourceMappingURL=Image.js.map
|
package/lib/shapes/Label.js
CHANGED
|
@@ -164,4 +164,3 @@ Factory.addGetterSetter(Tag, 'pointerDirection', NONE);
|
|
|
164
164
|
Factory.addGetterSetter(Tag, 'pointerWidth', 0, getNumberValidator());
|
|
165
165
|
Factory.addGetterSetter(Tag, 'pointerHeight', 0, getNumberValidator());
|
|
166
166
|
Factory.addGetterSetter(Tag, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
|
|
167
|
-
//# sourceMappingURL=Label.js.map
|
package/lib/shapes/Line.js
CHANGED
|
@@ -153,4 +153,3 @@ Factory.addGetterSetter(Line, 'closed', false);
|
|
|
153
153
|
Factory.addGetterSetter(Line, 'bezier', false);
|
|
154
154
|
Factory.addGetterSetter(Line, 'tension', 0, getNumberValidator());
|
|
155
155
|
Factory.addGetterSetter(Line, 'points', [], getNumberArrayValidator());
|
|
156
|
-
//# sourceMappingURL=Line.js.map
|
package/lib/shapes/Path.d.ts
CHANGED
package/lib/shapes/Path.js
CHANGED
|
@@ -117,10 +117,10 @@ export class Path extends Shape {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
return {
|
|
120
|
-
x:
|
|
121
|
-
y:
|
|
122
|
-
width:
|
|
123
|
-
height:
|
|
120
|
+
x: minX,
|
|
121
|
+
y: minY,
|
|
122
|
+
width: maxX - minX,
|
|
123
|
+
height: maxY - minY,
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
getLength() {
|
|
@@ -625,4 +625,3 @@ Path.prototype.className = 'Path';
|
|
|
625
625
|
Path.prototype._attrsAffectingSize = ['data'];
|
|
626
626
|
_registerNode(Path);
|
|
627
627
|
Factory.addGetterSetter(Path, 'data');
|
|
628
|
-
//# sourceMappingURL=Path.js.map
|
package/lib/shapes/Rect.js
CHANGED
|
@@ -63,4 +63,3 @@ RegularPolygon.prototype._attrsAffectingSize = ['radius'];
|
|
|
63
63
|
_registerNode(RegularPolygon);
|
|
64
64
|
Factory.addGetterSetter(RegularPolygon, 'radius', 0, getNumberValidator());
|
|
65
65
|
Factory.addGetterSetter(RegularPolygon, 'sides', 0, getNumberValidator());
|
|
66
|
-
//# sourceMappingURL=RegularPolygon.js.map
|
package/lib/shapes/Ring.js
CHANGED
|
@@ -31,4 +31,3 @@ Ring.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
|
|
31
31
|
_registerNode(Ring);
|
|
32
32
|
Factory.addGetterSetter(Ring, 'innerRadius', 0, getNumberValidator());
|
|
33
33
|
Factory.addGetterSetter(Ring, 'outerRadius', 0, getNumberValidator());
|
|
34
|
-
//# sourceMappingURL=Ring.js.map
|
package/lib/shapes/Sprite.js
CHANGED
package/lib/shapes/Star.js
CHANGED
|
@@ -36,4 +36,3 @@ _registerNode(Star);
|
|
|
36
36
|
Factory.addGetterSetter(Star, 'numPoints', 5, getNumberValidator());
|
|
37
37
|
Factory.addGetterSetter(Star, 'innerRadius', 0, getNumberValidator());
|
|
38
38
|
Factory.addGetterSetter(Star, 'outerRadius', 0, getNumberValidator());
|
|
39
|
-
//# sourceMappingURL=Star.js.map
|
package/lib/shapes/Text.d.ts
CHANGED
package/lib/shapes/Text.js
CHANGED
|
@@ -92,7 +92,7 @@ export class Text extends Shape {
|
|
|
92
92
|
for (n = 0; n < textArrLen; n++) {
|
|
93
93
|
var lineTranslateX = 0;
|
|
94
94
|
var lineTranslateY = 0;
|
|
95
|
-
var obj = textArr[n], text = obj.text, width = obj.width, lastLine =
|
|
95
|
+
var obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph, spacesNumber, oneWord, lineWidth;
|
|
96
96
|
context.save();
|
|
97
97
|
if (align === RIGHT) {
|
|
98
98
|
lineTranslateX += totalWidth - width - padding * 2;
|
|
@@ -137,7 +137,7 @@ export class Text extends Shape {
|
|
|
137
137
|
var array = stringToArray(text);
|
|
138
138
|
for (var li = 0; li < array.length; li++) {
|
|
139
139
|
var letter = array[li];
|
|
140
|
-
if (letter === ' ' &&
|
|
140
|
+
if (letter === ' ' && !lastLine && align === JUSTIFY) {
|
|
141
141
|
lineTranslateX += (totalWidth - padding * 2 - width) / spacesNumber;
|
|
142
142
|
}
|
|
143
143
|
this._partialTextX = lineTranslateX;
|
|
@@ -217,7 +217,11 @@ export class Text extends Shape {
|
|
|
217
217
|
line = line.trim();
|
|
218
218
|
}
|
|
219
219
|
var width = this._getTextWidth(line);
|
|
220
|
-
return this.textArr.push({
|
|
220
|
+
return this.textArr.push({
|
|
221
|
+
text: line,
|
|
222
|
+
width: width,
|
|
223
|
+
lastInParagraph: false,
|
|
224
|
+
});
|
|
221
225
|
}
|
|
222
226
|
_getTextWidth(text) {
|
|
223
227
|
var letterSpacing = this.letterSpacing();
|
|
@@ -310,6 +314,9 @@ export class Text extends Shape {
|
|
|
310
314
|
if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
|
|
311
315
|
break;
|
|
312
316
|
}
|
|
317
|
+
if (this.textArr[this.textArr.length - 1]) {
|
|
318
|
+
this.textArr[this.textArr.length - 1].lastInParagraph = true;
|
|
319
|
+
}
|
|
313
320
|
}
|
|
314
321
|
this.textHeight = fontSize;
|
|
315
322
|
this.textWidth = textWidth;
|
|
@@ -345,4 +352,3 @@ Factory.addGetterSetter(Text, 'ellipsis', false, getBooleanValidator());
|
|
|
345
352
|
Factory.addGetterSetter(Text, 'letterSpacing', 0, getNumberValidator());
|
|
346
353
|
Factory.addGetterSetter(Text, 'text', '', getStringValidator());
|
|
347
354
|
Factory.addGetterSetter(Text, 'textDecoration', '');
|
|
348
|
-
//# sourceMappingURL=Text.js.map
|
package/lib/shapes/TextPath.js
CHANGED
|
@@ -22,7 +22,7 @@ export class TextPath extends Shape {
|
|
|
22
22
|
this.dataArray = Path.parsePathData(this.attrs.data);
|
|
23
23
|
this._setTextData();
|
|
24
24
|
});
|
|
25
|
-
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva', this._setTextData);
|
|
25
|
+
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva', this._setTextData);
|
|
26
26
|
this._setTextData();
|
|
27
27
|
}
|
|
28
28
|
_sceneFunc(context) {
|
|
@@ -341,4 +341,3 @@ Factory.addGetterSetter(TextPath, 'fontVariant', NORMAL);
|
|
|
341
341
|
Factory.addGetterSetter(TextPath, 'text', EMPTY_STRING);
|
|
342
342
|
Factory.addGetterSetter(TextPath, 'textDecoration', null);
|
|
343
343
|
Factory.addGetterSetter(TextPath, 'kerningFunc', null);
|
|
344
|
-
//# sourceMappingURL=TextPath.js.map
|
|
@@ -446,9 +446,9 @@ export class Transformer extends Group {
|
|
|
446
446
|
x: pos.x - ap.x,
|
|
447
447
|
y: pos.y - ap.y,
|
|
448
448
|
};
|
|
449
|
-
this._fire('transformstart', { evt: e, target: this.getNode() });
|
|
449
|
+
this._fire('transformstart', { evt: e.evt, target: this.getNode() });
|
|
450
450
|
this._nodes.forEach((target) => {
|
|
451
|
-
target._fire('transformstart', { evt: e, target });
|
|
451
|
+
target._fire('transformstart', { evt: e.evt, target });
|
|
452
452
|
});
|
|
453
453
|
}
|
|
454
454
|
_handleMouseMove(e) {
|
|
@@ -946,4 +946,3 @@ Factory.backCompat(Transformer, {
|
|
|
946
946
|
rotateHandlerOffset: 'rotateAnchorOffset',
|
|
947
947
|
enabledHandlers: 'enabledAnchors',
|
|
948
948
|
});
|
|
949
|
-
//# sourceMappingURL=Transformer.js.map
|