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/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.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
- pattern.setTransform({
102
- a: m[0],
103
- b: m[1],
104
- c: m[2],
105
- d: m[3],
106
- e: m[4],
107
- f: m[5],
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 + roundingOffset,
279
- height: height + roundingOffset,
280
- x: -Math.round(strokeWidth / 2 + blurRadius) +
277
+ width: width,
278
+ height: height,
279
+ x: -(strokeWidth / 2 + blurRadius) +
281
280
  Math.min(shadowOffsetX, 0) +
282
281
  fillRect.x,
283
- y: -Math.round(strokeWidth / 2 + blurRadius) +
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: Math.round(boundLeft),
42
- y: Math.round(clockwise ? -1 * boundBottom : boundTop),
43
- width: Math.round(boundRight - boundLeft),
44
- height: Math.round(boundBottom - boundTop)
41
+ x: boundLeft,
42
+ y: clockwise ? -1 * boundBottom : boundTop,
43
+ width: boundRight - boundLeft,
44
+ height: boundBottom - boundTop,
45
45
  };
46
46
  }
47
47
  }
@@ -9,8 +9,8 @@ export declare class Path extends Shape<PathConfig> {
9
9
  constructor(config?: PathConfig);
10
10
  _sceneFunc(context: any): void;
11
11
  getSelfRect(): {
12
- x: number;
13
- y: number;
12
+ x: any;
13
+ y: any;
14
14
  width: number;
15
15
  height: number;
16
16
  };
@@ -117,10 +117,10 @@ export class Path extends Shape {
117
117
  }
118
118
  }
119
119
  return {
120
- x: Math.round(minX),
121
- y: Math.round(minY),
122
- width: Math.round(maxX - minX),
123
- height: Math.round(maxY - minY),
120
+ x: minX,
121
+ y: minY,
122
+ width: maxX - minX,
123
+ height: maxY - minY,
124
124
  };
125
125
  }
126
126
  getLength() {
@@ -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",
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.0.0-beta.2",
64
- "@size-limit/preset-big-lib": "^5.0.4",
65
- "@types/mocha": "^9.0.0",
66
- "canvas": "^2.8.0",
67
- "chai": "4.3.4",
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": "8.4.0",
81
- "mocha-headless-chrome": "^3.1.0",
82
- "parcel": "2.0.0-beta.2",
83
- "rollup": "^2.57.0",
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.30.0",
88
- "size-limit": "^5.0.4",
89
- "ts-mocha": "^8.0.0",
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.4.3"
92
+ "typescript": "^4.5.5"
92
93
  },
93
94
  "keywords": [
94
95
  "canvas",