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/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,
|
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({
|
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
|
};
|
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'] = () => {
|
package/lib/shapes/Arc.js
CHANGED
|
@@ -31,17 +31,17 @@ export class Arc extends Shape {
|
|
|
31
31
|
const angle = Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
|
|
32
32
|
const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
|
|
33
33
|
const boundRightRatio = 1;
|
|
34
|
-
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), 3 * Math.PI / 2));
|
|
34
|
+
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
|
|
35
35
|
const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
|
|
36
36
|
const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
|
|
37
37
|
const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);
|
|
38
38
|
const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
|
|
39
39
|
const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
|
|
40
40
|
return {
|
|
41
|
-
x:
|
|
42
|
-
y:
|
|
43
|
-
width:
|
|
44
|
-
height:
|
|
41
|
+
x: boundLeft,
|
|
42
|
+
y: clockwise ? -1 * boundBottom : boundTop,
|
|
43
|
+
width: boundRight - boundLeft,
|
|
44
|
+
height: boundBottom - boundTop,
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
}
|
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() {
|
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) {
|
|
@@ -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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "konva",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.4",
|
|
4
4
|
"author": "Anton Lavrenov",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
}
|
|
61
61
|
],
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@parcel/transformer-image": "2.
|
|
64
|
-
"@size-limit/preset-big-lib": "^
|
|
65
|
-
"@types/mocha": "^9.
|
|
66
|
-
"canvas": "^2.
|
|
67
|
-
"chai": "4.3.
|
|
63
|
+
"@parcel/transformer-image": "2.3.2",
|
|
64
|
+
"@size-limit/preset-big-lib": "^7.0.8",
|
|
65
|
+
"@types/mocha": "^9.1.0",
|
|
66
|
+
"canvas": "^2.9.0",
|
|
67
|
+
"chai": "4.3.6",
|
|
68
68
|
"filehound": "^1.17.5",
|
|
69
69
|
"gulp": "^4.0.2",
|
|
70
70
|
"gulp-concat": "^2.6.1",
|
|
@@ -77,18 +77,19 @@
|
|
|
77
77
|
"gulp-uglify": "^3.0.2",
|
|
78
78
|
"gulp-uglify-es": "^3.0.0",
|
|
79
79
|
"gulp-util": "^3.0.8",
|
|
80
|
-
"mocha": "
|
|
81
|
-
"mocha-headless-chrome": "^
|
|
82
|
-
"parcel": "2.
|
|
83
|
-
"
|
|
80
|
+
"mocha": "9.2.2",
|
|
81
|
+
"mocha-headless-chrome": "^4.0.0",
|
|
82
|
+
"parcel": "2.3.2",
|
|
83
|
+
"process": "^0.11.10",
|
|
84
|
+
"rollup": "^2.70.0",
|
|
84
85
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
85
86
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
86
87
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
87
|
-
"rollup-plugin-typescript2": "^0.
|
|
88
|
-
"size-limit": "^
|
|
89
|
-
"ts-mocha": "^
|
|
88
|
+
"rollup-plugin-typescript2": "^0.31.2",
|
|
89
|
+
"size-limit": "^7.0.8",
|
|
90
|
+
"ts-mocha": "^9.0.2",
|
|
90
91
|
"ts-node": "^9.1.1",
|
|
91
|
-
"typescript": "^4.
|
|
92
|
+
"typescript": "^4.5.5"
|
|
92
93
|
},
|
|
93
94
|
"keywords": [
|
|
94
95
|
"canvas",
|