konva 9.2.2 → 9.3.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 +41 -33
- package/konva.min.js +3 -3
- package/lib/Global.js +1 -1
- package/lib/Node.js +1 -1
- package/lib/index-types.d.ts +9 -9
- package/lib/shapes/Transformer.d.ts +2 -0
- package/lib/shapes/Transformer.js +15 -21
- package/package.json +11 -11
package/konva.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* Konva JavaScript Framework v9.
|
|
8
|
+
* Konva JavaScript Framework v9.3.0
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Wed Dec 20 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.
|
|
38
|
+
version: '9.3.0',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -4217,7 +4217,7 @@
|
|
|
4217
4217
|
this.toCanvas(config).toBlob((blob) => {
|
|
4218
4218
|
resolve(blob);
|
|
4219
4219
|
callback === null || callback === void 0 ? void 0 : callback(blob);
|
|
4220
|
-
});
|
|
4220
|
+
}, config === null || config === void 0 ? void 0 : config.mimeType, config === null || config === void 0 ? void 0 : config.quality);
|
|
4221
4221
|
}
|
|
4222
4222
|
catch (err) {
|
|
4223
4223
|
reject(err);
|
|
@@ -6887,11 +6887,11 @@
|
|
|
6887
6887
|
const m = tr.getMatrix();
|
|
6888
6888
|
const matrix = typeof DOMMatrix === 'undefined'
|
|
6889
6889
|
? {
|
|
6890
|
-
a: m[0],
|
|
6891
|
-
b: m[1],
|
|
6892
|
-
c: m[2],
|
|
6890
|
+
a: m[0], // Horizontal scaling. A value of 1 results in no scaling.
|
|
6891
|
+
b: m[1], // Vertical skewing.
|
|
6892
|
+
c: m[2], // Horizontal skewing.
|
|
6893
6893
|
d: m[3],
|
|
6894
|
-
e: m[4],
|
|
6894
|
+
e: m[4], // Horizontal translation (moving).
|
|
6895
6895
|
f: m[5], // Vertical translation (moving).
|
|
6896
6896
|
}
|
|
6897
6897
|
: new DOMMatrix(m);
|
|
@@ -8317,10 +8317,10 @@
|
|
|
8317
8317
|
* 8 - 7 - 6
|
|
8318
8318
|
*/
|
|
8319
8319
|
INTERSECTION_OFFSETS = [
|
|
8320
|
-
{ x: 0, y: 0 },
|
|
8321
|
-
{ x: -1, y: -1 },
|
|
8322
|
-
{ x: 1, y: -1 },
|
|
8323
|
-
{ x: 1, y: 1 },
|
|
8320
|
+
{ x: 0, y: 0 }, // 0
|
|
8321
|
+
{ x: -1, y: -1 }, // 2
|
|
8322
|
+
{ x: 1, y: -1 }, // 4
|
|
8323
|
+
{ x: 1, y: 1 }, // 6
|
|
8324
8324
|
{ x: -1, y: 1 }, // 8
|
|
8325
8325
|
], INTERSECTION_OFFSETS_LEN = INTERSECTION_OFFSETS.length;
|
|
8326
8326
|
/**
|
|
@@ -15566,6 +15566,7 @@
|
|
|
15566
15566
|
* @param {Object} config
|
|
15567
15567
|
* @param {Boolean} [config.resizeEnabled] Default is true
|
|
15568
15568
|
* @param {Boolean} [config.rotateEnabled] Default is true
|
|
15569
|
+
* @param {Boolean} [config.rotateLineVisible] Default is true
|
|
15569
15570
|
* @param {Array} [config.rotationSnaps] Array of angles for rotation snaps. Default is []
|
|
15570
15571
|
* @param {Number} [config.rotationSnapTolerance] Snapping tolerance. If closer than this it will snap. Default is 5
|
|
15571
15572
|
* @param {Number} [config.rotateAnchorOffset] Default is 50
|
|
@@ -15927,7 +15928,7 @@
|
|
|
15927
15928
|
ctx.beginPath();
|
|
15928
15929
|
ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);
|
|
15929
15930
|
ctx.moveTo(shape.width() / 2, -padding);
|
|
15930
|
-
if (tr.rotateEnabled()) {
|
|
15931
|
+
if (tr.rotateEnabled() && tr.rotateLineVisible()) {
|
|
15931
15932
|
ctx.lineTo(shape.width() / 2, -tr.rotateAnchorOffset() * Util._sign(shape.height()) - padding);
|
|
15932
15933
|
}
|
|
15933
15934
|
ctx.fillStrokeShape(shape);
|
|
@@ -16210,7 +16211,6 @@
|
|
|
16210
16211
|
this.update();
|
|
16211
16212
|
return;
|
|
16212
16213
|
}
|
|
16213
|
-
const allowNegativeScale = this.flipEnabled();
|
|
16214
16214
|
var t = new Transform();
|
|
16215
16215
|
t.rotate(Konva$2.getAngle(this.rotation()));
|
|
16216
16216
|
if (this._movingAnchorName &&
|
|
@@ -16226,10 +16226,6 @@
|
|
|
16226
16226
|
this._movingAnchorName = this._movingAnchorName.replace('left', 'right');
|
|
16227
16227
|
this._anchorDragOffset.x -= offset.x;
|
|
16228
16228
|
this._anchorDragOffset.y -= offset.y;
|
|
16229
|
-
if (!allowNegativeScale) {
|
|
16230
|
-
this.update();
|
|
16231
|
-
return;
|
|
16232
|
-
}
|
|
16233
16229
|
}
|
|
16234
16230
|
else if (this._movingAnchorName &&
|
|
16235
16231
|
newAttrs.width < 0 &&
|
|
@@ -16242,10 +16238,6 @@
|
|
|
16242
16238
|
this._anchorDragOffset.x -= offset.x;
|
|
16243
16239
|
this._anchorDragOffset.y -= offset.y;
|
|
16244
16240
|
newAttrs.width += this.padding() * 2;
|
|
16245
|
-
if (!allowNegativeScale) {
|
|
16246
|
-
this.update();
|
|
16247
|
-
return;
|
|
16248
|
-
}
|
|
16249
16241
|
}
|
|
16250
16242
|
if (this._movingAnchorName &&
|
|
16251
16243
|
newAttrs.height < 0 &&
|
|
@@ -16260,10 +16252,6 @@
|
|
|
16260
16252
|
this._anchorDragOffset.x -= offset.x;
|
|
16261
16253
|
this._anchorDragOffset.y -= offset.y;
|
|
16262
16254
|
newAttrs.height += this.padding() * 2;
|
|
16263
|
-
if (!allowNegativeScale) {
|
|
16264
|
-
this.update();
|
|
16265
|
-
return;
|
|
16266
|
-
}
|
|
16267
16255
|
}
|
|
16268
16256
|
else if (this._movingAnchorName &&
|
|
16269
16257
|
newAttrs.height < 0 &&
|
|
@@ -16276,10 +16264,6 @@
|
|
|
16276
16264
|
this._anchorDragOffset.x -= offset.x;
|
|
16277
16265
|
this._anchorDragOffset.y -= offset.y;
|
|
16278
16266
|
newAttrs.height += this.padding() * 2;
|
|
16279
|
-
if (!allowNegativeScale) {
|
|
16280
|
-
this.update();
|
|
16281
|
-
return;
|
|
16282
|
-
}
|
|
16283
16267
|
}
|
|
16284
16268
|
if (this.boundBoxFunc()) {
|
|
16285
16269
|
const bounded = this.boundBoxFunc()(oldAttrs, newAttrs);
|
|
@@ -16300,9 +16284,19 @@
|
|
|
16300
16284
|
oldTr.rotate(oldAttrs.rotation);
|
|
16301
16285
|
oldTr.scale(oldAttrs.width / baseSize, oldAttrs.height / baseSize);
|
|
16302
16286
|
const newTr = new Transform();
|
|
16303
|
-
|
|
16304
|
-
|
|
16305
|
-
|
|
16287
|
+
const newScaleX = newAttrs.width / baseSize;
|
|
16288
|
+
const newScaleY = newAttrs.height / baseSize;
|
|
16289
|
+
if (this.flipEnabled() === false) {
|
|
16290
|
+
newTr.translate(newAttrs.x, newAttrs.y);
|
|
16291
|
+
newTr.rotate(newAttrs.rotation);
|
|
16292
|
+
newTr.translate(newAttrs.width < 0 ? newAttrs.width : 0, newAttrs.height < 0 ? newAttrs.height : 0);
|
|
16293
|
+
newTr.scale(Math.abs(newScaleX), Math.abs(newScaleY));
|
|
16294
|
+
}
|
|
16295
|
+
else {
|
|
16296
|
+
newTr.translate(newAttrs.x, newAttrs.y);
|
|
16297
|
+
newTr.rotate(newAttrs.rotation);
|
|
16298
|
+
newTr.scale(newScaleX, newScaleY);
|
|
16299
|
+
}
|
|
16306
16300
|
// now lets think we had [old transform] and n ow we have [new transform]
|
|
16307
16301
|
// Now, the questions is: how can we transform "parent" to go from [old transform] into [new transform]
|
|
16308
16302
|
// in equation it will be:
|
|
@@ -16592,6 +16586,20 @@
|
|
|
16592
16586
|
* transformer.rotateEnabled(false);
|
|
16593
16587
|
*/
|
|
16594
16588
|
Factory.addGetterSetter(Transformer, 'rotateEnabled', true);
|
|
16589
|
+
/**
|
|
16590
|
+
* get/set visibility of a little line that connects transformer and rotate anchor.
|
|
16591
|
+
* @name Konva.Transformer#rotateLineVisible
|
|
16592
|
+
* @method
|
|
16593
|
+
* @param {Boolean} enabled
|
|
16594
|
+
* @returns {Boolean}
|
|
16595
|
+
* @example
|
|
16596
|
+
* // get
|
|
16597
|
+
* var rotateLineVisible = transformer.rotateLineVisible();
|
|
16598
|
+
*
|
|
16599
|
+
* // set
|
|
16600
|
+
* transformer.rotateLineVisible(false);
|
|
16601
|
+
*/
|
|
16602
|
+
Factory.addGetterSetter(Transformer, 'rotateLineVisible', true);
|
|
16595
16603
|
/**
|
|
16596
16604
|
* get/set rotation snaps angles.
|
|
16597
16605
|
* @name Konva.Transformer#rotationSnaps
|