konva 10.2.0 → 10.2.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 +47 -80
- package/konva.min.js +3 -3
- package/lib/DragAndDrop.d.ts +1 -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/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.1
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Fri Mar 13 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.1',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -3220,73 +3220,15 @@ js: import "konva/skia-backend";
|
|
|
3220
3220
|
this._filterUpToDate = true;
|
|
3221
3221
|
return filterCanvas;
|
|
3222
3222
|
}
|
|
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) {
|
|
3223
|
+
on(...args) {
|
|
3224
|
+
const evtStr = args[0];
|
|
3225
|
+
const selectorOrHandler = args[1];
|
|
3226
|
+
args[2];
|
|
3285
3227
|
if (this._cache) {
|
|
3286
3228
|
this._cache.delete(ALL_LISTENERS);
|
|
3287
3229
|
}
|
|
3288
|
-
if (
|
|
3289
|
-
return this._delegate.apply(this,
|
|
3230
|
+
if (args.length === 3) {
|
|
3231
|
+
return this._delegate.apply(this, args);
|
|
3290
3232
|
}
|
|
3291
3233
|
const events = evtStr.split(SPACE$1);
|
|
3292
3234
|
/*
|
|
@@ -3303,7 +3245,7 @@ js: import "konva/skia-backend";
|
|
|
3303
3245
|
if (!this.eventListeners[baseEvent]) {
|
|
3304
3246
|
this.eventListeners[baseEvent] = [];
|
|
3305
3247
|
}
|
|
3306
|
-
this.eventListeners[baseEvent].push({ name, handler });
|
|
3248
|
+
this.eventListeners[baseEvent].push({ name, handler: selectorOrHandler });
|
|
3307
3249
|
}
|
|
3308
3250
|
return this;
|
|
3309
3251
|
}
|
|
@@ -3387,6 +3329,7 @@ js: import "konva/skia-backend";
|
|
|
3387
3329
|
handler.call(targets[i], evt);
|
|
3388
3330
|
}
|
|
3389
3331
|
});
|
|
3332
|
+
return this;
|
|
3390
3333
|
}
|
|
3391
3334
|
/**
|
|
3392
3335
|
* remove a node from parent, but don't destroy. You can reuse the node later.
|
|
@@ -3403,6 +3346,13 @@ js: import "konva/skia-backend";
|
|
|
3403
3346
|
// we can have drag element but that is not dragged yet
|
|
3404
3347
|
// so just clear it
|
|
3405
3348
|
DD._dragElements.delete(this._id);
|
|
3349
|
+
// also remove any dragging descendants, otherwise they'll
|
|
3350
|
+
// have a broken parent chain and crash on getStage()
|
|
3351
|
+
DD._dragElements.forEach((elem, key) => {
|
|
3352
|
+
if (this.isAncestorOf(elem.node)) {
|
|
3353
|
+
DD._dragElements.delete(key);
|
|
3354
|
+
}
|
|
3355
|
+
});
|
|
3406
3356
|
this._remove();
|
|
3407
3357
|
return this;
|
|
3408
3358
|
}
|
|
@@ -4851,6 +4801,7 @@ js: import "konva/skia-backend";
|
|
|
4851
4801
|
},
|
|
4852
4802
|
dragStatus: 'ready',
|
|
4853
4803
|
pointerId,
|
|
4804
|
+
startEvent: evt,
|
|
4854
4805
|
});
|
|
4855
4806
|
}
|
|
4856
4807
|
/**
|
|
@@ -4867,7 +4818,9 @@ js: import "konva/skia-backend";
|
|
|
4867
4818
|
this.fire('dragstart', {
|
|
4868
4819
|
type: 'dragstart',
|
|
4869
4820
|
target: this,
|
|
4870
|
-
|
|
4821
|
+
// Use the stored start event if available (from mousedown/touchstart),
|
|
4822
|
+
// otherwise fall back to the provided event (when startDrag is called programmatically)
|
|
4823
|
+
evt: (elem.startEvent && elem.startEvent.evt) || (evt && evt.evt),
|
|
4871
4824
|
}, bubbleEvent);
|
|
4872
4825
|
}
|
|
4873
4826
|
_setDragPosition(evt, elem) {
|
|
@@ -5056,7 +5009,7 @@ js: import "konva/skia-backend";
|
|
|
5056
5009
|
// attache events listeners once into prototype
|
|
5057
5010
|
// that way we don't spend too much time on making an new instance
|
|
5058
5011
|
Node.prototype.eventListeners = {};
|
|
5059
|
-
Node.prototype.on
|
|
5012
|
+
Node.prototype.on(TRANSFORM_CHANGE_STR$1, function () {
|
|
5060
5013
|
if (this._batchingTransformChange) {
|
|
5061
5014
|
this._needClearTransformCache = true;
|
|
5062
5015
|
return;
|
|
@@ -5064,13 +5017,13 @@ js: import "konva/skia-backend";
|
|
|
5064
5017
|
this._clearCache(TRANSFORM);
|
|
5065
5018
|
this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);
|
|
5066
5019
|
});
|
|
5067
|
-
Node.prototype.on
|
|
5020
|
+
Node.prototype.on('visibleChange.konva', function () {
|
|
5068
5021
|
this._clearSelfAndDescendantCache(VISIBLE);
|
|
5069
5022
|
});
|
|
5070
|
-
Node.prototype.on
|
|
5023
|
+
Node.prototype.on('listeningChange.konva', function () {
|
|
5071
5024
|
this._clearSelfAndDescendantCache(LISTENING);
|
|
5072
5025
|
});
|
|
5073
|
-
Node.prototype.on
|
|
5026
|
+
Node.prototype.on('opacityChange.konva', function () {
|
|
5074
5027
|
this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
|
|
5075
5028
|
});
|
|
5076
5029
|
const addGetterSetter = Factory.addGetterSetter;
|
|
@@ -7717,11 +7670,11 @@ js: import "konva/skia-backend";
|
|
|
7717
7670
|
Shape.prototype.nodeType = 'Shape';
|
|
7718
7671
|
_registerNode(Shape);
|
|
7719
7672
|
Shape.prototype.eventListeners = {};
|
|
7720
|
-
Shape.prototype.on
|
|
7721
|
-
Shape.prototype.on
|
|
7722
|
-
Shape.prototype.on
|
|
7723
|
-
Shape.prototype.on
|
|
7724
|
-
Shape.prototype.on
|
|
7673
|
+
Shape.prototype.on('shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);
|
|
7674
|
+
Shape.prototype.on('shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);
|
|
7675
|
+
Shape.prototype.on('fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);
|
|
7676
|
+
Shape.prototype.on('fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);
|
|
7677
|
+
Shape.prototype.on('fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);
|
|
7725
7678
|
// add getters and setters
|
|
7726
7679
|
Factory.addGetterSetter(Shape, 'stroke', undefined, getStringOrGradientValidator());
|
|
7727
7680
|
/**
|
|
@@ -15878,7 +15831,7 @@ js: import "konva/skia-backend";
|
|
|
15878
15831
|
});
|
|
15879
15832
|
width += chars[i].width;
|
|
15880
15833
|
}
|
|
15881
|
-
const { height } = this._getTextSize(this.attrs.text);
|
|
15834
|
+
const { width: fullTextWidth, height } = this._getTextSize(this.attrs.text);
|
|
15882
15835
|
this.textWidth = width;
|
|
15883
15836
|
this.textHeight = height;
|
|
15884
15837
|
this.glyphInfo = [];
|
|
@@ -15888,6 +15841,12 @@ js: import "konva/skia-backend";
|
|
|
15888
15841
|
const letterSpacing = this.letterSpacing();
|
|
15889
15842
|
const align = this.align();
|
|
15890
15843
|
const kerningFunc = this.kerningFunc();
|
|
15844
|
+
// The sum of individual character widths can exceed the whole-string width
|
|
15845
|
+
// due to kerning (browsers place adjacent glyphs closer together than the
|
|
15846
|
+
// individual measurements suggest). This difference is the maximum amount
|
|
15847
|
+
// by which the accumulated glyph offset can legitimately overshoot the
|
|
15848
|
+
// path length when the path is sized to match the visually-measured text.
|
|
15849
|
+
const kerningAdjustment = Math.max(0, width - fullTextWidth);
|
|
15891
15850
|
// defines the width of the text on a straight line
|
|
15892
15851
|
const textWidth = Math.max(this.textWidth + ((this.attrs.text || '').length - 1) * letterSpacing, 0);
|
|
15893
15852
|
let offset = 0;
|
|
@@ -15913,7 +15872,15 @@ js: import "konva/skia-backend";
|
|
|
15913
15872
|
const numberOfSpaces = this.text().split(' ').length - 1;
|
|
15914
15873
|
glyphWidth += (this.pathLength - textWidth) / numberOfSpaces;
|
|
15915
15874
|
}
|
|
15916
|
-
const
|
|
15875
|
+
const charEndLength = offsetToGlyph + glyphWidth;
|
|
15876
|
+
// When the path length is sized to match the visually-measured (kerned)
|
|
15877
|
+
// text width, the accumulated per-glyph offset can exceed pathLength by
|
|
15878
|
+
// up to kerningAdjustment pixels. Clamp to pathLength in that case so
|
|
15879
|
+
// the last character is not silently dropped.
|
|
15880
|
+
const charEndPoint = this._getPointAtLength(charEndLength > this.pathLength &&
|
|
15881
|
+
charEndLength - this.pathLength <= kerningAdjustment
|
|
15882
|
+
? this.pathLength
|
|
15883
|
+
: charEndLength);
|
|
15917
15884
|
if (!charEndPoint) {
|
|
15918
15885
|
return;
|
|
15919
15886
|
}
|