konva 9.3.11 → 9.3.12
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/README.md +4 -0
- package/konva.js +43 -54
- package/konva.min.js +3 -3
- package/lib/Global.js +1 -1
- package/lib/Shape.d.ts +3 -3
- package/lib/Shape.js +10 -1
- package/lib/shapes/Path.d.ts +12 -3
- package/lib/shapes/Path.js +21 -43
- package/lib/shapes/TextPath.d.ts +4 -1
- package/lib/shapes/Transformer.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,6 +64,10 @@ Konva works in all modern mobile and desktop browsers. A browser need to be capa
|
|
|
64
64
|
|
|
65
65
|
At the current moment `Konva` doesn't work in IE11 directly. To make it work you just need to provide some polyfills such as `Array.prototype.find`, `String.prototype.trimLeft`, `String.prototype.trimRight`, `Array.from`.
|
|
66
66
|
|
|
67
|
+
# Debugging
|
|
68
|
+
|
|
69
|
+
The Chrome inspector simply shows the canvas element. To see the Konva objects and their details, install the konva-dev extension at https://github.com/konvajs/konva-devtool.
|
|
70
|
+
|
|
67
71
|
# Loading and installing Konva
|
|
68
72
|
|
|
69
73
|
Konva supports UMD loading. So you can use all possible variants to load the framework into your project:
|
package/konva.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* Konva JavaScript Framework v9.3.
|
|
8
|
+
* Konva JavaScript Framework v9.3.12
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date: Thu
|
|
11
|
+
* Date: Thu Jun 20 2024
|
|
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.3.
|
|
38
|
+
version: '9.3.12',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -7147,8 +7147,20 @@
|
|
|
7147
7147
|
};
|
|
7148
7148
|
}
|
|
7149
7149
|
getClientRect(config = {}) {
|
|
7150
|
+
// if we have a cached parent, it will use cached transform matrix
|
|
7151
|
+
// but we don't want to that
|
|
7152
|
+
let hasCachedParent = false;
|
|
7153
|
+
let parent = this.getParent();
|
|
7154
|
+
while (parent) {
|
|
7155
|
+
if (parent.isCached()) {
|
|
7156
|
+
hasCachedParent = true;
|
|
7157
|
+
break;
|
|
7158
|
+
}
|
|
7159
|
+
parent = parent.getParent();
|
|
7160
|
+
}
|
|
7150
7161
|
const skipTransform = config.skipTransform;
|
|
7151
|
-
|
|
7162
|
+
// force relative to stage if we have a cached parent
|
|
7163
|
+
const relativeTo = config.relativeTo || (hasCachedParent && this.getStage()) || undefined;
|
|
7152
7164
|
const fillRect = this.getSelfRect();
|
|
7153
7165
|
const applyStroke = !config.skipStroke && this.hasStroke();
|
|
7154
7166
|
const strokeWidth = (applyStroke && this.strokeWidth()) || 0;
|
|
@@ -11458,58 +11470,30 @@
|
|
|
11458
11470
|
return null;
|
|
11459
11471
|
}
|
|
11460
11472
|
static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX, fromY) {
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
if (
|
|
11465
|
-
|
|
11466
|
-
}
|
|
11467
|
-
var m = (P2y - P1y) / (P2x - P1x + 0.00000001);
|
|
11468
|
-
var run = Math.sqrt((dist * dist) / (1 + m * m));
|
|
11469
|
-
if (P2x < P1x) {
|
|
11470
|
-
run *= -1;
|
|
11473
|
+
fromX = fromX !== null && fromX !== void 0 ? fromX : P1x;
|
|
11474
|
+
fromY = fromY !== null && fromY !== void 0 ? fromY : P1y;
|
|
11475
|
+
const len = this.getLineLength(P1x, P1y, P2x, P2y);
|
|
11476
|
+
if (len < 1e-10) {
|
|
11477
|
+
return { x: P1x, y: P1y };
|
|
11471
11478
|
}
|
|
11472
|
-
var rise = m * run;
|
|
11473
|
-
var pt;
|
|
11474
11479
|
if (P2x === P1x) {
|
|
11475
|
-
//
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
// x: P1x,
|
|
11493
|
-
// y: P1y,
|
|
11494
|
-
// };
|
|
11495
|
-
// }
|
|
11496
|
-
var u = (fromX - P1x) * (P2x - P1x) + (fromY - P1y) * (P2y - P1y);
|
|
11497
|
-
u = u / (len * len);
|
|
11498
|
-
ix = P1x + u * (P2x - P1x);
|
|
11499
|
-
iy = P1y + u * (P2y - P1y);
|
|
11500
|
-
var pRise = this.getLineLength(fromX, fromY, ix, iy);
|
|
11501
|
-
var pRun = Math.sqrt(dist * dist - pRise * pRise);
|
|
11502
|
-
run = Math.sqrt((pRun * pRun) / (1 + m * m));
|
|
11503
|
-
if (P2x < P1x) {
|
|
11504
|
-
run *= -1;
|
|
11505
|
-
}
|
|
11506
|
-
rise = m * run;
|
|
11507
|
-
pt = {
|
|
11508
|
-
x: ix + run,
|
|
11509
|
-
y: iy + rise,
|
|
11510
|
-
};
|
|
11511
|
-
}
|
|
11512
|
-
return pt;
|
|
11480
|
+
// Vertical line
|
|
11481
|
+
return { x: fromX, y: fromY + (P2y > P1y ? dist : -dist) };
|
|
11482
|
+
}
|
|
11483
|
+
const m = (P2y - P1y) / (P2x - P1x);
|
|
11484
|
+
const run = Math.sqrt((dist * dist) / (1 + m * m)) * (P2x < P1x ? -1 : 1);
|
|
11485
|
+
const rise = m * run;
|
|
11486
|
+
if (Math.abs(fromY - P1y - m * (fromX - P1x)) < 1e-10) {
|
|
11487
|
+
return { x: fromX + run, y: fromY + rise };
|
|
11488
|
+
}
|
|
11489
|
+
const u = ((fromX - P1x) * (P2x - P1x) + (fromY - P1y) * (P2y - P1y)) / (len * len);
|
|
11490
|
+
const ix = P1x + u * (P2x - P1x);
|
|
11491
|
+
const iy = P1y + u * (P2y - P1y);
|
|
11492
|
+
const pRise = this.getLineLength(fromX, fromY, ix, iy);
|
|
11493
|
+
const pRun = Math.sqrt(dist * dist - pRise * pRise);
|
|
11494
|
+
const adjustedRun = Math.sqrt((pRun * pRun) / (1 + m * m)) * (P2x < P1x ? -1 : 1);
|
|
11495
|
+
const adjustedRise = m * adjustedRun;
|
|
11496
|
+
return { x: ix + adjustedRun, y: iy + adjustedRise };
|
|
11513
11497
|
}
|
|
11514
11498
|
static getPointOnCubicBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y) {
|
|
11515
11499
|
function CB1(t) {
|
|
@@ -16027,6 +16011,11 @@
|
|
|
16027
16011
|
});
|
|
16028
16012
|
}
|
|
16029
16013
|
_handleMouseDown(e) {
|
|
16014
|
+
// do nothing if we already transforming
|
|
16015
|
+
// that is possible to trigger with multitouch
|
|
16016
|
+
if (this._transforming) {
|
|
16017
|
+
return;
|
|
16018
|
+
}
|
|
16030
16019
|
this._movingAnchorName = e.target.name().split(' ')[0];
|
|
16031
16020
|
var attrs = this._getNodeRect();
|
|
16032
16021
|
var width = attrs.width;
|