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.
Files changed (138) hide show
  1. package/README.md +3 -0
  2. package/cmj/Node.js +5 -5
  3. package/cmj/Shape.js +15 -16
  4. package/cmj/Util.js +6 -1
  5. package/cmj/index-node.js +1 -0
  6. package/cmj/shapes/Arc.js +16 -24
  7. package/cmj/shapes/Image.d.ts +1 -1
  8. package/cmj/shapes/Image.js +2 -1
  9. package/cmj/shapes/Path.d.ts +2 -2
  10. package/cmj/shapes/Path.js +4 -4
  11. package/cmj/shapes/Text.d.ts +1 -0
  12. package/cmj/shapes/Text.js +10 -3
  13. package/cmj/shapes/TextPath.js +1 -1
  14. package/cmj/shapes/Transformer.js +2 -2
  15. package/konva.js +80 -65
  16. package/konva.min.js +3 -3
  17. package/lib/Animation.js +0 -1
  18. package/lib/Canvas.js +0 -1
  19. package/lib/Container.js +0 -1
  20. package/lib/Context.js +0 -1
  21. package/lib/Core.js +0 -1
  22. package/lib/DragAndDrop.js +0 -1
  23. package/lib/Factory.js +0 -1
  24. package/lib/FastLayer.js +0 -1
  25. package/lib/Global.js +1 -2
  26. package/lib/Group.js +0 -1
  27. package/lib/Layer.js +0 -1
  28. package/lib/Node.js +5 -6
  29. package/lib/PointerEvents.js +0 -1
  30. package/lib/Shape.js +15 -17
  31. package/lib/Stage.js +0 -1
  32. package/lib/Tween.js +0 -1
  33. package/lib/Util.js +6 -2
  34. package/lib/Validators.js +0 -1
  35. package/lib/_CoreInternals.js +0 -1
  36. package/lib/_FullInternals.js +0 -1
  37. package/lib/filters/Blur.js +0 -1
  38. package/lib/filters/Brighten.js +0 -1
  39. package/lib/filters/Contrast.js +0 -1
  40. package/lib/filters/Emboss.js +0 -1
  41. package/lib/filters/Enhance.js +0 -1
  42. package/lib/filters/Grayscale.js +0 -1
  43. package/lib/filters/HSL.js +0 -1
  44. package/lib/filters/HSV.js +0 -1
  45. package/lib/filters/Invert.js +0 -1
  46. package/lib/filters/Kaleidoscope.js +0 -1
  47. package/lib/filters/Mask.js +0 -1
  48. package/lib/filters/Noise.js +0 -1
  49. package/lib/filters/Pixelate.js +0 -1
  50. package/lib/filters/Posterize.js +0 -1
  51. package/lib/filters/RGB.js +0 -1
  52. package/lib/filters/RGBA.js +0 -1
  53. package/lib/filters/Sepia.js +0 -1
  54. package/lib/filters/Solarize.js +0 -1
  55. package/lib/filters/Threshold.js +0 -1
  56. package/lib/index-node.js +1 -1
  57. package/lib/index.js +0 -1
  58. package/lib/shapes/Arc.js +16 -25
  59. package/lib/shapes/Arrow.js +0 -1
  60. package/lib/shapes/Circle.js +0 -1
  61. package/lib/shapes/Ellipse.js +0 -1
  62. package/lib/shapes/Image.d.ts +1 -1
  63. package/lib/shapes/Image.js +2 -2
  64. package/lib/shapes/Label.js +0 -1
  65. package/lib/shapes/Line.js +0 -1
  66. package/lib/shapes/Path.d.ts +2 -2
  67. package/lib/shapes/Path.js +4 -5
  68. package/lib/shapes/Rect.js +0 -1
  69. package/lib/shapes/RegularPolygon.js +0 -1
  70. package/lib/shapes/Ring.js +0 -1
  71. package/lib/shapes/Sprite.js +0 -1
  72. package/lib/shapes/Star.js +0 -1
  73. package/lib/shapes/Text.d.ts +1 -0
  74. package/lib/shapes/Text.js +10 -4
  75. package/lib/shapes/TextPath.js +1 -2
  76. package/lib/shapes/Transformer.js +2 -3
  77. package/lib/shapes/Wedge.js +0 -1
  78. package/lib/types.js +0 -1
  79. package/package.json +15 -14
  80. package/lib/Animation.js.map +0 -1
  81. package/lib/Canvas.js.map +0 -1
  82. package/lib/Container.js.map +0 -1
  83. package/lib/Context.js.map +0 -1
  84. package/lib/Core.js.map +0 -1
  85. package/lib/DragAndDrop.js.map +0 -1
  86. package/lib/Factory.js.map +0 -1
  87. package/lib/FastLayer.js.map +0 -1
  88. package/lib/Global.js.map +0 -1
  89. package/lib/Group.js.map +0 -1
  90. package/lib/Layer.js.map +0 -1
  91. package/lib/Node.js.map +0 -1
  92. package/lib/PointerEvents.js.map +0 -1
  93. package/lib/Shape.js.map +0 -1
  94. package/lib/Stage.js.map +0 -1
  95. package/lib/Tween.js.map +0 -1
  96. package/lib/Util.js.map +0 -1
  97. package/lib/Validators.js.map +0 -1
  98. package/lib/_CoreInternals.js.map +0 -1
  99. package/lib/_FullInternals.js.map +0 -1
  100. package/lib/filters/Blur.js.map +0 -1
  101. package/lib/filters/Brighten.js.map +0 -1
  102. package/lib/filters/Contrast.js.map +0 -1
  103. package/lib/filters/Emboss.js.map +0 -1
  104. package/lib/filters/Enhance.js.map +0 -1
  105. package/lib/filters/Grayscale.js.map +0 -1
  106. package/lib/filters/HSL.js.map +0 -1
  107. package/lib/filters/HSV.js.map +0 -1
  108. package/lib/filters/Invert.js.map +0 -1
  109. package/lib/filters/Kaleidoscope.js.map +0 -1
  110. package/lib/filters/Mask.js.map +0 -1
  111. package/lib/filters/Noise.js.map +0 -1
  112. package/lib/filters/Pixelate.js.map +0 -1
  113. package/lib/filters/Posterize.js.map +0 -1
  114. package/lib/filters/RGB.js.map +0 -1
  115. package/lib/filters/RGBA.js.map +0 -1
  116. package/lib/filters/Sepia.js.map +0 -1
  117. package/lib/filters/Solarize.js.map +0 -1
  118. package/lib/filters/Threshold.js.map +0 -1
  119. package/lib/index-node.js.map +0 -1
  120. package/lib/index.js.map +0 -1
  121. package/lib/shapes/Arc.js.map +0 -1
  122. package/lib/shapes/Arrow.js.map +0 -1
  123. package/lib/shapes/Circle.js.map +0 -1
  124. package/lib/shapes/Ellipse.js.map +0 -1
  125. package/lib/shapes/Image.js.map +0 -1
  126. package/lib/shapes/Label.js.map +0 -1
  127. package/lib/shapes/Line.js.map +0 -1
  128. package/lib/shapes/Path.js.map +0 -1
  129. package/lib/shapes/Rect.js.map +0 -1
  130. package/lib/shapes/RegularPolygon.js.map +0 -1
  131. package/lib/shapes/Ring.js.map +0 -1
  132. package/lib/shapes/Sprite.js.map +0 -1
  133. package/lib/shapes/Star.js.map +0 -1
  134. package/lib/shapes/Text.js.map +0 -1
  135. package/lib/shapes/TextPath.js.map +0 -1
  136. package/lib/shapes/Transformer.js.map +0 -1
  137. package/lib/shapes/Wedge.js.map +0 -1
  138. package/lib/types.js.map +0 -1
