konva 9.0.2 → 9.2.0
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 +69 -27
- package/konva.min.js +3 -3
- package/lib/Animation.js +1 -1
- package/lib/Container.d.ts +3 -2
- package/lib/Container.js +3 -2
- package/lib/Context.d.ts +5 -3
- package/lib/Context.js +4 -9
- package/lib/Global.js +1 -1
- package/lib/Shape.d.ts +3 -1
- package/lib/Shape.js +8 -1
- package/lib/Tween.js +1 -1
- package/lib/shapes/Transformer.d.ts +1 -0
- package/lib/shapes/Transformer.js +10 -1
- package/lib/types.js +1 -1
- package/package.json +3 -3
package/konva.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* Konva JavaScript Framework v9.0
|
|
8
|
+
* Konva JavaScript Framework v9.2.0
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Mon Jun 05 2023
|
|
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: '9.0
|
|
38
|
+
version: '9.2.0',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -1712,13 +1712,8 @@
|
|
|
1712
1712
|
clearRect(a0, a1, a2, a3) {
|
|
1713
1713
|
this._context.clearRect(a0, a1, a2, a3);
|
|
1714
1714
|
}
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
* @method
|
|
1718
|
-
* @name Konva.Context#clip
|
|
1719
|
-
*/
|
|
1720
|
-
clip() {
|
|
1721
|
-
this._context.clip();
|
|
1715
|
+
clip(...args) {
|
|
1716
|
+
this._context.clip.apply(this._context, args);
|
|
1722
1717
|
}
|
|
1723
1718
|
/**
|
|
1724
1719
|
* closePath function.
|
|
@@ -1803,18 +1798,9 @@
|
|
|
1803
1798
|
}
|
|
1804
1799
|
return this._context.isPointInPath(x, y, fillRule);
|
|
1805
1800
|
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
* @name Konva.Context#fill
|
|
1810
|
-
*/
|
|
1811
|
-
fill(path2d) {
|
|
1812
|
-
if (path2d) {
|
|
1813
|
-
this._context.fill(path2d);
|
|
1814
|
-
}
|
|
1815
|
-
else {
|
|
1816
|
-
this._context.fill();
|
|
1817
|
-
}
|
|
1801
|
+
fill(...args) {
|
|
1802
|
+
// this._context.fill();
|
|
1803
|
+
this._context.fill.apply(this._context, args);
|
|
1818
1804
|
}
|
|
1819
1805
|
/**
|
|
1820
1806
|
* fillRect function.
|
|
@@ -5619,15 +5605,16 @@
|
|
|
5619
5605
|
var m = transform.getMatrix();
|
|
5620
5606
|
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
5621
5607
|
context.beginPath();
|
|
5608
|
+
let clipArgs;
|
|
5622
5609
|
if (clipFunc) {
|
|
5623
|
-
clipFunc.call(this, context, this);
|
|
5610
|
+
clipArgs = clipFunc.call(this, context, this);
|
|
5624
5611
|
}
|
|
5625
5612
|
else {
|
|
5626
5613
|
var clipX = this.clipX();
|
|
5627
5614
|
var clipY = this.clipY();
|
|
5628
5615
|
context.rect(clipX, clipY, clipWidth, clipHeight);
|
|
5629
5616
|
}
|
|
5630
|
-
context.clip();
|
|
5617
|
+
context.clip.apply(context, clipArgs);
|
|
5631
5618
|
m = transform.copy().invert().getMatrix();
|
|
5632
5619
|
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
5633
5620
|
}
|
|
@@ -5817,10 +5804,15 @@
|
|
|
5817
5804
|
* // get clip function
|
|
5818
5805
|
* var clipFunction = container.clipFunc();
|
|
5819
5806
|
*
|
|
5820
|
-
* // set clip
|
|
5807
|
+
* // set clip function
|
|
5821
5808
|
* container.clipFunc(function(ctx) {
|
|
5822
5809
|
* ctx.rect(0, 0, 100, 100);
|
|
5823
5810
|
* });
|
|
5811
|
+
*
|
|
5812
|
+
* container.clipFunc(function(ctx) {
|
|
5813
|
+
* // optionally return a clip Path2D and clip-rule or just the clip-rule
|
|
5814
|
+
* return [new Path2D('M0 0v50h50Z'), 'evenodd']
|
|
5815
|
+
* });
|
|
5824
5816
|
*/
|
|
5825
5817
|
|
|
5826
5818
|
const Captures = new Map();
|
|
@@ -6692,7 +6684,13 @@
|
|
|
6692
6684
|
// the approach is good. But what if we want to cache the shape before we add it into the stage
|
|
6693
6685
|
// what color to use for hit test?
|
|
6694
6686
|
function _fillFunc$2(context) {
|
|
6695
|
-
|
|
6687
|
+
const fillRule = this.attrs.fillRule;
|
|
6688
|
+
if (fillRule) {
|
|
6689
|
+
context.fill(fillRule);
|
|
6690
|
+
}
|
|
6691
|
+
else {
|
|
6692
|
+
context.fill();
|
|
6693
|
+
}
|
|
6696
6694
|
}
|
|
6697
6695
|
function _strokeFunc$2(context) {
|
|
6698
6696
|
context.stroke();
|
|
@@ -8266,6 +8264,20 @@
|
|
|
8266
8264
|
* // set fill pattern rotation
|
|
8267
8265
|
* shape.fillPatternRotation(20);
|
|
8268
8266
|
*/
|
|
8267
|
+
Factory.addGetterSetter(Shape, 'fillRule', undefined, getStringValidator());
|
|
8268
|
+
/**
|
|
8269
|
+
* get/set fill rule
|
|
8270
|
+
* @name Konva.Shape#fillRule
|
|
8271
|
+
* @method
|
|
8272
|
+
* @param {CanvasFillRule} rotation
|
|
8273
|
+
* @returns {Konva.Shape}
|
|
8274
|
+
* @example
|
|
8275
|
+
* // get fill rule
|
|
8276
|
+
* var fillRule = shape.fillRule();
|
|
8277
|
+
*
|
|
8278
|
+
* // set fill rule
|
|
8279
|
+
* shape.fillRule('evenodd);
|
|
8280
|
+
*/
|
|
8269
8281
|
Factory.backCompat(Shape, {
|
|
8270
8282
|
dashArray: 'dash',
|
|
8271
8283
|
getDashArray: 'getDash',
|
|
@@ -15372,6 +15384,7 @@
|
|
|
15372
15384
|
'anchorFillChange',
|
|
15373
15385
|
'anchorCornerRadiusChange',
|
|
15374
15386
|
'ignoreStrokeChange',
|
|
15387
|
+
'anchorStyleFuncChange',
|
|
15375
15388
|
]
|
|
15376
15389
|
.map((e) => e + `.${EVENTS_NAME}`)
|
|
15377
15390
|
.join(' ');
|
|
@@ -16293,7 +16306,8 @@
|
|
|
16293
16306
|
var resizeEnabled = this.resizeEnabled();
|
|
16294
16307
|
var padding = this.padding();
|
|
16295
16308
|
var anchorSize = this.anchorSize();
|
|
16296
|
-
this.find('._anchor')
|
|
16309
|
+
const anchors = this.find('._anchor');
|
|
16310
|
+
anchors.forEach((node) => {
|
|
16297
16311
|
node.setAttrs({
|
|
16298
16312
|
width: anchorSize,
|
|
16299
16313
|
height: anchorSize,
|
|
@@ -16372,6 +16386,12 @@
|
|
|
16372
16386
|
x: 0,
|
|
16373
16387
|
y: 0,
|
|
16374
16388
|
});
|
|
16389
|
+
const styleFunc = this.anchorStyleFunc();
|
|
16390
|
+
if (styleFunc) {
|
|
16391
|
+
anchors.forEach((node) => {
|
|
16392
|
+
styleFunc(node);
|
|
16393
|
+
});
|
|
16394
|
+
}
|
|
16375
16395
|
(_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
|
|
16376
16396
|
}
|
|
16377
16397
|
/**
|
|
@@ -16801,6 +16821,28 @@
|
|
|
16801
16821
|
* });
|
|
16802
16822
|
*/
|
|
16803
16823
|
Factory.addGetterSetter(Transformer, 'anchorDragBoundFunc');
|
|
16824
|
+
/**
|
|
16825
|
+
* get/set styling function for transformer anchors to overwrite default styles
|
|
16826
|
+
* @name Konva.Transformer#anchorStyleFunc
|
|
16827
|
+
* @method
|
|
16828
|
+
* @param {Function} func
|
|
16829
|
+
* @returns {Function}
|
|
16830
|
+
* @example
|
|
16831
|
+
* // get
|
|
16832
|
+
* var anchorStyleFunc = transformer.anchorStyleFunc();
|
|
16833
|
+
*
|
|
16834
|
+
* // set
|
|
16835
|
+
* transformer.anchorStyleFunc(function(anchor) {
|
|
16836
|
+
* // anchor is a simple Konva.Rect instance
|
|
16837
|
+
* // it will be executed AFTER all attributes are set, like 'anchorStrokeWidth' or 'anchorFill'
|
|
16838
|
+
* if (anchor.hasName('.rotater')) {
|
|
16839
|
+
* // make rotater anchor filled black and looks like a circle
|
|
16840
|
+
* anchor.fill('black');
|
|
16841
|
+
* anchor.cornerRadius(anchor.width() / 2);
|
|
16842
|
+
* }
|
|
16843
|
+
* });
|
|
16844
|
+
*/
|
|
16845
|
+
Factory.addGetterSetter(Transformer, 'anchorStyleFunc');
|
|
16804
16846
|
/**
|
|
16805
16847
|
* using this setting you can drag transformer group by dragging empty space between attached nodes
|
|
16806
16848
|
* shouldOverdrawWholeArea = true may temporary disable all events on attached nodes
|