konva 8.3.3 → 8.3.6
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 +11 -6
- package/cmj/Shape.js +15 -16
- package/cmj/Util.d.ts +0 -1
- package/cmj/Util.js +0 -4
- 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 +59 -55
- package/konva.min.js +3 -3
- package/lib/Global.js +1 -1
- package/lib/Node.js +11 -6
- package/lib/Shape.js +15 -16
- package/lib/Util.d.ts +0 -1
- package/lib/Util.js +0 -4
- 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 +45 -16
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.6',
|
|
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({
|
|
@@ -933,11 +933,16 @@ export class Node {
|
|
|
933
933
|
_toKonvaCanvas(config) {
|
|
934
934
|
config = config || {};
|
|
935
935
|
var box = this.getClientRect();
|
|
936
|
-
var stage = this.getStage(), x = config.x !== undefined ? config.x : box.x, y = config.y !== undefined ? config.y : box.y, pixelRatio = config.pixelRatio || 1, canvas = new SceneCanvas({
|
|
937
|
-
width: config.width || box.width || (stage ? stage.width() : 0),
|
|
938
|
-
height: config.height ||
|
|
936
|
+
var stage = this.getStage(), x = config.x !== undefined ? config.x : Math.floor(box.x), y = config.y !== undefined ? config.y : Math.floor(box.y), pixelRatio = config.pixelRatio || 1, canvas = new SceneCanvas({
|
|
937
|
+
width: config.width || Math.ceil(box.width) || (stage ? stage.width() : 0),
|
|
938
|
+
height: config.height ||
|
|
939
|
+
Math.ceil(box.height) ||
|
|
940
|
+
(stage ? stage.height() : 0),
|
|
939
941
|
pixelRatio: pixelRatio,
|
|
940
942
|
}), context = canvas.getContext();
|
|
943
|
+
if (config.imageSmoothingEnabled === false) {
|
|
944
|
+
context._context.imageSmoothingEnabled = false;
|
|
945
|
+
}
|
|
941
946
|
context.save();
|
|
942
947
|
if (x || y) {
|
|
943
948
|
context.translate(-1 * x, -1 * y);
|
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/Util.d.ts
CHANGED
package/lib/Util.js
CHANGED
|
@@ -106,10 +106,6 @@ export class Transform {
|
|
|
106
106
|
getMatrix() {
|
|
107
107
|
return this.m;
|
|
108
108
|
}
|
|
109
|
-
setAbsolutePosition(x, y) {
|
|
110
|
-
var m0 = this.m[0], m1 = this.m[1], m2 = this.m[2], m3 = this.m[3], m4 = this.m[4], m5 = this.m[5], yt = (m0 * (y - m5) - m1 * (x - m4)) / (m0 * m3 - m1 * m2), xt = (x - m4 - m2 * yt) / m0;
|
|
111
|
-
return this.translate(xt, yt);
|
|
112
|
-
}
|
|
113
109
|
decompose() {
|
|
114
110
|
var a = this.m[0];
|
|
115
111
|
var b = this.m[1];
|
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.6",
|
|
4
4
|
"author": "Anton Lavrenov",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -9,10 +9,38 @@
|
|
|
9
9
|
"lib",
|
|
10
10
|
"cmj"
|
|
11
11
|
],
|
|
12
|
-
"main": "./
|
|
12
|
+
"main": "./cmj/index-node.js",
|
|
13
13
|
"browser": "./lib/index.js",
|
|
14
14
|
"typings": "./lib/index-types.d.ts",
|
|
15
15
|
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"node": {
|
|
19
|
+
"require": "./cmj/index-node.js",
|
|
20
|
+
"import": "./lib/index-node.js",
|
|
21
|
+
"default": "./lib/index-node.js"
|
|
22
|
+
},
|
|
23
|
+
"require": "./cmj/index.js",
|
|
24
|
+
"import": "./lib/index.js",
|
|
25
|
+
"default": "./lib/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./cmj": {
|
|
28
|
+
"import": "./lib/index.js",
|
|
29
|
+
"require": "./cmj/index-node.js",
|
|
30
|
+
"node": "./cmj/index-node.js",
|
|
31
|
+
"default": "./cmj/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./cmj/*": {
|
|
34
|
+
"import": "./lib/*.js",
|
|
35
|
+
"require": "./cmj/*.js",
|
|
36
|
+
"default": "./cmj/*.js"
|
|
37
|
+
},
|
|
38
|
+
"./lib/*": {
|
|
39
|
+
"import": "./lib/*.js",
|
|
40
|
+
"require": "./cmj/*.js",
|
|
41
|
+
"default": "./lib/*.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
16
44
|
"scripts": {
|
|
17
45
|
"start": "npm run test:watch",
|
|
18
46
|
"compile": "npm run clean && npm run tsc && cp ./src/index-types.d.ts ./lib/index-types.d.ts && npm run rollup && cp ./package-cmj.json ./cmj/package.json && cp ./src/index-types.d.ts ./cmj/index-types.d.ts",
|
|
@@ -60,12 +88,12 @@
|
|
|
60
88
|
}
|
|
61
89
|
],
|
|
62
90
|
"devDependencies": {
|
|
63
|
-
"@parcel/transformer-image": "2.
|
|
64
|
-
"@size-limit/preset-big-lib": "^
|
|
65
|
-
"@types/mocha": "^9.
|
|
66
|
-
"canvas": "^2.
|
|
67
|
-
"chai": "4.3.
|
|
68
|
-
"filehound": "^1.17.
|
|
91
|
+
"@parcel/transformer-image": "2.5.0",
|
|
92
|
+
"@size-limit/preset-big-lib": "^7.0.8",
|
|
93
|
+
"@types/mocha": "^9.1.1",
|
|
94
|
+
"canvas": "^2.9.1",
|
|
95
|
+
"chai": "4.3.6",
|
|
96
|
+
"filehound": "^1.17.6",
|
|
69
97
|
"gulp": "^4.0.2",
|
|
70
98
|
"gulp-concat": "^2.6.1",
|
|
71
99
|
"gulp-connect": "^5.7.0",
|
|
@@ -77,18 +105,19 @@
|
|
|
77
105
|
"gulp-uglify": "^3.0.2",
|
|
78
106
|
"gulp-uglify-es": "^3.0.0",
|
|
79
107
|
"gulp-util": "^3.0.8",
|
|
80
|
-
"mocha": "
|
|
81
|
-
"mocha-headless-chrome": "^
|
|
82
|
-
"parcel": "2.
|
|
83
|
-
"
|
|
108
|
+
"mocha": "9.2.2",
|
|
109
|
+
"mocha-headless-chrome": "^4.0.0",
|
|
110
|
+
"parcel": "2.5.0",
|
|
111
|
+
"process": "^0.11.10",
|
|
112
|
+
"rollup": "^2.70.2",
|
|
84
113
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
85
114
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
86
115
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
87
|
-
"rollup-plugin-typescript2": "^0.
|
|
88
|
-
"size-limit": "^
|
|
89
|
-
"ts-mocha": "^
|
|
116
|
+
"rollup-plugin-typescript2": "^0.31.2",
|
|
117
|
+
"size-limit": "^7.0.8",
|
|
118
|
+
"ts-mocha": "^9.0.2",
|
|
90
119
|
"ts-node": "^9.1.1",
|
|
91
|
-
"typescript": "
|
|
120
|
+
"typescript": "4.6.3"
|
|
92
121
|
},
|
|
93
122
|
"keywords": [
|
|
94
123
|
"canvas",
|