package/lib/Animation.js CHANGED
@@ -139,4 +139,3 @@ export class Animation {
139
139
  Animation.animations = [];
140
140
  Animation.animIdCounter = 0;
141
141
  Animation.animRunning = false;
142
- //# sourceMappingURL=Animation.js.map
package/lib/Canvas.js CHANGED
@@ -105,4 +105,3 @@ export class HitCanvas extends Canvas {
105
105
  this.setSize(config.width, config.height);
106
106
  }
107
107
  }
108
- //# sourceMappingURL=Canvas.js.map
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
@@ -518,4 +518,3 @@ export class HitContext extends Context {
518
518
  }
519
519
  }
520
520
  }
521
- //# sourceMappingURL=Context.js.map
package/lib/Core.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export { Konva } from './_CoreInternals.js';
2
2
  import { Konva } from './_CoreInternals.js';
3
3
  export default Konva;
4
- //# sourceMappingURL=Core.js.map
@@ -102,4 +102,3 @@ if (Konva.isBrowser) {
102
102
  window.addEventListener('mouseup', DD._endDragAfter, false);
103
103
  window.addEventListener('touchend', DD._endDragAfter, false);
104
104
  }
105
- //# sourceMappingURL=DragAndDrop.js.map
package/lib/Factory.js CHANGED
@@ -115,4 +115,3 @@ export const Factory = {
115
115
  this._filterUpToDate = false;
116
116
  },
