konva 9.3.14 → 9.3.16

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 (68) hide show
  1. package/konva.js +754 -737
  2. package/konva.min.js +3 -3
  3. package/lib/Animation.js +1 -1
  4. package/lib/BezierFunctions.js +1 -2
  5. package/lib/Canvas.js +9 -9
  6. package/lib/Container.d.ts +1 -1
  7. package/lib/Container.js +29 -29
  8. package/lib/Context.d.ts +2 -2
  9. package/lib/Context.js +26 -26
  10. package/lib/DragAndDrop.d.ts +2 -2
  11. package/lib/DragAndDrop.js +6 -4
  12. package/lib/Factory.js +16 -16
  13. package/lib/Global.js +1 -1
  14. package/lib/Group.js +1 -1
  15. package/lib/Layer.js +17 -17
  16. package/lib/Node.d.ts +4 -4
  17. package/lib/Node.js +87 -87
  18. package/lib/PointerEvents.js +5 -6
  19. package/lib/Shape.js +31 -31
  20. package/lib/Stage.d.ts +3 -3
  21. package/lib/Stage.js +28 -28
  22. package/lib/Tween.js +21 -21
  23. package/lib/Util.d.ts +4 -4
  24. package/lib/Util.js +62 -62
  25. package/lib/Validators.js +16 -17
  26. package/lib/_CoreInternals.d.ts +8 -8
  27. package/lib/_FullInternals.d.ts +8 -8
  28. package/lib/filters/Blur.js +6 -6
  29. package/lib/filters/Brighten.js +1 -1
  30. package/lib/filters/Contrast.js +2 -2
  31. package/lib/filters/Emboss.js +19 -19
  32. package/lib/filters/Enhance.js +4 -4
  33. package/lib/filters/Grayscale.js +1 -1
  34. package/lib/filters/HSL.js +6 -6
  35. package/lib/filters/HSV.js +7 -7
  36. package/lib/filters/Invert.js +1 -1
  37. package/lib/filters/Kaleidoscope.js +20 -20
  38. package/lib/filters/Mask.js +57 -57
  39. package/lib/filters/Noise.js +2 -2
  40. package/lib/filters/Pixelate.js +1 -1
  41. package/lib/filters/Posterize.js +1 -1
  42. package/lib/filters/RGB.js +1 -1
  43. package/lib/filters/RGBA.js +3 -3
  44. package/lib/filters/Sepia.js +1 -1
  45. package/lib/filters/Solarize.js +8 -7
  46. package/lib/filters/Threshold.js +2 -2
  47. package/lib/shapes/Arc.js +1 -1
  48. package/lib/shapes/Arrow.js +10 -10
  49. package/lib/shapes/Ellipse.js +1 -1
  50. package/lib/shapes/Image.js +3 -3
  51. package/lib/shapes/Label.d.ts +1 -1
  52. package/lib/shapes/Label.js +6 -6
  53. package/lib/shapes/Line.d.ts +1 -1
  54. package/lib/shapes/Line.js +14 -14
  55. package/lib/shapes/Path.d.ts +8 -8
  56. package/lib/shapes/Path.js +68 -68
  57. package/lib/shapes/Rect.js +1 -1
  58. package/lib/shapes/RegularPolygon.js +6 -6
  59. package/lib/shapes/Ring.js +1 -1
  60. package/lib/shapes/Sprite.js +9 -9
  61. package/lib/shapes/Star.js +5 -5
  62. package/lib/shapes/Text.d.ts +13 -13
  63. package/lib/shapes/Text.js +52 -38
  64. package/lib/shapes/TextPath.d.ts +2 -2
  65. package/lib/shapes/TextPath.js +23 -23
  66. package/lib/shapes/Transformer.d.ts +1 -1
  67. package/lib/shapes/Transformer.js +63 -63
  68. package/package.json +2 -5
package/lib/Node.js CHANGED
@@ -7,7 +7,7 @@ const Canvas_1 = require("./Canvas");
7
7
  const Global_1 = require("./Global");
8
8
  const DragAndDrop_1 = require("./DragAndDrop");
9
9
  const Validators_1 = require("./Validators");
10
- var ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', NAME = 'name', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [
10
+ const ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', NAME = 'name', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [
11
11
  'xChange.konva',
