konva 8.3.3 → 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/cmj/Node.js +3 -3
- package/cmj/Shape.js +15 -16
- package/cmj/index-node.js +1 -0
- package/cmj/shapes/Arc.js +5 -5
- package/cmj/shapes/Path.d.ts +2 -2
- package/cmj/shapes/Path.js +4 -4
- package/cmj/shapes/TextPath.js +1 -1
- package/cmj/shapes/Transformer.js +2 -2
- package/konva.js +48 -41
- package/konva.min.js +3 -3
- package/lib/Global.js +1 -1
- package/lib/Node.js +3 -3
- package/lib/Shape.js +15 -16
- package/lib/index-node.js +1 -0
- package/lib/shapes/Arc.js +5 -5
- package/lib/shapes/Path.d.ts +2 -2
- package/lib/shapes/Path.js +4 -4
- package/lib/shapes/TextPath.js +1 -1
- package/lib/shapes/Transformer.js +2 -2
- package/package.json +15 -14
package/cmj/Node.js
CHANGED
|
@@ -102,13 +102,13 @@ class Node {
|
|
|
102
102
|
relativeTo: this.getParent(),
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
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;
|
|
105
|
+
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;
|
|
106
106
|
if (!width || !height) {
|
|
107
107
|
Util_1.Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
width += offset * 2;
|
|
111
|
-
height += offset * 2;
|
|
110
|
+
width += offset * 2 + 1;
|
|
111
|
+
height += offset * 2 + 1;
|
|
112
112
|
x -= offset;
|
|
113
113
|
y -= offset;
|
|
114
114
|
var cachedSceneCanvas = new Canvas_1.SceneCanvas({
|
package/cmj/Shape.js
CHANGED
|
@@ -101,14 +101,17 @@ class Shape extends Node_1.Node {
|
|
|
101
101
|
tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
|
|
102
102
|
tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
|
|
103
103
|
const m = tr.getMatrix();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
const matrix = typeof DOMMatrix === 'undefined'
|
|
105
|
+
? {
|
|
106
|
+
a: m[0],
|
|
107
|
+
b: m[1],
|
|
108
|
+
c: m[2],
|
|
109
|
+
d: m[3],
|
|
110
|
+
e: m[4],
|
|
111
|
+
f: m[5],
|
|
112
|
+
}
|
|
113
|
+
: new DOMMatrix(m);
|
|
114
|
+
pattern.setTransform(matrix);
|
|
112
115
|
}
|
|
113
116
|
return pattern;
|
|
114
117
|
}
|
|
@@ -273,17 +276,13 @@ class Shape extends Node_1.Node {
|
|
|
273
276
|
const blurRadius = (applyShadow && this.shadowBlur()) || 0;
|
|
274
277
|
const width = preWidth + blurRadius * 2;
|
|
275
278
|
const height = preHeight + blurRadius * 2;
|
|
276
|
-
let roundingOffset = 0;
|
|
277
|
-
if (Math.round(strokeWidth / 2) !== strokeWidth / 2) {
|
|
278
|
-
roundingOffset = 1;
|
|
279
|
-
}
|
|
280
279
|
const rect = {
|
|
281
|
-
width: width
|
|
282
|
-
height: height
|
|
283
|
-
x: -
|
|
280
|
+
width: width,
|
|
281
|
+
height: height,
|
|
282
|
+
x: -(strokeWidth / 2 + blurRadius) +
|
|
284
283
|
Math.min(shadowOffsetX, 0) +
|
|
285
284
|
fillRect.x,
|
|
286
|
-
y: -
|
|
285
|
+
y: -(strokeWidth / 2 + blurRadius) +
|
|
287
286
|
Math.min(shadowOffsetY, 0) +
|
|
288
287
|
fillRect.y,
|
|
289
288
|
};
|
package/cmj/index-node.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const _FullInternals_1 = require("./_FullInternals");
|
|
4
4
|
const Canvas = require("canvas");
|
|
5
5
|
const canvas = Canvas['default'] || Canvas;
|
|
6
|
+
global.DOMMatrix = canvas.DOMMatrix;
|
|
6
7
|
const isNode = typeof global.document === 'undefined';
|
|
7
8
|
if (isNode) {
|
|
8
9
|
_FullInternals_1.Konva.Util['createCanvasElement'] = () => {
|
package/cmj/shapes/Arc.js
CHANGED
|
@@ -34,17 +34,17 @@ class Arc extends Shape_1.Shape {
|
|
|
34
34
|
const angle = Global_1.Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
|
|
35
35
|
const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
|
|
36
36
|
const boundRightRatio = 1;
|
|
37
|
-
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), 3 * Math.PI / 2));
|
|
37
|
+
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
|
|
38
38
|
const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
|
|
39
39
|
const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
|
|
40
40
|
const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);
|
|
41
41
|
const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
|
|
42
42
|
const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
|
|
43
43
|
return {
|
|
44
|
-
x:
|
|
45
|
-
y:
|
|
46
|
-
width:
|
|
47
|
-
height:
|
|
44
|
+
x: boundLeft,
|
|
45
|
+
y: clockwise ? -1 * boundBottom : boundTop,
|
|
46
|
+
width: boundRight - boundLeft,
|
|
47
|
+
height: boundBottom - boundTop,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}
|
package/cmj/shapes/Path.d.ts
CHANGED
package/cmj/shapes/Path.js
CHANGED
|
@@ -120,10 +120,10 @@ class Path extends Shape_1.Shape {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
return {
|
|
123
|
-
x:
|
|
124
|
-
y:
|
|
125
|
-
width:
|
|
126
|
-
height:
|
|
123
|
+
x: minX,
|
|
124
|
+
y: minY,
|
|
125
|
+
width: maxX - minX,
|
|
126
|
+
height: maxY - minY,
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
getLength() {
|
package/cmj/shapes/TextPath.js
CHANGED
|
@@ -25,7 +25,7 @@ class TextPath extends Shape_1.Shape {
|
|
|
25
25
|
this.dataArray = Path_1.Path.parsePathData(this.attrs.data);
|
|
26
26
|
this._setTextData();
|
|
27
27
|
});
|
|
28
|
-
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva', this._setTextData);
|
|
28
|
+
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva', this._setTextData);
|
|
29
29
|
this._setTextData();
|
|
30
30
|
}
|
|
31
31
|
_sceneFunc(context) {
|
|
@@ -449,9 +449,9 @@ class Transformer extends Group_1.Group {
|
|
|
449
449
|
x: pos.x - ap.x,
|
|
450
450
|
y: pos.y - ap.y,
|
|
451
451
|
};
|
|
452
|
-
this._fire('transformstart', { evt: e, target: this.getNode() });
|
|
452
|
+
this._fire('transformstart', { evt: e.evt, target: this.getNode() });
|
|
453
453
|
this._nodes.forEach((target) => {
|
|
454
|
-
target._fire('transformstart', { evt: e, target });
|
|
454
|
+
target._fire('transformstart', { evt: e.evt, target });
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
_handleMouseMove(e) {
|
package/konva.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* Konva JavaScript Framework v8.3.
|
|
8
|
+
* Konva JavaScript Framework v8.3.4
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Sun Mar 13 2022
|
|
12
12
|
*
|
|
13
13
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
|
14
14
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
: {};
|
|
36
36
|
const Konva$2 = {
|
|
37
37
|
_global: glob,
|
|
38
|
-
version: '8.3.
|
|
38
|
+
version: '8.3.4',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -2599,15 +2599,26 @@
|
|
|
2599
2599
|
relativeTo: this.getParent(),
|
|
2600
2600
|
});
|
|
2601
2601
|
}
|
|
2602
|
-
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;
|
|
2602
|
+
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;
|
|
2603
2603
|
if (!width || !height) {
|
|
2604
2604
|
Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
|
|
2605
2605
|
return;
|
|
2606
2606
|
}
|
|
2607
|
-
|
|
2608
|
-
|
|
2607
|
+
// let's just add 1 pixel extra,
|
|
2608
|
+
// because using Math.floor on x, y position may shift drawing
|
|
2609
|
+
width += offset * 2 + 1;
|
|
2610
|
+
height += offset * 2 + 1;
|
|
2609
2611
|
x -= offset;
|
|
2610
2612
|
y -= offset;
|
|
2613
|
+
// if (Math.floor(x) < x) {
|
|
2614
|
+
// x = Math.floor(x);
|
|
2615
|
+
// // width += 1;
|
|
2616
|
+
// }
|
|
2617
|
+
// if (Math.floor(y) < y) {
|
|
2618
|
+
// y = Math.floor(y);
|
|
2619
|
+
// // height += 1;
|
|
2620
|
+
// }
|
|
2621
|
+
// console.log({ x, y, width, height }, rect);
|
|
2611
2622
|
var cachedSceneCanvas = new SceneCanvas({
|
|
2612
2623
|
pixelRatio: pixelRatio,
|
|
2613
2624
|
width: width,
|
|
@@ -6704,14 +6715,17 @@
|
|
|
6704
6715
|
tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
|
|
6705
6716
|
tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
|
|
6706
6717
|
const m = tr.getMatrix();
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6718
|
+
const matrix = typeof DOMMatrix === 'undefined'
|
|
6719
|
+
? {
|
|
6720
|
+
a: m[0],
|
|
6721
|
+
b: m[1],
|
|
6722
|
+
c: m[2],
|
|
6723
|
+
d: m[3],
|
|
6724
|
+
e: m[4],
|
|
6725
|
+
f: m[5], // Vertical translation (moving).
|
|
6726
|
+
}
|
|
6727
|
+
: new DOMMatrix(m);
|
|
6728
|
+
pattern.setTransform(matrix);
|
|
6715
6729
|
}
|
|
6716
6730
|
return pattern;
|
|
6717
6731
|
}
|
|
@@ -6933,20 +6947,13 @@
|
|
|
6933
6947
|
const blurRadius = (applyShadow && this.shadowBlur()) || 0;
|
|
6934
6948
|
const width = preWidth + blurRadius * 2;
|
|
6935
6949
|
const height = preHeight + blurRadius * 2;
|
|
6936
|
-
// if stroke, for example = 3
|
|
6937
|
-
// we need to set x to 1.5, but after Math.round it will be 2
|
|
6938
|
-
// as we have additional offset we need to increase width and height by 1 pixel
|
|
6939
|
-
let roundingOffset = 0;
|
|
6940
|
-
if (Math.round(strokeWidth / 2) !== strokeWidth / 2) {
|
|
6941
|
-
roundingOffset = 1;
|
|
6942
|
-
}
|
|
6943
6950
|
const rect = {
|
|
6944
|
-
width: width
|
|
6945
|
-
height: height
|
|
6946
|
-
x: -
|
|
6951
|
+
width: width,
|
|
6952
|
+
height: height,
|
|
6953
|
+
x: -(strokeWidth / 2 + blurRadius) +
|
|
6947
6954
|
Math.min(shadowOffsetX, 0) +
|
|
6948
6955
|
fillRect.x,
|
|
6949
|
-
y: -
|
|
6956
|
+
y: -(strokeWidth / 2 + blurRadius) +
|
|
6950
6957
|
Math.min(shadowOffsetY, 0) +
|
|
6951
6958
|
fillRect.y,
|
|
6952
6959
|
};
|
|
@@ -9732,17 +9739,17 @@
|
|
|
9732
9739
|
const angle = Konva$2.getAngle(clockwise ? 360 - this.angle() : this.angle());
|
|
9733
9740
|
const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
|
|
9734
9741
|
const boundRightRatio = 1;
|
|
9735
|
-
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), 3 * Math.PI / 2));
|
|
9742
|
+
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
|
|
9736
9743
|
const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
|
|
9737
9744
|
const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
|
|
9738
9745
|
const boundRight = boundRightRatio * (outerRadius );
|
|
9739
9746
|
const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
|
|
9740
9747
|
const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
|
|
9741
9748
|
return {
|
|
9742
|
-
x:
|
|
9743
|
-
y:
|
|
9744
|
-
width:
|
|
9745
|
-
height:
|
|
9749
|
+
x: boundLeft,
|
|
9750
|
+
y: clockwise ? -1 * boundBottom : boundTop,
|
|
9751
|
+
width: boundRight - boundLeft,
|
|
9752
|
+
height: boundBottom - boundTop,
|
|
9746
9753
|
};
|
|
9747
9754
|
}
|
|
9748
9755
|
}
|
|
@@ -10341,10 +10348,10 @@
|
|
|
10341
10348
|
}
|
|
10342
10349
|
}
|
|
10343
10350
|
return {
|
|
10344
|
-
x:
|
|
10345
|
-
y:
|
|
10346
|
-
width:
|
|
10347
|
-
height:
|
|
10351
|
+
x: minX,
|
|
10352
|
+
y: minY,
|
|
10353
|
+
width: maxX - minX,
|
|
10354
|
+
height: maxY - minY,
|
|
10348
10355
|
};
|
|
10349
10356
|
}
|
|
10350
10357
|
/**
|
|
@@ -13964,7 +13971,7 @@
|
|
|
13964
13971
|
this._setTextData();
|
|
13965
13972
|
});
|
|
13966
13973
|
// update text data for certain attr changes
|
|
13967
|
-
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva', this._setTextData);
|
|
13974
|
+
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva', this._setTextData);
|
|
13968
13975
|
this._setTextData();
|
|
13969
13976
|
}
|
|
13970
13977
|
_sceneFunc(context) {
|
|
@@ -14386,10 +14393,10 @@
|
|
|
14386
14393
|
* @param {Number} letterSpacing
|
|
14387
14394
|
* @returns {Number}
|
|
14388
14395
|
* @example
|
|
14389
|
-
* // get
|
|
14396
|
+
* // get letter spacing value
|
|
14390
14397
|
* var letterSpacing = shape.letterSpacing();
|
|
14391
14398
|
*
|
|
14392
|
-
* // set the
|
|
14399
|
+
* // set the letter spacing value
|
|
14393
14400
|
* shape.letterSpacing(2);
|
|
14394
14401
|
*/
|
|
14395
14402
|
Factory.addGetterSetter(TextPath, 'letterSpacing', 0, getNumberValidator());
|
|
@@ -14400,10 +14407,10 @@
|
|
|
14400
14407
|
* @param {String} textBaseline
|
|
14401
14408
|
* @returns {String}
|
|
14402
14409
|
* @example
|
|
14403
|
-
* // get
|
|
14410
|
+
* // get current text baseline
|
|
14404
14411
|
* var textBaseline = shape.textBaseline();
|
|
14405
14412
|
*
|
|
14406
|
-
* // set
|
|
14413
|
+
* // set new text baseline
|
|
14407
14414
|
* shape.textBaseline('top');
|
|
14408
14415
|
*/
|
|
14409
14416
|
Factory.addGetterSetter(TextPath, 'textBaseline', 'middle');
|
|
@@ -15001,9 +15008,9 @@
|
|
|
15001
15008
|
x: pos.x - ap.x,
|
|
15002
15009
|
y: pos.y - ap.y,
|
|
15003
15010
|
};
|
|
15004
|
-
this._fire('transformstart', { evt: e, target: this.getNode() });
|
|
15011
|
+
this._fire('transformstart', { evt: e.evt, target: this.getNode() });
|
|
15005
15012
|
this._nodes.forEach((target) => {
|
|
15006
|
-
target._fire('transformstart', { evt: e, target });
|
|
15013
|
+
target._fire('transformstart', { evt: e.evt, target });
|
|
15007
15014
|
});
|
|
15008
15015
|
}
|
|
15009
15016
|
_handleMouseMove(e) {
|