117
117
  };
118
- //# sourceMappingURL=Factory.js.map
package/lib/FastLayer.js CHANGED
@@ -10,4 +10,3 @@ export class FastLayer extends Layer {
10
10
  }
11
11
  FastLayer.prototype.nodeType = 'FastLayer';
12
12
  _registerNode(FastLayer);
13
- //# sourceMappingURL=FastLayer.js.map
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.1',
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
@@ -11,4 +11,3 @@ export class Group extends Container {
11
11
  }
12
12
  Group.prototype.nodeType = 'Group';
13
13
  _registerNode(Group);
14
- //# sourceMappingURL=Group.js.map
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
@@ -35,4 +35,3 @@ export function releaseCapture(pointerId, target) {
35
35
  shape._fire('lostpointercapture', createEvent(new PointerEvent('lostpointercapture')));
36
36
  }
37
37
  }
38
- //# sourceMappingURL=PointerEvents.js.map
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
  };
@@ -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
@@ -685,4 +685,3 @@ export class Stage extends Container {
685
685
  Stage.prototype.nodeType = STAGE;
686
686
  _registerNode(Stage);
687
687
  Factory.addGetterSetter(Stage, 'container');
688
- //# sourceMappingURL=Stage.js.map
package/lib/Tween.js CHANGED
@@ -514,4 +514,3 @@ export const Easings = {
514
514
  return (c * t) / d + b;
515
515
  },
516
516
  };
517
- //# sourceMappingURL=Tween.js.map
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(Number);
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
@@ -169,4 +169,3 @@ export function getComponentValidator(components) {
169
169
  };
170
170
  }
171
171
  }
172
- //# sourceMappingURL=Validators.js.map
@@ -32,4 +32,3 @@ export const Konva = Util._assign(Global, {
32
32
  Canvas,
33
33
  });
34
34
  export default Konva;
35
- //# sourceMappingURL=_CoreInternals.js.map
@@ -76,4 +76,3 @@ export const Konva = Core.Util._assign(Core, {
76
76
  Threshold,
77
77
  },
78
78
  });
79
- //# sourceMappingURL=_FullInternals.js.map
@@ -695,4 +695,3 @@ export const Blur = function Blur(imageData) {
695
695
  }
696
696
  };
697
697
  Factory.addGetterSetter(Node, 'blurRadius', 0, getNumberValidator(), Factory.afterSetFilter);
698
- //# sourceMappingURL=Blur.js.map
@@ -10,4 +10,3 @@ export const Brighten = function (imageData) {
10
10
  }
11
11
  };
12
12
  Factory.addGetterSetter(Node, 'brightness', 0, getNumberValidator(), Factory.afterSetFilter);
13
- //# sourceMappingURL=Brighten.js.map
@@ -32,4 +32,3 @@ export const Contrast = function (imageData) {
32
32
  }
33
33
  };
34
34
  Factory.addGetterSetter(Node, 'contrast', 0, getNumberValidator(), Factory.afterSetFilter);
35
- //# sourceMappingURL=Contrast.js.map
@@ -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
@@ -81,4 +81,3 @@ export const Enhance = function (imageData) {
81
81
  }
82
82
  };
83
83
  Factory.addGetterSetter(Node, 'enhance', 0, getNumberValidator(), Factory.afterSetFilter);
84
- //# sourceMappingURL=Enhance.js.map
@@ -7,4 +7,3 @@ export const Grayscale = function (imageData) {
7
7
  data[i + 2] = brightness;
8
8
  }
9
9
  };
10
- //# sourceMappingURL=Grayscale.js.map
@@ -22,4 +22,3 @@ export const HSL = function (imageData) {
22
22
  data[i + 3] = a;
23
23
  }
24
24
  };
25
- //# sourceMappingURL=HSL.js.map
@@ -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
@@ -6,4 +6,3 @@ export const Invert = function (imageData) {
6
6
  data[i + 2] = 255 - data[i + 2];
7
7
  }
8
8
  };
9
- //# sourceMappingURL=Invert.js.map
@@ -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
@@ -138,4 +138,3 @@ export const Mask = function (imageData) {
138
138
  return imageData;
139
139
  };
140
140
  Factory.addGetterSetter(Node, 'threshold', 0, getNumberValidator(), Factory.afterSetFilter);
141
- //# sourceMappingURL=Mask.js.map
@@ -10,4 +10,3 @@ export const Noise = function (imageData) {
10
10
  }
