konva 10.2.0 → 10.2.3
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 +64 -80
- package/konva.min.js +3 -3
- package/lib/DragAndDrop.d.ts +1 -0
- package/lib/DragAndDrop.js +3 -0
- package/lib/Global.js +1 -1
- package/lib/Node.d.ts +3 -2
- package/lib/Node.js +19 -9
- package/lib/Shape.js +5 -5
- package/lib/_CoreInternals.d.ts +1 -0
- package/lib/_FullInternals.d.ts +1 -0
- package/lib/shapes/TextPath.js +7 -2
- package/lib/shapes/Transformer.d.ts +2 -0
- package/lib/shapes/Transformer.js +9 -0
- 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.2.
|
|
8
|
+
* Konva JavaScript Framework v10.2.3
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Mon Mar 16 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.2.
|
|
38
|
+
version: '10.2.3',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -2345,6 +2345,10 @@ js: import "konva/skia-backend";
|
|
|
2345
2345
|
});
|
|
2346
2346
|
// call dragmove only after ALL positions are changed
|
|
2347
2347
|
nodesToFireEvents.forEach((node) => {
|
|
2348
|
+
// node may have been destroyed during a previous dragmove handler
|
|
2349
|
+
if (!node.getStage()) {
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2348
2352
|
node.fire('dragmove', {
|
|
2349
2353
|
type: 'dragmove',
|
|
2350
2354
|
target: node,
|
|
@@ -3220,73 +3224,15 @@ js: import "konva/skia-backend";
|
|
|
3220
3224
|
this._filterUpToDate = true;
|
|
3221
3225
|
return filterCanvas;
|
|
3222
3226
|
}
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
* Pass in a string of events delimited by a space to bind multiple events at once
|
|
3228
|
-
* such as 'mousedown mouseup mousemove'. Include a namespace to bind an
|
|
3229
|
-
* event by name such as 'click.foobar'.
|
|
3230
|
-
* @method
|
|
3231
|
-
* @name Konva.Node#on
|
|
3232
|
-
* @param {String} evtStr e.g. 'click', 'mousedown touchstart', 'mousedown.foo touchstart.foo'
|
|
3233
|
-
* @param {Function} handler The handler function. The first argument of that function is event object. Event object has `target` as main target of the event, `currentTarget` as current node listener and `evt` as native browser event.
|
|
3234
|
-
* @returns {Konva.Node}
|
|
3235
|
-
* @example
|
|
3236
|
-
* // add click listener
|
|
3237
|
-
* node.on('click', function() {
|
|
3238
|
-
* console.log('you clicked me!');
|
|
3239
|
-
* });
|
|
3240
|
-
*
|
|
3241
|
-
* // get the target node
|
|
3242
|
-
* node.on('click', function(evt) {
|
|
3243
|
-
* console.log(evt.target);
|
|
3244
|
-
* });
|
|
3245
|
-
*
|
|
3246
|
-
* // stop event propagation
|
|
3247
|
-
* node.on('click', function(evt) {
|
|
3248
|
-
* evt.cancelBubble = true;
|
|
3249
|
-
* });
|
|
3250
|
-
*
|
|
3251
|
-
* // bind multiple listeners
|
|
3252
|
-
* node.on('click touchstart', function() {
|
|
3253
|
-
* console.log('you clicked/touched me!');
|
|
3254
|
-
* });
|
|
3255
|
-
*
|
|
3256
|
-
* // namespace listener
|
|
3257
|
-
* node.on('click.foo', function() {
|
|
3258
|
-
* console.log('you clicked/touched me!');
|
|
3259
|
-
* });
|
|
3260
|
-
*
|
|
3261
|
-
* // get the event type
|
|
3262
|
-
* node.on('click tap', function(evt) {
|
|
3263
|
-
* var eventType = evt.type;
|
|
3264
|
-
* });
|
|
3265
|
-
*
|
|
3266
|
-
* // get native event object
|
|
3267
|
-
* node.on('click tap', function(evt) {
|
|
3268
|
-
* var nativeEvent = evt.evt;
|
|
3269
|
-
* });
|
|
3270
|
-
*
|
|
3271
|
-
* // for change events, get the old and new val
|
|
3272
|
-
* node.on('xChange', function(evt) {
|
|
3273
|
-
* var oldVal = evt.oldVal;
|
|
3274
|
-
* var newVal = evt.newVal;
|
|
3275
|
-
* });
|
|
3276
|
-
*
|
|
3277
|
-
* // get event targets
|
|
3278
|
-
* // with event delegations
|
|
3279
|
-
* layer.on('click', 'Group', function(evt) {
|
|
3280
|
-
* var shape = evt.target;
|
|
3281
|
-
* var group = evt.currentTarget;
|
|
3282
|
-
* });
|
|
3283
|
-
*/
|
|
3284
|
-
on(evtStr, handler) {
|
|
3227
|
+
on(...args) {
|
|
3228
|
+
const evtStr = args[0];
|
|
3229
|
+
const selectorOrHandler = args[1];
|
|
3230
|
+
args[2];
|
|
3285
3231
|
if (this._cache) {
|
|
3286
3232
|
this._cache.delete(ALL_LISTENERS);
|
|
3287
3233
|
}
|
|
3288
|
-
if (
|
|
3289
|
-
return this._delegate.apply(this,
|
|
3234
|
+
if (args.length === 3) {
|
|
3235
|
+
return this._delegate.apply(this, args);
|
|
3290
3236
|
}
|
|
3291
3237
|
const events = evtStr.split(SPACE$1);
|
|
3292
3238
|
/*
|
|
@@ -3303,7 +3249,7 @@ js: import "konva/skia-backend";
|
|
|
3303
3249
|
if (!this.eventListeners[baseEvent]) {
|
|
3304
3250
|
this.eventListeners[baseEvent] = [];
|
|
3305
3251
|
}
|
|
3306
|
-
this.eventListeners[baseEvent].push({ name, handler });
|
|
3252
|
+
this.eventListeners[baseEvent].push({ name, handler: selectorOrHandler });
|
|
3307
3253
|
}
|
|
3308
3254
|
return this;
|
|
3309
3255
|
}
|
|
@@ -3387,6 +3333,7 @@ js: import "konva/skia-backend";
|
|
|
3387
3333
|
handler.call(targets[i], evt);
|
|
3388
3334
|
}
|
|
3389
3335
|
});
|
|
3336
|
+
return this;
|
|
3390
3337
|
}
|
|
3391
3338
|
/**
|
|
3392
3339
|
* remove a node from parent, but don't destroy. You can reuse the node later.
|
|
@@ -3403,6 +3350,13 @@ js: import "konva/skia-backend";
|
|
|
3403
3350
|
// we can have drag element but that is not dragged yet
|
|
3404
3351
|
// so just clear it
|
|
3405
3352
|
DD._dragElements.delete(this._id);
|
|
3353
|
+
// also remove any dragging descendants, otherwise they'll
|
|
3354
|
+
// have a broken parent chain and crash on getStage()
|
|
3355
|
+
DD._dragElements.forEach((elem, key) => {
|
|
3356
|
+
if (this.isAncestorOf(elem.node)) {
|
|
3357
|
+
DD._dragElements.delete(key);
|
|
3358
|
+
}
|
|
3359
|
+
});
|
|
3406
3360
|
this._remove();
|
|
3407
3361
|
return this;
|
|
3408
3362
|
}
|
|
@@ -4851,6 +4805,7 @@ js: import "konva/skia-backend";
|
|
|
4851
4805
|
},
|
|
4852
4806
|
dragStatus: 'ready',
|
|
4853
4807
|
pointerId,
|
|
4808
|
+
startEvent: evt,
|
|
4854
4809
|
});
|
|
4855
4810
|
}
|
|
4856
4811
|
/**
|
|
@@ -4867,7 +4822,9 @@ js: import "konva/skia-backend";
|
|
|
4867
4822
|
this.fire('dragstart', {
|
|
4868
4823
|
type: 'dragstart',
|
|
4869
4824
|
target: this,
|
|
4870
|
-
|
|
4825
|
+
// Use the stored start event if available (from mousedown/touchstart),
|
|
4826
|
+
// otherwise fall back to the provided event (when startDrag is called programmatically)
|
|
4827
|
+
evt: (elem.startEvent && elem.startEvent.evt) || (evt && evt.evt),
|
|
4871
4828
|
}, bubbleEvent);
|
|
4872
4829
|
}
|
|
4873
4830
|
_setDragPosition(evt, elem) {
|
|
@@ -5056,7 +5013,7 @@ js: import "konva/skia-backend";
|
|
|
5056
5013
|
// attache events listeners once into prototype
|
|
5057
5014
|
// that way we don't spend too much time on making an new instance
|
|
5058
5015
|
Node.prototype.eventListeners = {};
|
|
5059
|
-
Node.prototype.on
|
|
5016
|
+
Node.prototype.on(TRANSFORM_CHANGE_STR$1, function () {
|
|
5060
5017
|
if (this._batchingTransformChange) {
|
|
5061
5018
|
this._needClearTransformCache = true;
|
|
5062
5019
|
return;
|
|
@@ -5064,13 +5021,13 @@ js: import "konva/skia-backend";
|
|
|
5064
5021
|
this._clearCache(TRANSFORM);
|
|
5065
5022
|
this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);
|
|
5066
5023
|
});
|
|
5067
|
-
Node.prototype.on
|
|
5024
|
+
Node.prototype.on('visibleChange.konva', function () {
|
|
5068
5025
|
this._clearSelfAndDescendantCache(VISIBLE);
|
|
5069
5026
|
});
|
|
5070
|
-
Node.prototype.on
|
|
5027
|
+
Node.prototype.on('listeningChange.konva', function () {
|
|
5071
5028
|
this._clearSelfAndDescendantCache(LISTENING);
|
|
5072
5029
|
});
|
|
5073
|
-
Node.prototype.on
|
|
5030
|
+
Node.prototype.on('opacityChange.konva', function () {
|
|
5074
5031
|
this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
|
|
5075
5032
|
});
|
|
5076
5033
|
const addGetterSetter = Factory.addGetterSetter;
|
|
@@ -7717,11 +7674,11 @@ js: import "konva/skia-backend";
|
|
|
7717
7674
|
Shape.prototype.nodeType = 'Shape';
|
|
7718
7675
|
_registerNode(Shape);
|
|
7719
7676
|
Shape.prototype.eventListeners = {};
|
|
7720
|
-
Shape.prototype.on
|
|
7721
|
-
Shape.prototype.on
|
|
7722
|
-
Shape.prototype.on
|
|
7723
|
-
Shape.prototype.on
|
|
7724
|
-
Shape.prototype.on
|
|
7677
|
+
Shape.prototype.on('shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);
|
|
7678
|
+
Shape.prototype.on('shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);
|
|
7679
|
+
Shape.prototype.on('fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);
|
|
7680
|
+
Shape.prototype.on('fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);
|
|
7681
|
+
Shape.prototype.on('fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);
|
|
7725
7682
|
// add getters and setters
|
|
7726
7683
|
Factory.addGetterSetter(Shape, 'stroke', undefined, getStringOrGradientValidator());
|
|
7727
7684
|
/**
|
|
@@ -15878,7 +15835,7 @@ js: import "konva/skia-backend";
|
|
|
15878
15835
|
});
|
|
15879
15836
|
width += chars[i].width;
|
|
15880
15837
|
}
|
|
15881
|
-
const { height } = this._getTextSize(this.attrs.text);
|
|
15838
|
+
const { width: fullTextWidth, height } = this._getTextSize(this.attrs.text);
|
|
15882
15839
|
this.textWidth = width;
|
|
15883
15840
|
this.textHeight = height;
|
|
15884
15841
|
this.glyphInfo = [];
|
|
@@ -15888,6 +15845,12 @@ js: import "konva/skia-backend";
|
|
|
15888
15845
|
const letterSpacing = this.letterSpacing();
|
|
15889
15846
|
const align = this.align();
|
|
15890
15847
|
const kerningFunc = this.kerningFunc();
|
|
15848
|
+
// The sum of individual character widths can exceed the whole-string width
|
|
15849
|
+
// due to kerning (browsers place adjacent glyphs closer together than the
|
|
15850
|
+
// individual measurements suggest). This difference is the maximum amount
|
|
15851
|
+
// by which the accumulated glyph offset can legitimately overshoot the
|
|
15852
|
+
// path length when the path is sized to match the visually-measured text.
|
|
15853
|
+
const kerningAdjustment = Math.max(0, width - fullTextWidth);
|
|
15891
15854
|
// defines the width of the text on a straight line
|
|
15892
15855
|
const textWidth = Math.max(this.textWidth + ((this.attrs.text || '').length - 1) * letterSpacing, 0);
|
|
15893
15856
|
let offset = 0;
|
|
@@ -15913,7 +15876,15 @@ js: import "konva/skia-backend";
|
|
|
15913
15876
|
const numberOfSpaces = this.text().split(' ').length - 1;
|
|
15914
15877
|
glyphWidth += (this.pathLength - textWidth) / numberOfSpaces;
|
|
15915
15878
|
}
|
|
15916
|
-
const
|
|
15879
|
+
const charEndLength = offsetToGlyph + glyphWidth;
|
|
15880
|
+
// When the path length is sized to match the visually-measured (kerned)
|
|
15881
|
+
// text width, the accumulated per-glyph offset can exceed pathLength by
|
|
15882
|
+
// up to kerningAdjustment pixels. Clamp to pathLength in that case so
|
|
15883
|
+
// the last character is not silently dropped.
|
|
15884
|
+
const charEndPoint = this._getPointAtLength(charEndLength > this.pathLength &&
|
|
15885
|
+
charEndLength - this.pathLength <= kerningAdjustment
|
|
15886
|
+
? this.pathLength
|
|
15887
|
+
: charEndLength);
|
|
15917
15888
|
if (!charEndPoint) {
|
|
15918
15889
|
return;
|
|
15919
15890
|
}
|
|
@@ -16352,6 +16323,7 @@ js: import "konva/skia-backend";
|
|
|
16352
16323
|
super(config);
|
|
16353
16324
|
this._movingAnchorName = null;
|
|
16354
16325
|
this._transforming = false;
|
|
16326
|
+
this._elementsCreated = false;
|
|
16355
16327
|
this._createElements();
|
|
16356
16328
|
// bindings
|
|
16357
16329
|
this._handleMouseMove = this._handleMouseMove.bind(this);
|
|
@@ -16626,6 +16598,7 @@ js: import "konva/skia-backend";
|
|
|
16626
16598
|
this._createAnchor(name);
|
|
16627
16599
|
});
|
|
16628
16600
|
this._createAnchor('rotater');
|
|
16601
|
+
this._elementsCreated = true;
|
|
16629
16602
|
}
|
|
16630
16603
|
_createAnchor(name) {
|
|
16631
16604
|
const anchor = new Rect({
|
|
@@ -17323,6 +17296,17 @@ js: import "konva/skia-backend";
|
|
|
17323
17296
|
this._removeEvents();
|
|
17324
17297
|
return this;
|
|
17325
17298
|
}
|
|
17299
|
+
// Transformer manages its own internal children (anchors, back shape).
|
|
17300
|
+
// Adding external nodes as children can cause infinite recursion because
|
|
17301
|
+
// the Transformer's absoluteTransform depends on nodes' transforms.
|
|
17302
|
+
// Use tr.nodes([node]) to attach nodes instead.
|
|
17303
|
+
add(...children) {
|
|
17304
|
+
if (this._elementsCreated) {
|
|
17305
|
+
Util.error('You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.');
|
|
17306
|
+
return this;
|
|
17307
|
+
}
|
|
17308
|
+
return super.add(...children);
|
|
17309
|
+
}
|
|
17326
17310
|
// do not work as a container
|
|
17327
17311
|
// we will recreate inner nodes manually
|
|
17328
17312
|
toObject() {
|