konva 9.3.0 → 9.3.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 +40 -25
- package/konva.min.js +3 -3
- package/lib/Container.d.ts +7 -3
- package/lib/Container.js +4 -4
- package/lib/Context.d.ts +1 -0
- package/lib/Context.js +4 -0
- package/lib/Global.js +1 -1
- package/lib/Node.d.ts +9 -3
- package/lib/Node.js +16 -7
- package/lib/Shape.d.ts +1 -1
- package/lib/Shape.js +6 -9
- package/lib/Util.d.ts +2 -2
- package/lib/_CoreInternals.d.ts +2 -2
- package/lib/_FullInternals.d.ts +2 -2
- package/lib/shapes/Transformer.d.ts +8 -1
- 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 v9.3.
|
|
8
|
+
* Konva JavaScript Framework v9.3.1
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date: Wed
|
|
11
|
+
* Date: Wed Jan 17 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.1',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -1467,6 +1467,7 @@
|
|
|
1467
1467
|
'putImageData',
|
|
1468
1468
|
'quadraticCurveTo',
|
|
1469
1469
|
'rect',
|
|
1470
|
+
'roundRect',
|
|
1470
1471
|
'restore',
|
|
1471
1472
|
'rotate',
|
|
1472
1473
|
'save',
|
|
@@ -1878,6 +1879,14 @@
|
|
|
1878
1879
|
rect(x, y, width, height) {
|
|
1879
1880
|
this._context.rect(x, y, width, height);
|
|
1880
1881
|
}
|
|
1882
|
+
/**
|
|
1883
|
+
* roundRect function.
|
|
1884
|
+
* @method
|
|
1885
|
+
* @name Konva.Context#roundRect
|
|
1886
|
+
*/
|
|
1887
|
+
roundRect(x, y, width, height, radii) {
|
|
1888
|
+
this._context.roundRect(x, y, width, height, radii);
|
|
1889
|
+
}
|
|
1881
1890
|
/**
|
|
1882
1891
|
* putImageData function.
|
|
1883
1892
|
* @method
|
|
@@ -2696,10 +2705,13 @@
|
|
|
2696
2705
|
Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
|
|
2697
2706
|
return;
|
|
2698
2707
|
}
|
|
2699
|
-
// let's just add 1 pixel extra,
|
|
2700
2708
|
// because using Math.floor on x, y position may shift drawing
|
|
2701
|
-
|
|
2702
|
-
|
|
2709
|
+
// to avoid shift we need to increase size
|
|
2710
|
+
// but we better to avoid it, for better filters flows
|
|
2711
|
+
const extraPaddingX = Math.abs(Math.round(rect.x) - x) > 0.5 ? 1 : 0;
|
|
2712
|
+
const extraPaddingY = Math.abs(Math.round(rect.y) - y) > 0.5 ? 1 : 0;
|
|
2713
|
+
width += offset * 2 + extraPaddingX;
|
|
2714
|
+
height += offset * 2 + extraPaddingY;
|
|
2703
2715
|
x -= offset;
|
|
2704
2716
|
y -= offset;
|
|
2705
2717
|
// if (Math.floor(x) < x) {
|
|
@@ -3160,7 +3172,7 @@
|
|
|
3160
3172
|
* @returns {Object}
|
|
3161
3173
|
*/
|
|
3162
3174
|
getAttrs() {
|
|
3163
|
-
return this.attrs || {};
|
|
3175
|
+
return (this.attrs || {});
|
|
3164
3176
|
}
|
|
3165
3177
|
/**
|
|
3166
3178
|
* set multiple attrs at once using an object literal
|
|
@@ -3688,8 +3700,11 @@
|
|
|
3688
3700
|
* @returns {Object}
|
|
3689
3701
|
*/
|
|
3690
3702
|
toObject() {
|
|
3691
|
-
var
|
|
3692
|
-
obj
|
|
3703
|
+
var attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;
|
|
3704
|
+
const obj = {
|
|
3705
|
+
attrs: {},
|
|
3706
|
+
className: this.getClassName(),
|
|
3707
|
+
};
|
|
3693
3708
|
for (key in attrs) {
|
|
3694
3709
|
val = attrs[key];
|
|
3695
3710
|
// if value is object and object is not plain
|
|
@@ -3709,7 +3724,6 @@
|
|
|
3709
3724
|
obj.attrs[key] = val;
|
|
3710
3725
|
}
|
|
3711
3726
|
}
|
|
3712
|
-
obj.className = this.getClassName();
|
|
3713
3727
|
return Util._prepareToStringify(obj);
|
|
3714
3728
|
}
|
|
3715
3729
|
/**
|
|
@@ -4076,6 +4090,11 @@
|
|
|
4076
4090
|
(stage ? stage.height() : 0),
|
|
4077
4091
|
pixelRatio: pixelRatio,
|
|
4078
4092
|
}), context = canvas.getContext();
|
|
4093
|
+
const bufferCanvas = new SceneCanvas({
|
|
4094
|
+
width: canvas.width,
|
|
4095
|
+
height: canvas.height,
|
|
4096
|
+
pixelRatio: canvas.pixelRatio,
|
|
4097
|
+
});
|
|
4079
4098
|
if (config.imageSmoothingEnabled === false) {
|
|
4080
4099
|
context._context.imageSmoothingEnabled = false;
|
|
4081
4100
|
}
|
|
@@ -4083,7 +4102,7 @@
|
|
|
4083
4102
|
if (x || y) {
|
|
4084
4103
|
context.translate(-1 * x, -1 * y);
|
|
4085
4104
|
}
|
|
4086
|
-
this.drawScene(canvas);
|
|
4105
|
+
this.drawScene(canvas, undefined, bufferCanvas);
|
|
4087
4106
|
context.restore();
|
|
4088
4107
|
return canvas;
|
|
4089
4108
|
}
|
|
@@ -5570,7 +5589,7 @@
|
|
|
5570
5589
|
});
|
|
5571
5590
|
this._requestDraw();
|
|
5572
5591
|
}
|
|
5573
|
-
drawScene(can, top) {
|
|
5592
|
+
drawScene(can, top, bufferCanvas) {
|
|
5574
5593
|
var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas()), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedSceneCanvas = cachedCanvas && cachedCanvas.scene;
|
|
5575
5594
|
var caching = canvas && canvas.isCache;
|
|
5576
5595
|
if (!this.isVisible() && !caching) {
|
|
@@ -5584,7 +5603,7 @@
|
|
|
5584
5603
|
context.restore();
|
|
5585
5604
|
}
|
|
5586
5605
|
else {
|
|
5587
|
-
this._drawChildren('drawScene', canvas, top);
|
|
5606
|
+
this._drawChildren('drawScene', canvas, top, bufferCanvas);
|
|
5588
5607
|
}
|
|
5589
5608
|
return this;
|
|
5590
5609
|
}
|
|
@@ -5605,7 +5624,7 @@
|
|
|
5605
5624
|
}
|
|
5606
5625
|
return this;
|
|
5607
5626
|
}
|
|
5608
|
-
_drawChildren(drawMethod, canvas, top) {
|
|
5627
|
+
_drawChildren(drawMethod, canvas, top, bufferCanvas) {
|
|
5609
5628
|
var _a;
|
|
5610
5629
|
var context = canvas && canvas.getContext(), clipWidth = this.clipWidth(), clipHeight = this.clipHeight(), clipFunc = this.clipFunc(), hasClip = (clipWidth && clipHeight) || clipFunc;
|
|
5611
5630
|
const selfCache = top === this;
|
|
@@ -5636,7 +5655,7 @@
|
|
|
5636
5655
|
context._applyGlobalCompositeOperation(this);
|
|
5637
5656
|
}
|
|
5638
5657
|
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
|
|
5639
|
-
child[drawMethod](canvas, top);
|
|
5658
|
+
child[drawMethod](canvas, top, bufferCanvas);
|
|
5640
5659
|
});
|
|
5641
5660
|
if (hasComposition) {
|
|
5642
5661
|
context.restore();
|
|
@@ -7048,10 +7067,6 @@
|
|
|
7048
7067
|
// so they use that method with forced fill
|
|
7049
7068
|
// it probably will be simpler, then copy/paste the code
|
|
7050
7069
|
var _a;
|
|
7051
|
-
// buffer canvas is available only inside the stage
|
|
7052
|
-
if (!this.getStage()) {
|
|
7053
|
-
return false;
|
|
7054
|
-
}
|
|
7055
7070
|
// force skip buffer canvas
|
|
7056
7071
|
const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;
|
|
7057
7072
|
if (!perfectDrawEnabled) {
|
|
@@ -7139,13 +7154,13 @@
|
|
|
7139
7154
|
}
|
|
7140
7155
|
return rect;
|
|
7141
7156
|
}
|
|
7142
|
-
drawScene(can, top) {
|
|
7157
|
+
drawScene(can, top, bufferCanvas) {
|
|
7143
7158
|
// basically there are 3 drawing modes
|
|
7144
7159
|
// 1 - simple drawing when nothing is cached.
|
|
7145
7160
|
// 2 - when we are caching current
|
|
7146
7161
|
// 3 - when node is cached and we need to draw it into layer
|
|
7147
7162
|
var layer = this.getLayer();
|
|
7148
|
-
var canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage,
|
|
7163
|
+
var canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferContext;
|
|
7149
7164
|
var skipBuffer = canvas.isCache;
|
|
7150
7165
|
var cachingSelf = top === this;
|
|
7151
7166
|
if (!this.isVisible() && !cachingSelf) {
|
|
@@ -7167,8 +7182,8 @@
|
|
|
7167
7182
|
// if buffer canvas is needed
|
|
7168
7183
|
if (this._useBufferCanvas() && !skipBuffer) {
|
|
7169
7184
|
stage = this.getStage();
|
|
7170
|
-
|
|
7171
|
-
bufferContext =
|
|
7185
|
+
const bc = bufferCanvas || stage.bufferCanvas;
|
|
7186
|
+
bufferContext = bc.getContext();
|
|
7172
7187
|
bufferContext.clear();
|
|
7173
7188
|
bufferContext.save();
|
|
7174
7189
|
bufferContext._applyLineJoin(this);
|
|
@@ -7177,13 +7192,13 @@
|
|
|
7177
7192
|
bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
|
|
7178
7193
|
drawFunc.call(this, bufferContext, this);
|
|
7179
7194
|
bufferContext.restore();
|
|
7180
|
-
var ratio =
|
|
7195
|
+
var ratio = bc.pixelRatio;
|
|
7181
7196
|
if (hasShadow) {
|
|
7182
7197
|
context._applyShadow(this);
|
|
7183
7198
|
}
|
|
7184
7199
|
context._applyOpacity(this);
|
|
7185
7200
|
context._applyGlobalCompositeOperation(this);
|
|
7186
|
-
context.drawImage(
|
|
7201
|
+
context.drawImage(bc._canvas, 0, 0, bc.width / ratio, bc.height / ratio);
|
|
7187
7202
|
}
|
|
7188
7203
|
else {
|
|
7189
7204
|
context._applyLineJoin(this);
|