11
11
  };
12
12
  Factory.addGetterSetter(Node, 'noise', 0.2, getNumberValidator(), Factory.afterSetFilter);
13
- //# sourceMappingURL=Noise.js.map
@@ -58,4 +58,3 @@ export const Pixelate = function (imageData) {
58
58
  }
59
59
  };
60
60
  Factory.addGetterSetter(Node, 'pixelSize', 8, getNumberValidator(), Factory.afterSetFilter);
61
- //# sourceMappingURL=Pixelate.js.map
@@ -8,4 +8,3 @@ export const Posterize = function (imageData) {
8
8
  }
9
9
  };
10
10
  Factory.addGetterSetter(Node, 'levels', 0.5, getNumberValidator(), Factory.afterSetFilter);
11
- //# sourceMappingURL=Posterize.js.map
@@ -37,4 +37,3 @@ Factory.addGetterSetter(Node, 'green', 0, function (val) {
37
37
  }
38
38
  });
39
39
  Factory.addGetterSetter(Node, 'blue', 0, RGBComponent, Factory.afterSetFilter);
40
- //# sourceMappingURL=RGB.js.map
@@ -47,4 +47,3 @@ Factory.addGetterSetter(Node, 'alpha', 1, function (val) {
47
47
  return val;
48
48
  }
49
49
  });
50
- //# sourceMappingURL=RGBA.js.map
@@ -9,4 +9,3 @@ export const Sepia = function (imageData) {
9
9
  data[i + 2] = Math.min(255, r * 0.272 + g * 0.534 + b * 0.131);
10
10
  }
11
11
  };
12
- //# sourceMappingURL=Sepia.js.map
@@ -23,4 +23,3 @@ export const Solarize = function (imageData) {
23
23
  } while (--x);
24
24
  } while (--y);
25
25
  };
26
- //# sourceMappingURL=Solarize.js.map
@@ -8,4 +8,3 @@ export const Threshold = function (imageData) {
8
8
  }
9
9
  };
10
10
  Factory.addGetterSetter(Node, 'threshold', 0.5, getNumberValidator(), Factory.afterSetFilter);
11
- //# sourceMappingURL=Threshold.js.map
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
@@ -1,3 +1,2 @@
1
1
  import { Konva } from './_FullInternals.js';
2
2
  export default Konva;
3
- //# sourceMappingURL=index.js.map
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 radius = this.outerRadius();
29
- const DEG_TO_RAD = Math.PI / 180;
30
- const angle = this.angle() * DEG_TO_RAD;
31
- const inc = 1 * DEG_TO_RAD;
32
- let start = 0;
33
- let end = angle + inc;
34
- if (this.clockwise()) {
35
- start = end;
36
- end = 360;
37
- }
38
- const xs = [];
39
- const ys = [];
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: minX || 0,
50
- y: minY || 0,
51
- width: maxX - minX,
52
- height: maxY - minY
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
@@ -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
@@ -31,4 +31,3 @@ Circle.prototype.className = 'Circle';
31
31
  Circle.prototype._attrsAffectingSize = ['radius'];
32
32
  _registerNode(Circle);
33
33
  Factory.addGetterSetter(Circle, 'radius', 0, getNumberValidator());
34
- //# sourceMappingURL=Circle.js.map
@@ -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
@@ -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>;
@@ -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
@@ -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
@@ -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
@@ -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() {
@@ -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
@@ -40,4 +40,3 @@ export class Rect extends Shape {
40
40
  Rect.prototype.className = 'Rect';
41
41
  _registerNode(Rect);
42
42
  Factory.addGetterSetter(Rect, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
43
- //# sourceMappingURL=Rect.js.map
@@ -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
@@ -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
@@ -106,4 +106,3 @@ Factory.backCompat(Sprite, {
106
106
  getIndex: 'getFrameIndex',
107
107
  setIndex: 'setFrameIndex',
108
108
  });
109
- //# sourceMappingURL=Sprite.js.map
@@ -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
@@ -20,6 +20,7 @@ export declare class Text extends Shape<TextConfig> {
20
20
  textArr: Array<{
21
21
  text: string;
22
22
  width: number;
23
+ lastInParagraph: boolean;
23
24
  }>;
24
25
  _partialText: string;
25
26
  _partialTextX: number;
@@ -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 = n !== textArrLen - 1, spacesNumber, oneWord, lineWidth;
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 === ' ' && n !== textArrLen - 1 && align === JUSTIFY) {
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({ text: line, width: width });
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
@@ -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