konva 7.2.1 → 7.2.5
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/CHANGELOG.md +18 -0
- package/konva.js +58 -34
- package/konva.min.js +4 -4
- package/lib/Animation.js +1 -0
- package/lib/Canvas.js +2 -1
- package/lib/Container.js +2 -1
- package/lib/Context.js +2 -1
- package/lib/DragAndDrop.js +1 -0
- package/lib/Factory.js +1 -0
- package/lib/FastLayer.js +2 -1
- package/lib/Global.js +6 -3
- package/lib/Group.js +2 -1
- package/lib/Layer.js +2 -1
- package/lib/Node.js +10 -5
- package/lib/PointerEvents.js +1 -0
- package/lib/Shape.js +6 -4
- package/lib/Stage.js +4 -3
- package/lib/Tween.js +1 -0
- package/lib/Util.js +5 -1
- package/lib/Validators.js +1 -0
- package/lib/_CoreInternals.js +1 -0
- package/lib/_FullInternals.js +1 -0
- package/lib/filters/Blur.js +3 -1
- package/lib/filters/Brighten.js +3 -1
- package/lib/filters/Contrast.js +3 -1
- package/lib/filters/Emboss.js +3 -1
- package/lib/filters/Enhance.js +3 -1
- package/lib/filters/Grayscale.js +3 -1
- package/lib/filters/HSL.js +3 -1
- package/lib/filters/HSV.js +3 -1
- package/lib/filters/Invert.js +3 -1
- package/lib/filters/Kaleidoscope.js +3 -1
- package/lib/filters/Mask.js +3 -1
- package/lib/filters/Noise.js +3 -1
- package/lib/filters/Pixelate.js +3 -1
- package/lib/filters/Posterize.js +3 -1
- package/lib/filters/RGB.js +3 -1
- package/lib/filters/RGBA.js +3 -1
- package/lib/filters/Sepia.js +3 -1
- package/lib/filters/Solarize.js +3 -1
- package/lib/filters/Threshold.js +3 -1
- package/lib/shapes/Arc.js +2 -1
- package/lib/shapes/Arrow.js +2 -1
- package/lib/shapes/Circle.js +2 -1
- package/lib/shapes/Ellipse.js +2 -1
- package/lib/shapes/Image.js +2 -1
- package/lib/shapes/Label.js +2 -1
- package/lib/shapes/Line.js +2 -1
- package/lib/shapes/Path.js +2 -1
- package/lib/shapes/Rect.js +2 -1
- package/lib/shapes/RegularPolygon.js +2 -1
- package/lib/shapes/Ring.js +2 -1
- package/lib/shapes/Sprite.js +2 -1
- package/lib/shapes/Star.js +2 -1
- package/lib/shapes/Text.js +4 -2
- package/lib/shapes/TextPath.js +2 -1
- package/lib/shapes/Transformer.js +4 -3
- package/lib/shapes/Wedge.js +2 -1
- package/lib/types.js +1 -0
- package/package.json +26 -12
- package/types/DragAndDrop.d.ts +2 -2
- package/types/Node.d.ts +1 -1
- package/types/Shape.d.ts +1 -1
- package/types/Stage.d.ts +1 -1
- package/types/Util.d.ts +3 -3
- package/types/_CoreInternals.d.ts +1 -1
- package/types/_FullInternals.d.ts +1 -1
- package/types/shapes/Text.d.ts +1 -0
- package/types/shapes/Transformer.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
|
6
|
+
## 7.2.5
|
|
7
|
+
|
|
8
|
+
* Fix transform update on `letterSpacing` change of `Konva.Text`
|
|
9
|
+
|
|
10
|
+
## 7.2.4
|
|
11
|
+
|
|
12
|
+
* Fix wrong `mouseleave` trigger for `Konva.Stage`
|
|
13
|
+
|
|
14
|
+
## 7.2.3
|
|
15
|
+
|
|
16
|
+
* Fix transformer rotation when parent of a node is rotated too.
|
|
17
|
+
|
|
18
|
+
## 7.2.2
|
|
19
|
+
|
|
20
|
+
* Fix wrong size calculations for `Konva.Line` with tension
|
|
21
|
+
* Fix `shape.intersects()` behavior when a node is dragged
|
|
22
|
+
* Fix ellipsis rendering for `Konva.Text`
|
|
23
|
+
|
|
6
24
|
## 7.2.1
|
|
7
25
|
|
|
8
26
|
* Fix correct rendering of `Konva.Label` when heigh of text is changed
|
package/konva.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
-
(global = global || self, global.Konva = factory());
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Konva = factory());
|
|
5
5
|
}(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* Konva JavaScript Framework v7.2.
|
|
8
|
+
* Konva JavaScript Framework v7.2.5
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Wed Mar 03 2021
|
|
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)
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
: {};
|
|
77
77
|
var Konva = {
|
|
78
78
|
_global: glob,
|
|
79
|
-
version: '7.2.
|
|
79
|
+
version: '7.2.5',
|
|
80
80
|
isBrowser: detectBrowser(),
|
|
81
81
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
82
82
|
dblClickWindow: 400,
|
|
@@ -528,6 +528,7 @@
|
|
|
528
528
|
result.skewX = 0;
|
|
529
529
|
result.skewY = (a * c + b * d) / delta;
|
|
530
530
|
}
|
|
531
|
+
else ;
|
|
531
532
|
result.rotation = Util._getRotation(result.rotation);
|
|
532
533
|
return result;
|
|
533
534
|
};
|
|
@@ -731,7 +732,9 @@
|
|
|
731
732
|
},
|
|
732
733
|
_sign: function (number) {
|
|
733
734
|
if (number === 0) {
|
|
734
|
-
|
|
735
|
+
// that is not what sign usually returns
|
|
736
|
+
// but that is what we need
|
|
737
|
+
return 1;
|
|
735
738
|
}
|
|
736
739
|
if (number > 0) {
|
|
737
740
|
return 1;
|
|
@@ -952,7 +955,7 @@
|
|
|
952
955
|
// Check hsl() format
|
|
953
956
|
if (/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(str)) {
|
|
954
957
|
// Extract h, s, l
|
|
955
|
-
var _a = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(str)
|
|
958
|
+
var _a = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(str); _a[0]; var hsl = _a.slice(1);
|
|
956
959
|
var h = Number(hsl[0]) / 360;
|
|
957
960
|
var s = Number(hsl[1]) / 100;
|
|
958
961
|
var l = Number(hsl[2]) / 100;
|
|
@@ -1087,6 +1090,9 @@
|
|
|
1087
1090
|
var len = p.length, allPoints = [], n, cp;
|
|
1088
1091
|
for (n = 2; n < len - 2; n += 2) {
|
|
1089
1092
|
cp = Util._getControlPoints(p[n - 2], p[n - 1], p[n], p[n + 1], p[n + 2], p[n + 3], tension);
|
|
1093
|
+
if (isNaN(cp[0])) {
|
|
1094
|
+
continue;
|
|
1095
|
+
}
|
|
1090
1096
|
allPoints.push(cp[0]);
|
|
1091
1097
|
allPoints.push(cp[1]);
|
|
1092
1098
|
allPoints.push(p[n]);
|
|
@@ -1492,25 +1498,25 @@
|
|
|
1492
1498
|
};
|
|
1493
1499
|
|
|
1494
1500
|
/*! *****************************************************************************
|
|
1495
|
-
Copyright (c) Microsoft Corporation.
|
|
1496
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
1497
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
1498
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1501
|
+
Copyright (c) Microsoft Corporation.
|
|
1499
1502
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
1503
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
1503
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1504
|
+
purpose with or without fee is hereby granted.
|
|
1504
1505
|
|
|
1505
|
-
|
|
1506
|
-
|
|
1506
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1507
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1508
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1509
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1510
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1511
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1512
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1507
1513
|
***************************************************************************** */
|
|
1508
1514
|
/* global Reflect, Promise */
|
|
1509
1515
|
|
|
1510
1516
|
var extendStatics = function(d, b) {
|
|
1511
1517
|
extendStatics = Object.setPrototypeOf ||
|
|
1512
1518
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1513
|
-
function (d, b) { for (var p in b) if (
|
|
1519
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1514
1520
|
return extendStatics(d, b);
|
|
1515
1521
|
};
|
|
1516
1522
|
|
|
@@ -2151,7 +2157,7 @@
|
|
|
2151
2157
|
shape._fillFunc(this);
|
|
2152
2158
|
};
|
|
2153
2159
|
SceneContext.prototype._fillPattern = function (shape) {
|
|
2154
|
-
var fillPatternX = shape.getFillPatternX(), fillPatternY = shape.getFillPatternY(), fillPatternRotation = Konva.getAngle(shape.getFillPatternRotation()), fillPatternOffsetX = shape.getFillPatternOffsetX(), fillPatternOffsetY = shape.getFillPatternOffsetY()
|
|
2160
|
+
var fillPatternX = shape.getFillPatternX(), fillPatternY = shape.getFillPatternY(), fillPatternRotation = Konva.getAngle(shape.getFillPatternRotation()), fillPatternOffsetX = shape.getFillPatternOffsetX(), fillPatternOffsetY = shape.getFillPatternOffsetY(); shape.getFillPatternScaleX(); shape.getFillPatternScaleY();
|
|
2155
2161
|
if (fillPatternX || fillPatternY) {
|
|
2156
2162
|
this.translate(fillPatternX || 0, fillPatternY || 0);
|
|
2157
2163
|
}
|
|
@@ -3401,7 +3407,8 @@
|
|
|
3401
3407
|
return true;
|
|
3402
3408
|
}
|
|
3403
3409
|
};
|
|
3404
|
-
Node.prototype.shouldDrawHit = function (top) {
|
|
3410
|
+
Node.prototype.shouldDrawHit = function (top, skipDragCheck) {
|
|
3411
|
+
if (skipDragCheck === void 0) { skipDragCheck = false; }
|
|
3405
3412
|
if (top) {
|
|
3406
3413
|
return this._isVisible(top) && this._isListening(top);
|
|
3407
3414
|
}
|
|
@@ -3418,7 +3425,7 @@
|
|
|
3418
3425
|
layerUnderDrag = true;
|
|
3419
3426
|
}
|
|
3420
3427
|
});
|
|
3421
|
-
var dragSkip = !Konva.hitOnDragEnabled && layerUnderDrag;
|
|
3428
|
+
var dragSkip = !skipDragCheck && !Konva.hitOnDragEnabled && layerUnderDrag;
|
|
3422
3429
|
return this.isListening() && this.isVisible() && !dragSkip;
|
|
3423
3430
|
};
|
|
3424
3431
|
/**
|
|
@@ -3519,6 +3526,21 @@
|
|
|
3519
3526
|
y: this.y(),
|
|
3520
3527
|
};
|
|
3521
3528
|
};
|
|
3529
|
+
/**
|
|
3530
|
+
* get absolute position of a node. That function can be used to calculate absolute position, but relative to any ancestor
|
|
3531
|
+
* @method
|
|
3532
|
+
* @name Konva.Node#getAbsolutePosition
|
|
3533
|
+
* @param {Object} Ancestor optional ancestor node
|
|
3534
|
+
* @returns {Konva.Node}
|
|
3535
|
+
* @example
|
|
3536
|
+
*
|
|
3537
|
+
* // returns absolute position relative to top-left corner of canvas
|
|
3538
|
+
* node.getAbsolutePosition();
|
|
3539
|
+
*
|
|
3540
|
+
* // calculate absolute position of node, inside stage
|
|
3541
|
+
* // so stage transforms are ignored
|
|
3542
|
+
* node.getAbsolutePosition(stage)
|
|
3543
|
+
*/
|
|
3522
3544
|
Node.prototype.getAbsolutePosition = function (top) {
|
|
3523
3545
|
var haveCachedParent = false;
|
|
3524
3546
|
var parent = this.parent;
|
|
@@ -4072,7 +4094,7 @@
|
|
|
4072
4094
|
* @name Konva.Node#getAbsoluteRotation
|
|
4073
4095
|
* @returns {Number}
|
|
4074
4096
|
* @example
|
|
4075
|
-
* // get absolute
|
|
4097
|
+
* // get absolute rotation
|
|
4076
4098
|
* var rotation = node.getAbsoluteRotation();
|
|
4077
4099
|
*/
|
|
4078
4100
|
Node.prototype.getAbsoluteRotation = function () {
|
|
@@ -4893,7 +4915,7 @@
|
|
|
4893
4915
|
*/
|
|
4894
4916
|
addGetterSetter(Node, 'name', '', getStringValidator());
|
|
4895
4917
|
/**
|
|
4896
|
-
* get/set name
|
|
4918
|
+
* get/set name.
|
|
4897
4919
|
* @name Konva.Node#name
|
|
4898
4920
|
* @method
|
|
4899
4921
|
* @param {String} name
|
|
@@ -5230,8 +5252,8 @@
|
|
|
5230
5252
|
* @example
|
|
5231
5253
|
* // get node size
|
|
5232
5254
|
* var size = node.size();
|
|
5233
|
-
* var
|
|
5234
|
-
* var
|
|
5255
|
+
* var width = size.width;
|
|
5256
|
+
* var height = size.height;
|
|
5235
5257
|
*
|
|
5236
5258
|
* // set size
|
|
5237
5259
|
* node.size({
|
|
@@ -5451,7 +5473,7 @@
|
|
|
5451
5473
|
* You can provide a string with '#' for id selections and '.' for name selections.
|
|
5452
5474
|
* Or a function that will return true/false when a node is passed through. See example below.
|
|
5453
5475
|
* With strings you can also select by type or class name. Pass multiple selectors
|
|
5454
|
-
* separated by a
|
|
5476
|
+
* separated by a comma.
|
|
5455
5477
|
* @method
|
|
5456
5478
|
* @name Konva.Container#find
|
|
5457
5479
|
* @param {String | Function} selector
|
|
@@ -5907,7 +5929,7 @@
|
|
|
5907
5929
|
MOUSEDOWN,
|
|
5908
5930
|
MOUSEMOVE,
|
|
5909
5931
|
MOUSEUP,
|
|
5910
|
-
|
|
5932
|
+
MOUSELEAVE$1,
|
|
5911
5933
|
TOUCHSTART,
|
|
5912
5934
|
TOUCHMOVE,
|
|
5913
5935
|
TOUCHEND,
|
|
@@ -6234,7 +6256,7 @@
|
|
|
6234
6256
|
this._fire(CONTENT_MOUSEOVER, { evt: evt });
|
|
6235
6257
|
this._fire(MOUSEOVER, { evt: evt, target: this, currentTarget: this });
|
|
6236
6258
|
};
|
|
6237
|
-
Stage.prototype.
|
|
6259
|
+
Stage.prototype._mouseleave = function (evt) {
|
|
6238
6260
|
var _a;
|
|
6239
6261
|
this.setPointersPositions(evt);
|
|
6240
6262
|
var targetShape = ((_a = this.targetShape) === null || _a === void 0 ? void 0 : _a.getStage()) ? this.targetShape : null;
|
|
@@ -7156,7 +7178,7 @@
|
|
|
7156
7178
|
Shape.prototype.intersects = function (point) {
|
|
7157
7179
|
var stage = this.getStage(), bufferHitCanvas = stage.bufferHitCanvas, p;
|
|
7158
7180
|
bufferHitCanvas.getContext().clear();
|
|
7159
|
-
this.drawHit(bufferHitCanvas);
|
|
7181
|
+
this.drawHit(bufferHitCanvas, null, true);
|
|
7160
7182
|
p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;
|
|
7161
7183
|
return p[3] > 0;
|
|
7162
7184
|
};
|
|
@@ -7335,8 +7357,9 @@
|
|
|
7335
7357
|
context.restore();
|
|
7336
7358
|
return this;
|
|
7337
7359
|
};
|
|
7338
|
-
Shape.prototype.drawHit = function (can, top) {
|
|
7339
|
-
if (
|
|
7360
|
+
Shape.prototype.drawHit = function (can, top, skipDragCheck) {
|
|
7361
|
+
if (skipDragCheck === void 0) { skipDragCheck = false; }
|
|
7362
|
+
if (!this.shouldDrawHit(top, skipDragCheck)) {
|
|
7340
7363
|
return this;
|
|
7341
7364
|
}
|
|
7342
7365
|
var layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
|
|
@@ -13826,7 +13849,7 @@
|
|
|
13826
13849
|
var mid = (low + high) >>> 1, substr = line.slice(0, mid + 1), substrWidth = this._getTextWidth(substr) + additionalWidth;
|
|
13827
13850
|
if (substrWidth <= maxWidth) {
|
|
13828
13851
|
low = mid + 1;
|
|
13829
|
-
match = substr
|
|
13852
|
+
match = substr;
|
|
13830
13853
|
matchWidth = substrWidth;
|
|
13831
13854
|
}
|
|
13832
13855
|
else {
|
|
@@ -13939,6 +13962,7 @@
|
|
|
13939
13962
|
'padding',
|
|
13940
13963
|
'wrap',
|
|
13941
13964
|
'lineHeight',
|
|
13965
|
+
'letterSpacing',
|
|
13942
13966
|
];
|
|
13943
13967
|
_registerNode(Text);
|
|
13944
13968
|
/**
|
|
@@ -15033,7 +15057,7 @@
|
|
|
15033
15057
|
}
|
|
15034
15058
|
this._nodes = nodes;
|
|
15035
15059
|
if (nodes.length === 1) {
|
|
15036
|
-
this.rotation(nodes[0].
|
|
15060
|
+
this.rotation(nodes[0].getAbsoluteRotation());
|
|
15037
15061
|
}
|
|
15038
15062
|
else {
|
|
15039
15063
|
this.rotation(0);
|
|
@@ -15045,7 +15069,7 @@
|
|
|
15045
15069
|
var onChange = function () {
|
|
15046
15070
|
//
|
|
15047
15071
|
if (_this.nodes().length === 1) {
|
|
15048
|
-
_this.rotation(_this.nodes()[0].
|
|
15072
|
+
_this.rotation(_this.nodes()[0].getAbsoluteRotation());
|
|
15049
15073
|
}
|
|
15050
15074
|
_this._resetTransformCache();
|
|
15051
15075
|
if (!_this._transforming && !_this.isDragging()) {
|
|
@@ -15260,7 +15284,7 @@
|
|
|
15260
15284
|
name: name + ' _anchor',
|
|
15261
15285
|
dragDistance: 0,
|
|
15262
15286
|
// make it draggable,
|
|
15263
|
-
// so activating the
|
|
15287
|
+
// so activating the anchor will not start drag&drop of any parent
|
|
15264
15288
|
draggable: true,
|
|
15265
15289
|
hitStrokeWidth: TOUCH_DEVICE ? 10 : 'auto',
|
|
15266
15290
|
});
|