12
12
  'yChange.konva',
13
13
  'scaleXChange.konva',
@@ -56,9 +56,9 @@ class Node {
56
56
  }
57
57
  }
58
58
  _getCache(attr, privateGetter) {
59
- var cache = this._cache.get(attr);
60
- var isTransform = attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM;
61
- var invalid = cache === undefined || (isTransform && cache.dirty === true);
59
+ let cache = this._cache.get(attr);
60
+ const isTransform = attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM;
61
+ const invalid = cache === undefined || (isTransform && cache.dirty === true);
62
62
  if (invalid) {
63
63
  cache = privateGetter.call(this);
64
64
  this._cache.set(attr, cache);
@@ -95,8 +95,8 @@ class Node {
95
95
  return this;
96
96
  }
97
97
  cache(config) {
98
- var conf = config || {};
99
- var rect = {};
98
+ const conf = config || {};
99
+ let rect = {};
100
100
  if (conf.x === undefined ||
101
101
  conf.y === undefined ||
102
102
  conf.width === undefined ||
@@ -106,7 +106,7 @@ class Node {
106
106
  relativeTo: this.getParent() || undefined,
107
107
  });
108
108
  }
109
- 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;
109
+ let 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;
110
110
  if (!width || !height) {
111
111
  Util_1.Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
112
112
  return;
@@ -117,7 +117,7 @@ class Node {
117
117
  height += offset * 2 + extraPaddingY;
118
118
  x -= offset;
119
119
  y -= offset;
120
- var cachedSceneCanvas = new Canvas_1.SceneCanvas({
120
+ const cachedSceneCanvas = new Canvas_1.SceneCanvas({
121
121
  pixelRatio: pixelRatio,
122
122
  width: width,
123
123
  height: height,
@@ -178,16 +178,16 @@ class Node {
178
178
  throw new Error('abstract "getClientRect" method call');
179
179
  }
180
180
  _transformedRect(rect, top) {
181
- var points = [
181
+ const points = [
182
182
  { x: rect.x, y: rect.y },
183
183
  { x: rect.x + rect.width, y: rect.y },
184
184
  { x: rect.x + rect.width, y: rect.y + rect.height },
185
185
  { x: rect.x, y: rect.y + rect.height },
186
186
  ];
187
- var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
188
- var trans = this.getAbsoluteTransform(top);
187
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
188
+ const trans = this.getAbsoluteTransform(top);
189
189
  points.forEach(function (point) {
190
- var transformed = trans.point(point);
190
+ const transformed = trans.point(point);
191
191
  if (minX === undefined) {
192
192
  minX = maxX = transformed.x;
193
193
  minY = maxY = transformed.y;
@@ -210,23 +210,23 @@ class Node {
210
210
  context._applyGlobalCompositeOperation(this);
211
211
  const canvasCache = this._getCanvasCache();
212
212
  context.translate(canvasCache.x, canvasCache.y);
213
- var cacheCanvas = this._getCachedSceneCanvas();
214
- var ratio = cacheCanvas.pixelRatio;
213
+ const cacheCanvas = this._getCachedSceneCanvas();
214
+ const ratio = cacheCanvas.pixelRatio;
215
215
  context.drawImage(cacheCanvas._canvas, 0, 0, cacheCanvas.width / ratio, cacheCanvas.height / ratio);
216
216
  context.restore();
217
217
  }
218
218
  _drawCachedHitCanvas(context) {
219
- var canvasCache = this._getCanvasCache(), hitCanvas = canvasCache.hit;
219
+ const canvasCache = this._getCanvasCache(), hitCanvas = canvasCache.hit;
220
220
  context.save();
221
221
  context.translate(canvasCache.x, canvasCache.y);
222
222
  context.drawImage(hitCanvas._canvas, 0, 0, hitCanvas.width / hitCanvas.pixelRatio, hitCanvas.height / hitCanvas.pixelRatio);
223
223
  context.restore();
224
224
  }
225
225
  _getCachedSceneCanvas() {
226
- var filters = this.filters(), cachedCanvas = this._getCanvasCache(), sceneCanvas = cachedCanvas.scene, filterCanvas = cachedCanvas.filter, filterContext = filterCanvas.getContext(), len, imageData, n, filter;
226
+ let filters = this.filters(), cachedCanvas = this._getCanvasCache(), sceneCanvas = cachedCanvas.scene, filterCanvas = cachedCanvas.filter, filterContext = filterCanvas.getContext(), len, imageData, n, filter;
227
227
  if (filters) {
228
228
  if (!this._filterUpToDate) {
229
- var ratio = sceneCanvas.pixelRatio;
229
+ const ratio = sceneCanvas.pixelRatio;
230
230
  filterCanvas.setSize(sceneCanvas.width / sceneCanvas.pixelRatio, sceneCanvas.height / sceneCanvas.pixelRatio);
231
231
  try {
232
232
  len = filters.length;
@@ -261,7 +261,7 @@ class Node {
261
261
  if (arguments.length === 3) {
262
262
  return this._delegate.apply(this, arguments);
263
263
  }
264
- var events = evtStr.split(SPACE), len = events.length, n, event, parts, baseEvent, name;
264
+ let events = evtStr.split(SPACE), len = events.length, n, event, parts, baseEvent, name;
265
265
  for (n = 0; n < len; n++) {
266
266
  event = events[n];
267
267
  parts = event.split('.');
@@ -278,7 +278,7 @@ class Node {
278
278
  return this;
279
279
  }
280
280
  off(evtStr, callback) {
281
- var events = (evtStr || '').split(SPACE), len = events.length, n, t, event, parts, baseEvent, name;
281
+ let events = (evtStr || '').split(SPACE), len = events.length, n, t, event, parts, baseEvent, name;
282
282
  this._cache && this._cache.delete(ALL_LISTENERS);
283
283
  if (!evtStr) {
284
284
  for (t in this.eventListeners) {
@@ -304,7 +304,7 @@ class Node {
304
304
  return this;
305
305
  }
306
306
  dispatchEvent(evt) {
307
- var e = {
307
+ const e = {
308
308
  target: this,
309
309
  type: evt.type,
310
310
  evt: evt,
@@ -323,10 +323,10 @@ class Node {
323
323
  return this;
324
324
  }
325
325
  _delegate(event, selector, handler) {
326
- var stopNode = this;
326
+ const stopNode = this;
327
327
  this.on(event, function (evt) {
328
- var targets = evt.target.findAncestors(selector, true, stopNode);
329
- for (var i = 0; i < targets.length; i++) {
328
+ const targets = evt.target.findAncestors(selector, true, stopNode);
329
+ for (let i = 0; i < targets.length; i++) {
330
330
  evt = Util_1.Util.cloneObject(evt);
331
331
  evt.currentTarget = targets[i];
332
332
  handler.call(targets[i], evt);
@@ -351,7 +351,7 @@ class Node {
351
351
  }
352
352
  _remove() {
353
353
  this._clearCaches();
354
- var parent = this.getParent();
354
+ const parent = this.getParent();
355
355
  if (parent && parent.children) {
356
356
  parent.children.splice(this.index, 1);
357
357
  parent._setChildrenIndices();
@@ -364,14 +364,14 @@ class Node {
364
364
  return this;
365
365
  }
366
366
  getAttr(attr) {
367
- var method = 'get' + Util_1.Util._capitalize(attr);
367
+ const method = 'get' + Util_1.Util._capitalize(attr);
368
368
  if (Util_1.Util._isFunction(this[method])) {
369
369
  return this[method]();
370
370
  }
371
371
  return this.attrs[attr];
372
372
  }
373
373
  getAncestors() {
374
- var parent = this.getParent(), ancestors = [];
374
+ let parent = this.getParent(), ancestors = [];
375
375
  while (parent) {
376
376
  ancestors.push(parent);
377
377
  parent = parent.getParent();
@@ -383,7 +383,7 @@ class Node {
383
383
  }
384
384
  setAttrs(config) {
385
385
  this._batchTransformChanges(() => {
386
- var key, method;
386
+ let key, method;
387
387
  if (!config) {
388
388
  return this;
389
389
  }
@@ -438,8 +438,8 @@ class Node {
438
438
  if (top) {
439
439
  return this._isVisible(top) && this._isListening(top);
440
440
  }
441
- var layer = this.getLayer();
442
- var layerUnderDrag = false;
441
+ const layer = this.getLayer();
442
+ let layerUnderDrag = false;
443
443
  DragAndDrop_1.DD._dragElements.forEach((elem) => {
444
444
  if (elem.dragStatus !== 'dragging') {
445
445
  return;
@@ -451,7 +451,7 @@ class Node {
451
451
  layerUnderDrag = true;
452
452
  }
453
453
  });
454
- var dragSkip = !skipDragCheck &&
454
+ const dragSkip = !skipDragCheck &&
455
455
  !Global_1.Konva.hitOnDragEnabled &&
456
456
  (layerUnderDrag || Global_1.Konva.isTransforming());
457
457
  return this.isListening() && this.isVisible() && !dragSkip;
@@ -468,7 +468,7 @@ class Node {
468
468
  return this.index || 0;
469
469
  }
470
470
  getAbsoluteZIndex() {
471
- var depth = this.getDepth(), that = this, index = 0, nodes, len, n, child;
471
+ let depth = this.getDepth(), that = this, index = 0, nodes, len, n, child;
472
472
  function addChildren(children) {
473
473
  nodes = [];
474
474
  len = children.length;
@@ -493,7 +493,7 @@ class Node {
493
493
  return index;
494
494
  }
495
495
  getDepth() {
496
- var depth = 0, parent = this.parent;
496
+ let depth = 0, parent = this.parent;
497
497
  while (parent) {
498
498
  depth++;
499
499
  parent = parent.parent;
@@ -528,11 +528,11 @@ class Node {
528
528
  if (!stage) {
529
529
  return null;
530
530
  }
531
- var pos = stage.getPointerPosition();
531
+ const pos = stage.getPointerPosition();
532
532
  if (!pos) {
533
533
  return null;
534
534
  }
535
- var transform = this.getAbsoluteTransform().copy();
535
+ const transform = this.getAbsoluteTransform().copy();
536
536
  transform.invert();
537
537
  return transform.point(pos);
538
538
  }
@@ -549,7 +549,7 @@ class Node {
549
549
  if (haveCachedParent && !top) {
550
550
  top = true;
551
551
  }
552
- var absoluteMatrix = this.getAbsoluteTransform(top).getMatrix(), absoluteTransform = new Util_1.Transform(), offset = this.offset();
552
+ const absoluteMatrix = this.getAbsoluteTransform(top).getMatrix(), absoluteTransform = new Util_1.Transform(), offset = this.offset();
553
553
  absoluteTransform.m = absoluteMatrix.slice();
554
554
  absoluteTransform.translate(offset.x, offset.y);
555
555
  return absoluteTransform.getTranslation();
@@ -559,7 +559,7 @@ class Node {
559
559
  this.attrs.x = x;
560
560
  this.attrs.y = y;
561
561
  this._clearCache(TRANSFORM);
562
- var it = this._getAbsoluteTransform().copy();
562
+ const it = this._getAbsoluteTransform().copy();
563
563
  it.invert();
564
564
  it.translate(pos.x, pos.y);
565
565
  pos = {
@@ -573,13 +573,13 @@ class Node {
573
573
  return this;
574
574
  }
575
575
  _setTransform(trans) {
576
- var key;
576
+ let key;
577
577
  for (key in trans) {
578
578
  this.attrs[key] = trans[key];
579
579
  }
580
580
  }
581
581
  _clearTransform() {
582
- var trans = {
582
+ const trans = {
583
583
  x: this.x(),
584
584
  y: this.y(),
585
585
  rotation: this.rotation(),
@@ -602,7 +602,7 @@ class Node {
602
602
  return trans;
603
603
  }
604
604
  move(change) {
605
- var changeX = change.x, changeY = change.y, x = this.x(), y = this.y();
605
+ let changeX = change.x, changeY = change.y, x = this.x(), y = this.y();
606
606
  if (changeX !== undefined) {
607
607
  x += changeX;
608
608
  }
@@ -613,7 +613,7 @@ class Node {
613
613
  return this;
614
614
  }
615
615
  _eachAncestorReverse(func, top) {
616
- var family = [], parent = this.getParent(), len, n;
616
+ let family = [], parent = this.getParent(), len, n;
617
617
  if (top && top._id === this._id) {
618
618
  return;
619
619
  }
@@ -636,7 +636,7 @@ class Node {
636
636
  Util_1.Util.warn('Node has no parent. moveToTop function is ignored.');
637
637
  return false;
638
638
  }
639
- var index = this.index, len = this.parent.getChildren().length;
639
+ const index = this.index, len = this.parent.getChildren().length;
640
640
  if (index < len - 1) {
641
641
  this.parent.children.splice(index, 1);
642
642
  this.parent.children.push(this);
@@ -650,7 +650,7 @@ class Node {
650
650
  Util_1.Util.warn('Node has no parent. moveUp function is ignored.');
651
651
  return false;
652
652
  }
653
- var index = this.index, len = this.parent.getChildren().length;
653
+ const index = this.index, len = this.parent.getChildren().length;
654
654
  if (index < len - 1) {
655
655
  this.parent.children.splice(index, 1);
656
656
  this.parent.children.splice(index + 1, 0, this);
@@ -664,7 +664,7 @@ class Node {
664
664
  Util_1.Util.warn('Node has no parent. moveDown function is ignored.');
665
665
  return false;
666
666
  }
667
- var index = this.index;
667
+ const index = this.index;
668
668
  if (index > 0) {
669
669
  this.parent.children.splice(index, 1);
670
670
  this.parent.children.splice(index - 1, 0, this);
@@ -678,7 +678,7 @@ class Node {
678
678
  Util_1.Util.warn('Node has no parent. moveToBottom function is ignored.');
679
679
  return false;
680
680
  }
681
- var index = this.index;
681
+ const index = this.index;
682
682
  if (index > 0) {
683
683
  this.parent.children.splice(index, 1);
684
684
  this.parent.children.unshift(this);
@@ -699,7 +699,7 @@ class Node {
699
699
  (this.parent.children.length - 1) +
700
700
  '.');
701
701
  }
702
- var index = this.index;
702
+ const index = this.index;
703
703
  this.parent.children.splice(index, 1);
704
704
  this.parent.children.splice(zIndex, 0, this);
705
705
  this.parent._setChildrenIndices();
@@ -709,8 +709,8 @@ class Node {
709
709
  return this._getCache(ABSOLUTE_OPACITY, this._getAbsoluteOpacity);
710
710
  }
711
711
  _getAbsoluteOpacity() {
712
- var absOpacity = this.opacity();
713
- var parent = this.getParent();
712
+ let absOpacity = this.opacity();
713
+ const parent = this.getParent();
714
714
  if (parent && !parent._isUnderCache) {
715
715
  absOpacity *= parent.getAbsoluteOpacity();
716
716
  }
@@ -724,7 +724,7 @@ class Node {
724
724
  return this;
725
725
  }
726
726
  toObject() {
727
- var attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;
727
+ let attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;
728
728
  const obj = {
729
729
  attrs: {},
730
730
  className: this.getClassName(),
@@ -753,11 +753,11 @@ class Node {
753
753
  return this.parent;
754
754
  }
755
755
  findAncestors(selector, includeSelf, stopNode) {
756
- var res = [];
756
+ const res = [];
757
757
  if (includeSelf && this._isMatch(selector)) {
758
758
  res.push(this);
759
759
  }
760
- var ancestor = this.parent;
760
+ let ancestor = this.parent;
761
761
  while (ancestor) {
762
762
  if (ancestor === stopNode) {
763
763
  return res;
@@ -782,7 +782,7 @@ class Node {
782
782
  if (typeof selector === 'function') {
783
783
  return selector(this);
784
784
  }
785
- var selectorArr = selector.replace(/ /g, '').split(','), len = selectorArr.length, n, sel;
785
+ let selectorArr = selector.replace(/ /g, '').split(','), len = selectorArr.length, n, sel;
786
786
  for (n = 0; n < len; n++) {
787
787
  sel = selectorArr[n];
788
788
  if (!Util_1.Util.isValidSelector(sel)) {
@@ -809,14 +809,14 @@ class Node {
809
809
  return false;
810
810
  }
811
811
  getLayer() {
812
- var parent = this.getParent();
812
+ const parent = this.getParent();
813
813
  return parent ? parent.getLayer() : null;
814
814
  }
815
815
  getStage() {
816
816
  return this._getCache(STAGE, this._getStage);
817
817
  }
818
818
  _getStage() {
819
- var parent = this.getParent();
819
+ const parent = this.getParent();
820
820
  if (parent) {
821
821
  return parent.getStage();
822
822
  }
@@ -843,11 +843,11 @@ class Node {
843
843
  }
844
844
  }
845
845
  _getAbsoluteTransform(top) {
846
- var at;
846
+ let at;
847
847
  if (top) {
848
848
  at = new Util_1.Transform();
849
849
  this._eachAncestorReverse(function (node) {
850
- var transformsEnabled = node.transformsEnabled();
850
+ const transformsEnabled = node.transformsEnabled();
851
851
  if (transformsEnabled === 'all') {
852
852
  at.multiply(node.getTransform());
853
853
  }
@@ -865,7 +865,7 @@ class Node {
865
865
  else {
866
866
  at.reset();
867
867
  }
868
- var transformsEnabled = this.transformsEnabled();
868
+ const transformsEnabled = this.transformsEnabled();
869
869
  if (transformsEnabled === 'all') {
870
870
  at.multiply(this.getTransform());
871
871
  }
@@ -881,7 +881,7 @@ class Node {
881
881
  }
882
882
  }
883
883
  getAbsoluteScale(top) {
884
- var parent = this;
884
+ let parent = this;
885
885
  while (parent) {
886
886
  if (parent._isUnderCache) {
887
887
  top = parent;
@@ -903,9 +903,9 @@ class Node {
903
903
  }
904
904
  _getTransform() {
905
905
  var _a, _b;
906
- var m = this._cache.get(TRANSFORM) || new Util_1.Transform();
906
+ const m = this._cache.get(TRANSFORM) || new Util_1.Transform();
907
907
  m.reset();
908
- var x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
908
+ const x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
909
909
  if (x !== 0 || y !== 0) {
910
910
  m.translate(x, y);
911
911
  }
@@ -925,11 +925,11 @@ class Node {
925
925
  return m;
926
926
  }
927
927
  clone(obj) {
928
- var attrs = Util_1.Util.cloneObject(this.attrs), key, allListeners, len, n, listener;
928
+ let attrs = Util_1.Util.cloneObject(this.attrs), key, allListeners, len, n, listener;
929
929
  for (key in obj) {
930
930
  attrs[key] = obj[key];
931
931
  }
932
- var node = new this.constructor(attrs);
932
+ const node = new this.constructor(attrs);
933
933
  for (key in this.eventListeners) {
934
934
  allListeners = this.eventListeners[key];
935
935
  len = allListeners.length;
@@ -947,8 +947,8 @@ class Node {
947
947
  }
948
948
  _toKonvaCanvas(config) {
949
949
  config = config || {};
950
- var box = this.getClientRect();
951
- 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 Canvas_1.SceneCanvas({
950
+ const box = this.getClientRect();
951
+ const 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 Canvas_1.SceneCanvas({
952
952
  width: config.width || Math.ceil(box.width) || (stage ? stage.width() : 0),
953
953
  height: config.height ||
954
954
  Math.ceil(box.height) ||
@@ -976,8 +976,8 @@ class Node {
976
976
  }
977
977
  toDataURL(config) {
978
978
  config = config || {};
979
- var mimeType = config.mimeType || null, quality = config.quality || null;
980
- var url = this._toKonvaCanvas(config).toDataURL(mimeType, quality);
979
+ const mimeType = config.mimeType || null, quality = config.quality || null;
980
+ const url = this._toKonvaCanvas(config).toDataURL(mimeType, quality);
981
981
  if (config.callback) {
982
982
  config.callback(url);
983
983
  }
@@ -1044,7 +1044,7 @@ class Node {
1044
1044
  }
1045
1045
  }
1046
1046
  _off(type, name, callback) {
1047
- var evtListeners = this.eventListeners[type], i, evtName, handler;
1047
+ let evtListeners = this.eventListeners[type], i, evtName, handler;
1048
1048
  for (i = 0; i < evtListeners.length; i++) {
1049
1049
  evtName = evtListeners[i].name;
1050
1050
  handler = evtListeners[i].handler;
@@ -1068,8 +1068,8 @@ class Node {
1068
1068
  }
1069
1069
  addName(name) {
1070
1070
  if (!this.hasName(name)) {
1071
- var oldName = this.name();
1072
- var newName = oldName ? oldName + ' ' + name : name;
1071
+ const oldName = this.name();
1072
+ const newName = oldName ? oldName + ' ' + name : name;
1073
1073
  this.name(newName);
1074
1074
  }
1075
1075
  return this;
@@ -1082,12 +1082,12 @@ class Node {
1082
1082
  if (!fullName) {
1083
1083
  return false;
1084
1084
  }
1085
- var names = (fullName || '').split(/\s/g);
1085
+ const names = (fullName || '').split(/\s/g);
1086
1086
  return names.indexOf(name) !== -1;
1087
1087
  }
1088
1088
  removeName(name) {
1089
- var names = (this.name() || '').split(/\s/g);
1090
- var index = names.indexOf(name);
1089
+ const names = (this.name() || '').split(/\s/g);
1090
+ const index = names.indexOf(name);
1091
1091
  if (index !== -1) {
1092
1092
  names.splice(index, 1);
1093
1093
  this.name(names.join(' '));
@@ -1095,7 +1095,7 @@ class Node {
1095
1095
  return this;
1096
1096
  }
1097
1097
  setAttr(attr, val) {
1098
- var func = this[SET + Util_1.Util._capitalize(attr)];
1098
+ const func = this[SET + Util_1.Util._capitalize(attr)];
1099
1099
  if (Util_1.Util._isFunction(func)) {
1100
1100
  func.call(this, val);
1101
1101
  }
@@ -1111,7 +1111,7 @@ class Node {
1111
1111
  }
1112
1112
  }
1113
1113
  _setAttr(key, val) {
1114
- var oldVal = this.attrs[key];
1114
+ const oldVal = this.attrs[key];
1115
1115
  if (oldVal === val && !Util_1.Util.isObject(val)) {
1116
1116
  return;
1117
1117
  }
@@ -1127,7 +1127,7 @@ class Node {
1127
1127
  this._requestDraw();
1128
1128
  }
1129
1129
  _setComponentAttr(key, component, val) {
1130
- var oldVal;
1130
+ let oldVal;
1131
1131
  if (val !== undefined) {
1132
1132
  oldVal = this.attrs[key];
1133
1133
  if (!oldVal) {
@@ -1141,14 +1141,14 @@ class Node {
1141
1141
  if (evt && this.nodeType === SHAPE) {
1142
1142
  evt.target = this;
1143
1143
  }
1144
- var shouldStop = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
1144
+ const shouldStop = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
1145
1145
  ((compareShape &&
1146
1146
  (this === compareShape ||
1147
1147
  (this.isAncestorOf && this.isAncestorOf(compareShape)))) ||
1148
1148
  (this.nodeType === 'Stage' && !compareShape));
1149
1149
  if (!shouldStop) {
1150
1150
  this._fire(eventType, evt);
1151
- var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
1151
+ const stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
1152
1152
  compareShape &&
1153
1153
  compareShape.isAncestorOf &&
1154
1154
  compareShape.isAncestorOf(this) &&
@@ -1206,13 +1206,13 @@ class Node {
1206
1206
  return this;
1207
1207
  }
1208
1208
  _createDragElement(evt) {
1209
- var pointerId = evt ? evt.pointerId : undefined;
1210
- var stage = this.getStage();
1211
- var ap = this.getAbsolutePosition();
1209
+ const pointerId = evt ? evt.pointerId : undefined;
1210
+ const stage = this.getStage();
1211
+ const ap = this.getAbsolutePosition();
1212
1212
  if (!stage) {
1213
1213
  return;
1214
1214
  }
1215
- var pos = stage._getPointerById(pointerId) ||
1215
+ const pos = stage._getPointerById(pointerId) ||
1216
1216
  stage._changedPointerPositions[0] ||
1217
1217
  ap;
1218
1218
  DragAndDrop_1.DD._dragElements.set(this._id, {
@@ -1243,11 +1243,11 @@ class Node {
1243
1243
  if (!pos) {
1244
1244
  return;
1245
1245
  }
1246
- var newNodePos = {
1246
+ let newNodePos = {
1247
1247
  x: pos.x - elem.offset.x,
1248
1248
  y: pos.y - elem.offset.y,
1249
1249
  };
1250
- var dbf = this.dragBoundFunc();
1250
+ const dbf = this.dragBoundFunc();
1251
1251
  if (dbf !== undefined) {
1252
1252
  const bounded = dbf.call(this, newNodePos, evt);
1253
1253
  if (!bounded) {
@@ -1284,15 +1284,15 @@ class Node {
1284
1284
  _listenDrag() {
1285
1285
  this._dragCleanup();
1286
1286
  this.on('mousedown.konva touchstart.konva', function (evt) {
1287
- var shouldCheckButton = evt.evt['button'] !== undefined;
1288
- var canDrag = !shouldCheckButton || Global_1.Konva.dragButtons.indexOf(evt.evt['button']) >= 0;
1287
+ const shouldCheckButton = evt.evt['button'] !== undefined;
1288
+ const canDrag = !shouldCheckButton || Global_1.Konva.dragButtons.indexOf(evt.evt['button']) >= 0;
1289
1289
  if (!canDrag) {
1290
1290
  return;
1291
1291
  }
1292
1292
  if (this.isDragging()) {
1293
1293
  return;
1294
1294
  }
1295
- var hasDraggingChild = false;
1295
+ let hasDraggingChild = false;
1296
1296
  DragAndDrop_1.DD._dragElements.forEach((elem) => {
1297
1297
  if (this.isAncestorOf(elem.node)) {
1298
1298
  hasDraggingChild = true;
@@ -1309,7 +1309,7 @@ class Node {
1309
1309
  }
1310
1310
  else {
1311
1311
  this._dragCleanup();
1312
- var stage = this.getStage();
1312
+ const stage = this.getStage();
1313
1313
  if (!stage) {
1314
1314
  return;
1315
1315
  }
@@ -1348,7 +1348,7 @@ class Node {
1348
1348
  return this._createNode(data, container);
1349
1349
  }
1350
1350
  static _createNode(obj, container) {
1351
- var className = Node.prototype.getClassName.call(obj), children = obj.children, no, len, n;
1351
+ let className = Node.prototype.getClassName.call(obj), children = obj.children, no, len, n;
1352
1352
  if (container) {
1353
1353
  obj.attrs.container = container;
1354
1354
  }
@@ -1,24 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.releaseCapture = exports.setPointerCapture = exports.hasPointerCapture = exports.createEvent = exports.getCapturedShape = void 0;
3
+ exports.getCapturedShape = getCapturedShape;
4
+ exports.createEvent = createEvent;
5
+ exports.hasPointerCapture = hasPointerCapture;
6
+ exports.setPointerCapture = setPointerCapture;
7
+ exports.releaseCapture = releaseCapture;
4
8
  const Global_1 = require("./Global");
5
9
  const Captures = new Map();
6
10
  const SUPPORT_POINTER_EVENTS = Global_1.Konva._global['PointerEvent'] !== undefined;
7
11
  function getCapturedShape(pointerId) {
8
12
  return Captures.get(pointerId);
9
13
  }
10
- exports.getCapturedShape = getCapturedShape;
11
14
  function createEvent(evt) {
12
15
  return {
13
16
  evt,
14
17
  pointerId: evt.pointerId,
15
18
  };
16
19
  }
17
- exports.createEvent = createEvent;
18
20
  function hasPointerCapture(pointerId, shape) {
19
21
  return Captures.get(pointerId) === shape;
20
22
  }
21
- exports.hasPointerCapture = hasPointerCapture;
22
23
  function setPointerCapture(pointerId, shape) {
23
24
  releaseCapture(pointerId);
24
25
  const stage = shape.getStage();
@@ -29,7 +30,6 @@ function setPointerCapture(pointerId, shape) {
29
30
  shape._fire('gotpointercapture', createEvent(new PointerEvent('gotpointercapture')));
30
31
  }
31
32
  }
32
- exports.setPointerCapture = setPointerCapture;
33
33
  function releaseCapture(pointerId, target) {
34
34
  const shape = Captures.get(pointerId);
35
35
  if (!shape)
@@ -42,4 +42,3 @@ function releaseCapture(pointerId, target) {
42
42
  shape._fire('lostpointercapture', createEvent(new PointerEvent('lostpointercapture')));
43
43
  }
44
44
  }
45
- exports.releaseCapture = releaseCapture;