konva 10.7.0 → 10.7.1
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/konva.js +87 -4
- package/konva.min.js +4 -4
- package/lib/Container.js +4 -0
- package/lib/Global.js +2 -2
- package/lib/Node.d.ts +8 -0
- package/lib/Node.js +34 -1
- package/lib/shapes/Transformer.d.ts +10 -2
- package/lib/shapes/Transformer.js +48 -1
- package/package.json +1 -1
package/konva.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* Konva JavaScript Framework v10.7.
|
|
8
|
+
* Konva JavaScript Framework v10.7.1
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Mon Oct 05 2026
|
|
12
12
|
*
|
|
13
13
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
|
14
14
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
: {};
|
|
36
36
|
const Konva$2 = {
|
|
37
37
|
_global: glob,
|
|
38
|
-
version: '10.7.
|
|
38
|
+
version: '10.7.1',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -4352,6 +4352,10 @@ js: import "konva/skia-backend";
|
|
|
4352
4352
|
};
|
|
4353
4353
|
for (key in attrs) {
|
|
4354
4354
|
val = attrs[key];
|
|
4355
|
+
// JSON has no typed arrays, so typed line points are written as an array
|
|
4356
|
+
if (val instanceof TypedArray) {
|
|
4357
|
+
val = Array.from(val);
|
|
4358
|
+
}
|
|
4355
4359
|
// if value is object and object is not plain
|
|
4356
4360
|
// like class instance, we should skip it and to not include
|
|
4357
4361
|
nonPlainObject =
|
|
@@ -5060,7 +5064,34 @@ js: import "konva/skia-backend";
|
|
|
5060
5064
|
}
|
|
5061
5065
|
return this;
|
|
5062
5066
|
}
|
|
5067
|
+
_addSubtreeObserver(observer) {
|
|
5068
|
+
var _a;
|
|
5069
|
+
((_a = this._subtreeObservers) !== null && _a !== void 0 ? _a : (this._subtreeObservers = new Set())).add(observer);
|
|
5070
|
+
Node._subtreeObserverCount++;
|
|
5071
|
+
}
|
|
5072
|
+
_removeSubtreeObserver(observer) {
|
|
5073
|
+
var _a;
|
|
5074
|
+
if ((_a = this._subtreeObservers) === null || _a === void 0 ? void 0 : _a.delete(observer)) {
|
|
5075
|
+
Node._subtreeObserverCount--;
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
// Tells the observers of this node and of its ancestors that something below
|
|
5079
|
+
// them changed. A node's own changes reach its observers through its change
|
|
5080
|
+
// events, so a draw request starts at the parent. A container calls this
|
|
5081
|
+
// itself when its child list changes.
|
|
5082
|
+
_notifySubtreeChange() {
|
|
5083
|
+
if (!Node._subtreeObserverCount)
|
|
5084
|
+
return;
|
|
5085
|
+
for (let node = this; node; node = node.parent) {
|
|
5086
|
+
const observers = node._subtreeObservers;
|
|
5087
|
+
if (observers)
|
|
5088
|
+
for (const o of observers)
|
|
5089
|
+
o._onSubtreeChange(node);
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5063
5092
|
_requestDraw() {
|
|
5093
|
+
var _a;
|
|
5094
|
+
(_a = this.parent) === null || _a === void 0 ? void 0 : _a._notifySubtreeChange();
|
|
5064
5095
|
if (Konva$2.autoDrawEnabled) {
|
|
5065
5096
|
const drawNode = this.getLayer() || this.getStage();
|
|
5066
5097
|
drawNode === null || drawNode === void 0 ? void 0 : drawNode.batchDraw();
|
|
@@ -5432,6 +5463,8 @@ js: import "konva/skia-backend";
|
|
|
5432
5463
|
return no;
|
|
5433
5464
|
}
|
|
5434
5465
|
}
|
|
5466
|
+
// Number of registered observers. The ancestor walk is skipped while it is 0.
|
|
5467
|
+
Node._subtreeObserverCount = 0;
|
|
5435
5468
|
// Perf: lets a listener inside an absoluteTransform cascade (e.g. Konva
|
|
5436
5469
|
// .Transformer reacting to a stage drag fan-out across N attached nodes)
|
|
5437
5470
|
// defer work until the cascade ends — collapses O(N) listener-driven calls
|
|
@@ -6074,6 +6107,7 @@ js: import "konva/skia-backend";
|
|
|
6074
6107
|
});
|
|
6075
6108
|
this.children = [];
|
|
6076
6109
|
// because all children were detached from parent, request draw via container
|
|
6110
|
+
this._notifySubtreeChange();
|
|
6077
6111
|
this._requestDraw();
|
|
6078
6112
|
return this;
|
|
6079
6113
|
}
|
|
@@ -6091,6 +6125,7 @@ js: import "konva/skia-backend";
|
|
|
6091
6125
|
});
|
|
6092
6126
|
this.children = [];
|
|
6093
6127
|
// because all children were detached from parent, request draw via container
|
|
6128
|
+
this._notifySubtreeChange();
|
|
6094
6129
|
this._requestDraw();
|
|
6095
6130
|
return this;
|
|
6096
6131
|
}
|
|
@@ -6129,6 +6164,7 @@ js: import "konva/skia-backend";
|
|
|
6129
6164
|
this._fire('add', {
|
|
6130
6165
|
child: child,
|
|
6131
6166
|
});
|
|
6167
|
+
this._notifySubtreeChange();
|
|
6132
6168
|
this._requestDraw();
|
|
6133
6169
|
// chainable
|
|
6134
6170
|
return this;
|
|
@@ -6329,6 +6365,7 @@ js: import "konva/skia-backend";
|
|
|
6329
6365
|
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, n) {
|
|
6330
6366
|
child.index = n;
|
|
6331
6367
|
});
|
|
6368
|
+
this._notifySubtreeChange();
|
|
6332
6369
|
this._requestDraw();
|
|
6333
6370
|
}
|
|
6334
6371
|
drawScene(can, top) {
|
|
@@ -16668,6 +16705,8 @@ js: import "konva/skia-backend";
|
|
|
16668
16705
|
this._transformWindow = null;
|
|
16669
16706
|
this._elementsCreated = false;
|
|
16670
16707
|
this._updateScheduled = false;
|
|
16708
|
+
// an attached container's descendants changed after the last layout
|
|
16709
|
+
this._subtreeChanged = false;
|
|
16671
16710
|
this._createElements();
|
|
16672
16711
|
// bindings
|
|
16673
16712
|
this._handleMouseMove = this._handleMouseMove.bind(this);
|
|
@@ -16766,6 +16805,8 @@ js: import "konva/skia-backend";
|
|
|
16766
16805
|
}
|
|
16767
16806
|
node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);
|
|
16768
16807
|
node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);
|
|
16808
|
+
if (node instanceof Container)
|
|
16809
|
+
node._addSubtreeObserver(this);
|
|
16769
16810
|
node.on(`destroy.${this._getEventNamespace()}`, () => {
|
|
16770
16811
|
// a destroyed node has nothing left to transform
|
|
16771
16812
|
this.setNodes(this._nodes.filter((n) => n !== node));
|
|
@@ -16842,6 +16883,7 @@ js: import "konva/skia-backend";
|
|
|
16842
16883
|
if (this._nodes) {
|
|
16843
16884
|
this._nodes.forEach((node) => {
|
|
16844
16885
|
node.off('.' + this._getEventNamespace());
|
|
16886
|
+
node._removeSubtreeObserver(this);
|
|
16845
16887
|
});
|
|
16846
16888
|
}
|
|
16847
16889
|
this._nodes = [];
|
|
@@ -16871,6 +16913,42 @@ js: import "konva/skia-backend";
|
|
|
16871
16913
|
this._clearCache('transform');
|
|
16872
16914
|
this._clearSelfAndDescendantCache('absoluteTransform');
|
|
16873
16915
|
}
|
|
16916
|
+
// Called for every change below an attached container. A burst of child
|
|
16917
|
+
// changes only drops cached values here. The new bounds are measured once,
|
|
16918
|
+
// before the next frame, or earlier if a draw or transform step comes first
|
|
16919
|
+
// (_syncSubtreeChange).
|
|
16920
|
+
_onSubtreeChange(node) {
|
|
16921
|
+
var _a, _b;
|
|
16922
|
+
if (this._fitting)
|
|
16923
|
+
return;
|
|
16924
|
+
// nothing was measured since the last change, so nothing cached is stale
|
|
16925
|
+
if (this._subtreeChanged && !this._cache[NODES_RECT])
|
|
16926
|
+
return;
|
|
16927
|
+
this._resetTransformCache(node);
|
|
16928
|
+
if (!this._subtreeChanged) {
|
|
16929
|
+
this._subtreeChanged = true;
|
|
16930
|
+
// queued ahead of the draw the change requests, so that draw shows the
|
|
16931
|
+
// new layout. Updating inside the draw would request one more frame.
|
|
16932
|
+
Util.requestAnimFrame(() => this._syncSubtreeChange(), (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a._getOwnerWindow());
|
|
16933
|
+
// the transformer can be on another layer than the changed node
|
|
16934
|
+
(_b = this.getLayer()) === null || _b === void 0 ? void 0 : _b.batchDraw();
|
|
16935
|
+
}
|
|
16936
|
+
}
|
|
16937
|
+
_syncSubtreeChange() {
|
|
16938
|
+
var _a;
|
|
16939
|
+
// while dragging, the dragmove handler updates the layout
|
|
16940
|
+
if (this._subtreeChanged && ((_a = this._nodes) === null || _a === void 0 ? void 0 : _a.length) && !this.isDragging()) {
|
|
16941
|
+
this._update();
|
|
16942
|
+
}
|
|
16943
|
+
}
|
|
16944
|
+
drawScene(can, top) {
|
|
16945
|
+
this._syncSubtreeChange();
|
|
16946
|
+
return super.drawScene(can, top);
|
|
16947
|
+
}
|
|
16948
|
+
drawHit(can, top) {
|
|
16949
|
+
this._syncSubtreeChange();
|
|
16950
|
+
return super.drawHit(can, top);
|
|
16951
|
+
}
|
|
16874
16952
|
_getNodeRect() {
|
|
16875
16953
|
return this._getCache(NODES_RECT, this.__getNodeRect);
|
|
16876
16954
|
}
|
|
@@ -17132,6 +17210,8 @@ js: import "konva/skia-backend";
|
|
|
17132
17210
|
(_a = this.getStage()) === null || _a === void 0 ? void 0 : _a._batchEvents(() => this._moveTransform(e));
|
|
17133
17211
|
}
|
|
17134
17212
|
_moveTransform(e) {
|
|
17213
|
+
// anchors must show the current bounds before they are measured against
|
|
17214
|
+
this._syncSubtreeChange();
|
|
17135
17215
|
let x, y, newHypotenuse;
|
|
17136
17216
|
const anchorNode = this._anchors[this._movingAnchorName];
|
|
17137
17217
|
const stage = anchorNode.getStage();
|
|
@@ -17569,7 +17649,9 @@ js: import "konva/skia-backend";
|
|
|
17569
17649
|
}
|
|
17570
17650
|
/**
|
|
17571
17651
|
* force update of Konva.Transformer.
|
|
17572
|
-
*
|
|
17652
|
+
* The transformer follows attribute changes of attached nodes and, for an attached group, any change of its descendants.
|
|
17653
|
+
* Use it after a change that sets no attribute, for example a `Line` points array mutated in place
|
|
17654
|
+
* or a custom `getSelfRect()` that depends on outside state.
|
|
17573
17655
|
* @method
|
|
17574
17656
|
* @name Konva.Transformer#forceUpdate
|
|
17575
17657
|
*/
|
|
@@ -17585,6 +17667,7 @@ js: import "konva/skia-backend";
|
|
|
17585
17667
|
}
|
|
17586
17668
|
_update() {
|
|
17587
17669
|
var _a;
|
|
17670
|
+
this._subtreeChanged = false;
|
|
17588
17671
|
const attrs = this._getNodeRect();
|
|
17589
17672
|
this._updateElements(attrs);
|
|
17590
17673
|
const draggable = this.nodes().some((node) => node.draggable());
|