konva 9.2.0 → 9.2.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 +239 -660
- package/konva.min.js +3 -3
- package/lib/Animation.d.ts +4 -4
- package/lib/Animation.js +27 -26
- package/lib/Container.d.ts +7 -6
- package/lib/Container.js +2 -3
- package/lib/Context.d.ts +24 -24
- package/lib/Context.js +51 -51
- package/lib/DragAndDrop.d.ts +2 -2
- package/lib/Factory.d.ts +2 -1
- package/lib/Global.d.ts +3 -3
- package/lib/Global.js +2 -2
- package/lib/Layer.d.ts +4 -4
- package/lib/Node.d.ts +15 -15
- package/lib/Node.js +15 -12
- package/lib/PointerEvents.d.ts +1 -1
- package/lib/Shape.d.ts +6 -6
- package/lib/Shape.js +9 -4
- package/lib/Stage.d.ts +10 -10
- package/lib/Stage.js +24 -21
- package/lib/Tween.d.ts +3 -3
- package/lib/Util.d.ts +58 -18
- package/lib/Util.js +7 -3
- package/lib/Validators.d.ts +9 -9
- package/lib/_CoreInternals.d.ts +62 -22
- package/lib/_FullInternals.d.ts +62 -22
- package/lib/filters/Blur.js +49 -512
- package/lib/shapes/Path.d.ts +6 -6
- package/lib/shapes/Path.js +1 -1
- package/lib/shapes/RegularPolygon.d.ts +4 -4
- package/lib/shapes/Text.d.ts +1 -0
- package/lib/shapes/Text.js +9 -0
- package/lib/shapes/TextPath.d.ts +6 -5
- package/lib/shapes/Transformer.d.ts +4 -2
- package/lib/shapes/Transformer.js +21 -14
- package/lib/types.d.ts +1 -1
- package/package.json +9 -9
package/lib/Animation.d.ts
CHANGED
|
@@ -6,14 +6,14 @@ export declare class Animation {
|
|
|
6
6
|
layers: Layer[];
|
|
7
7
|
frame: IFrame;
|
|
8
8
|
constructor(func: AnimationFn, layers?: any);
|
|
9
|
-
setLayers(layers:
|
|
9
|
+
setLayers(layers: null | Layer | Layer[]): this;
|
|
10
10
|
getLayers(): Layer[];
|
|
11
|
-
addLayer(layer:
|
|
11
|
+
addLayer(layer: Layer): boolean;
|
|
12
12
|
isRunning(): boolean;
|
|
13
13
|
start(): this;
|
|
14
14
|
stop(): this;
|
|
15
|
-
_updateFrameObject(time:
|
|
16
|
-
static animations:
|
|
15
|
+
_updateFrameObject(time: number): void;
|
|
16
|
+
static animations: Array<Animation>;
|
|
17
17
|
static animIdCounter: number;
|
|
18
18
|
static animRunning: boolean;
|
|
19
19
|
static _addAnimation(anim: any): void;
|
package/lib/Animation.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Animation = void 0;
|
|
4
4
|
const Global_1 = require("./Global");
|
|
5
5
|
const Util_1 = require("./Util");
|
|
6
|
-
|
|
6
|
+
const now = (function () {
|
|
7
7
|
if (Global_1.glob.performance && Global_1.glob.performance.now) {
|
|
8
8
|
return function () {
|
|
9
9
|
return Global_1.glob.performance.now();
|
|
@@ -26,15 +26,9 @@ class Animation {
|
|
|
26
26
|
this.setLayers(layers);
|
|
27
27
|
}
|
|
28
28
|
setLayers(layers) {
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
lays = [];
|
|
32
|
-
}
|
|
33
|
-
else if (layers.length > 0) {
|
|
34
|
-
lays = layers;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
lays = [layers];
|
|
29
|
+
let lays = [];
|
|
30
|
+
if (layers) {
|
|
31
|
+
lays = Array.isArray(layers) ? layers : [layers];
|
|
38
32
|
}
|
|
39
33
|
this.layers = lays;
|
|
40
34
|
return this;
|
|
@@ -43,8 +37,9 @@ class Animation {
|
|
|
43
37
|
return this.layers;
|
|
44
38
|
}
|
|
45
39
|
addLayer(layer) {
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
const layers = this.layers;
|
|
41
|
+
const len = layers.length;
|
|
42
|
+
for (let n = 0; n < len; n++) {
|
|
48
43
|
if (layers[n]._id === layer._id) {
|
|
49
44
|
return false;
|
|
50
45
|
}
|
|
@@ -53,8 +48,10 @@ class Animation {
|
|
|
53
48
|
return true;
|
|
54
49
|
}
|
|
55
50
|
isRunning() {
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const a = Animation;
|
|
52
|
+
const animations = a.animations;
|
|
53
|
+
const len = animations.length;
|
|
54
|
+
for (let n = 0; n < len; n++) {
|
|
58
55
|
if (animations[n].id === this.id) {
|
|
59
56
|
return true;
|
|
60
57
|
}
|
|
@@ -83,8 +80,10 @@ class Animation {
|
|
|
83
80
|
this._handleAnimation();
|
|
84
81
|
}
|
|
85
82
|
static _removeAnimation(anim) {
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
const id = anim.id;
|
|
84
|
+
const animations = this.animations;
|
|
85
|
+
const len = animations.length;
|
|
86
|
+
for (let n = 0; n < len; n++) {
|
|
88
87
|
if (animations[n].id === id) {
|
|
89
88
|
this.animations.splice(n, 1);
|
|
90
89
|
break;
|
|
@@ -92,13 +91,15 @@ class Animation {
|
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
static _runFrames() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
const layerHash = {};
|
|
95
|
+
const animations = this.animations;
|
|
96
|
+
for (let n = 0; n < animations.length; n++) {
|
|
97
|
+
const anim = animations[n];
|
|
98
|
+
const layers = anim.layers;
|
|
99
|
+
const func = anim.func;
|
|
100
100
|
anim._updateFrameObject(now());
|
|
101
|
-
layersLen = layers.length;
|
|
101
|
+
const layersLen = layers.length;
|
|
102
|
+
let needRedraw;
|
|
102
103
|
if (func) {
|
|
103
104
|
needRedraw = func.call(anim, anim.frame) !== false;
|
|
104
105
|
}
|
|
@@ -108,14 +109,14 @@ class Animation {
|
|
|
108
109
|
if (!needRedraw) {
|
|
109
110
|
continue;
|
|
110
111
|
}
|
|
111
|
-
for (i = 0; i < layersLen; i++) {
|
|
112
|
-
layer = layers[i];
|
|
112
|
+
for (let i = 0; i < layersLen; i++) {
|
|
113
|
+
const layer = layers[i];
|
|
113
114
|
if (layer._id !== undefined) {
|
|
114
115
|
layerHash[layer._id] = layer;
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
|
-
for (key in layerHash) {
|
|
119
|
+
for (let key in layerHash) {
|
|
119
120
|
if (!layerHash.hasOwnProperty(key)) {
|
|
120
121
|
continue;
|
|
121
122
|
}
|
|
@@ -123,7 +124,7 @@ class Animation {
|
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
static _animationLoop() {
|
|
126
|
-
|
|
127
|
+
const Anim = Animation;
|
|
127
128
|
if (Anim.animations.length) {
|
|
128
129
|
Anim._runFrames();
|
|
129
130
|
Util_1.Util.requestAnimFrame(Anim._animationLoop);
|
package/lib/Container.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Node, NodeConfig } from './Node.js';
|
|
2
2
|
import { GetSet, IRect } from './types.js';
|
|
3
|
+
import { Shape } from './Shape.js';
|
|
3
4
|
import { HitCanvas, SceneCanvas } from './Canvas.js';
|
|
4
5
|
import { SceneContext } from './Context.js';
|
|
5
6
|
export type ClipFuncOutput = void | [Path2D | CanvasFillRule] | [Path2D, CanvasFillRule];
|
|
@@ -12,7 +13,7 @@ export interface ContainerConfig extends NodeConfig {
|
|
|
12
13
|
clipHeight?: number;
|
|
13
14
|
}
|
|
14
15
|
export declare abstract class Container<ChildType extends Node = Node> extends Node<ContainerConfig> {
|
|
15
|
-
children: Array<ChildType
|
|
16
|
+
children: Array<ChildType>;
|
|
16
17
|
getChildren(filterFunc?: (item: Node) => boolean): ChildType[];
|
|
17
18
|
hasChildren(): boolean;
|
|
18
19
|
removeChildren(): this;
|
|
@@ -20,14 +21,14 @@ export declare abstract class Container<ChildType extends Node = Node> extends N
|
|
|
20
21
|
abstract _validateAdd(node: Node): void;
|
|
21
22
|
add(...children: ChildType[]): this;
|
|
22
23
|
destroy(): this;
|
|
23
|
-
find<ChildNode extends Node
|
|
24
|
-
findOne<ChildNode extends Node = Node>(selector: string | Function): ChildNode;
|
|
25
|
-
_generalFind<ChildNode extends Node
|
|
24
|
+
find<ChildNode extends Node>(selector: any): Array<ChildNode>;
|
|
25
|
+
findOne<ChildNode extends Node = Node>(selector: string | Function): ChildNode | undefined;
|
|
26
|
+
_generalFind<ChildNode extends Node>(selector: string | Function, findOne: boolean): ChildNode[];
|
|
26
27
|
private _descendants;
|
|
27
28
|
toObject(): any;
|
|
28
29
|
isAncestorOf(node: Node): boolean;
|
|
29
30
|
clone(obj?: any): this;
|
|
30
|
-
getAllIntersections(pos: any):
|
|
31
|
+
getAllIntersections(pos: any): Shape<import("./Shape.js").ShapeConfig>[];
|
|
31
32
|
_clearSelfAndDescendantCache(attr?: string): void;
|
|
32
33
|
_setChildrenIndices(): void;
|
|
33
34
|
drawScene(can?: SceneCanvas, top?: Node): this;
|
|
@@ -44,5 +45,5 @@ export declare abstract class Container<ChildType extends Node = Node> extends N
|
|
|
44
45
|
clipY: GetSet<number, this>;
|
|
45
46
|
clipWidth: GetSet<number, this>;
|
|
46
47
|
clipHeight: GetSet<number, this>;
|
|
47
|
-
clipFunc: GetSet<(ctx: CanvasRenderingContext2D, shape: Container
|
|
48
|
+
clipFunc: GetSet<(ctx: CanvasRenderingContext2D, shape: Container) => ClipFuncOutput, this>;
|
|
48
49
|
}
|
package/lib/Container.js
CHANGED
|
@@ -144,7 +144,7 @@ class Container extends Node_1.Node {
|
|
|
144
144
|
}
|
|
145
145
|
getAllIntersections(pos) {
|
|
146
146
|
var arr = [];
|
|
147
|
-
this.find('Shape').forEach(
|
|
147
|
+
this.find('Shape').forEach((shape) => {
|
|
148
148
|
if (shape.isVisible() && shape.intersects(pos)) {
|
|
149
149
|
arr.push(shape);
|
|
150
150
|
}
|
|
@@ -243,9 +243,8 @@ class Container extends Node_1.Node {
|
|
|
243
243
|
context.restore();
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
getClientRect(config) {
|
|
246
|
+
getClientRect(config = {}) {
|
|
247
247
|
var _a;
|
|
248
|
-
config = config || {};
|
|
249
248
|
var skipTransform = config.skipTransform;
|
|
250
249
|
var relativeTo = config.relativeTo;
|
|
251
250
|
var minX, minY, maxX, maxY;
|
package/lib/Context.d.ts
CHANGED
|
@@ -23,20 +23,20 @@ export declare class Context {
|
|
|
23
23
|
_applyOpacity(shape: Node): void;
|
|
24
24
|
_applyLineJoin(shape: Shape): void;
|
|
25
25
|
setAttr(attr: string, val: any): void;
|
|
26
|
-
arc(
|
|
27
|
-
arcTo(
|
|
26
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterClockwise?: boolean): void;
|
|
27
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
28
28
|
beginPath(): void;
|
|
29
|
-
bezierCurveTo(
|
|
30
|
-
clearRect(
|
|
29
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
|
30
|
+
clearRect(x: number, y: number, width: number, height: number): void;
|
|
31
31
|
clip(fillRule?: CanvasFillRule): void;
|
|
32
32
|
clip(path: Path2D, fillRule?: CanvasFillRule): void;
|
|
33
33
|
closePath(): void;
|
|
34
|
-
createImageData(
|
|
35
|
-
createLinearGradient(
|
|
36
|
-
createPattern(
|
|
37
|
-
createRadialGradient(
|
|
38
|
-
drawImage(
|
|
39
|
-
ellipse(
|
|
34
|
+
createImageData(width: any, height: any): ImageData | undefined;
|
|
35
|
+
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
|
|
36
|
+
createPattern(image: CanvasImageSource, repetition: string | null): CanvasPattern | null;
|
|
37
|
+
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
|
|
38
|
+
drawImage(image: CanvasImageSource, sx: number, sy: number, sWidth?: number, sHeight?: number, dx?: number, dy?: number, dWidth?: number, dHeight?: number): void;
|
|
39
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
|
40
40
|
isPointInPath(x: number, y: number, path?: Path2D, fillRule?: CanvasFillRule): boolean;
|
|
41
41
|
fill(fillRule?: CanvasFillRule): void;
|
|
42
42
|
fill(path: Path2D, fillRule?: CanvasFillRule): void;
|
|
@@ -44,23 +44,23 @@ export declare class Context {
|
|
|
44
44
|
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
45
45
|
fillText(text: string, x: number, y: number, maxWidth?: number): void;
|
|
46
46
|
measureText(text: string): TextMetrics;
|
|
47
|
-
getImageData(
|
|
48
|
-
lineTo(
|
|
49
|
-
moveTo(
|
|
50
|
-
rect(
|
|
51
|
-
putImageData(
|
|
52
|
-
quadraticCurveTo(
|
|
47
|
+
getImageData(sx: number, sy: number, sw: number, sh: number): ImageData;
|
|
48
|
+
lineTo(x: number, y: number): void;
|
|
49
|
+
moveTo(x: number, y: number): void;
|
|
50
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
51
|
+
putImageData(imageData: ImageData, dx: number, dy: number): void;
|
|
52
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
53
53
|
restore(): void;
|
|
54
|
-
rotate(
|
|
54
|
+
rotate(angle: number): void;
|
|
55
55
|
save(): void;
|
|
56
|
-
scale(
|
|
57
|
-
setLineDash(
|
|
56
|
+
scale(x: number, y: number): void;
|
|
57
|
+
setLineDash(segments: number[]): void;
|
|
58
58
|
getLineDash(): number[];
|
|
59
|
-
setTransform(
|
|
59
|
+
setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
60
60
|
stroke(path2d?: Path2D): void;
|
|
61
|
-
strokeText(
|
|
62
|
-
transform(
|
|
63
|
-
translate(
|
|
61
|
+
strokeText(text: string, x: number, y: number, maxWidth?: number): void;
|
|
62
|
+
transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
63
|
+
translate(x: number, y: number): void;
|
|
64
64
|
_enableTrace(): void;
|
|
65
65
|
_applyGlobalCompositeOperation(node: any): void;
|
|
66
66
|
}
|
|
@@ -69,7 +69,7 @@ export interface Context extends CanvasContextProps {
|
|
|
69
69
|
}
|
|
70
70
|
export declare class SceneContext extends Context {
|
|
71
71
|
constructor(canvas: Canvas, { willReadFrequently }?: {
|
|
72
|
-
willReadFrequently?: boolean;
|
|
72
|
+
willReadFrequently?: boolean | undefined;
|
|
73
73
|
});
|
|
74
74
|
_fillColor(shape: Shape): void;
|
|
75
75
|
_fillPattern(shape: Shape): void;
|
package/lib/Context.js
CHANGED
|
@@ -183,20 +183,20 @@ class Context {
|
|
|
183
183
|
setAttr(attr, val) {
|
|
184
184
|
this._context[attr] = val;
|
|
185
185
|
}
|
|
186
|
-
arc(
|
|
187
|
-
this._context.arc(
|
|
186
|
+
arc(x, y, radius, startAngle, endAngle, counterClockwise) {
|
|
187
|
+
this._context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
|
|
188
188
|
}
|
|
189
|
-
arcTo(
|
|
190
|
-
this._context.arcTo(
|
|
189
|
+
arcTo(x1, y1, x2, y2, radius) {
|
|
190
|
+
this._context.arcTo(x1, y1, x2, y2, radius);
|
|
191
191
|
}
|
|
192
192
|
beginPath() {
|
|
193
193
|
this._context.beginPath();
|
|
194
194
|
}
|
|
195
|
-
bezierCurveTo(
|
|
196
|
-
this._context.bezierCurveTo(
|
|
195
|
+
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
196
|
+
this._context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
197
197
|
}
|
|
198
|
-
clearRect(
|
|
199
|
-
this._context.clearRect(
|
|
198
|
+
clearRect(x, y, width, height) {
|
|
199
|
+
this._context.clearRect(x, y, width, height);
|
|
200
200
|
}
|
|
201
201
|
clip(...args) {
|
|
202
202
|
this._context.clip.apply(this._context, args);
|
|
@@ -204,38 +204,38 @@ class Context {
|
|
|
204
204
|
closePath() {
|
|
205
205
|
this._context.closePath();
|
|
206
206
|
}
|
|
207
|
-
createImageData(
|
|
207
|
+
createImageData(width, height) {
|
|
208
208
|
var a = arguments;
|
|
209
209
|
if (a.length === 2) {
|
|
210
|
-
return this._context.createImageData(
|
|
210
|
+
return this._context.createImageData(width, height);
|
|
211
211
|
}
|
|
212
212
|
else if (a.length === 1) {
|
|
213
|
-
return this._context.createImageData(
|
|
213
|
+
return this._context.createImageData(width);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
createLinearGradient(
|
|
217
|
-
return this._context.createLinearGradient(
|
|
216
|
+
createLinearGradient(x0, y0, x1, y1) {
|
|
217
|
+
return this._context.createLinearGradient(x0, y0, x1, y1);
|
|
218
218
|
}
|
|
219
|
-
createPattern(
|
|
220
|
-
return this._context.createPattern(
|
|
219
|
+
createPattern(image, repetition) {
|
|
220
|
+
return this._context.createPattern(image, repetition);
|
|
221
221
|
}
|
|
222
|
-
createRadialGradient(
|
|
223
|
-
return this._context.createRadialGradient(
|
|
222
|
+
createRadialGradient(x0, y0, r0, x1, y1, r1) {
|
|
223
|
+
return this._context.createRadialGradient(x0, y0, r0, x1, y1, r1);
|
|
224
224
|
}
|
|
225
|
-
drawImage(
|
|
225
|
+
drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {
|
|
226
226
|
var a = arguments, _context = this._context;
|
|
227
227
|
if (a.length === 3) {
|
|
228
|
-
_context.drawImage(
|
|
228
|
+
_context.drawImage(image, sx, sy);
|
|
229
229
|
}
|
|
230
230
|
else if (a.length === 5) {
|
|
231
|
-
_context.drawImage(
|
|
231
|
+
_context.drawImage(image, sx, sy, sWidth, sHeight);
|
|
232
232
|
}
|
|
233
233
|
else if (a.length === 9) {
|
|
234
|
-
_context.drawImage(
|
|
234
|
+
_context.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
ellipse(
|
|
238
|
-
this._context.ellipse(
|
|
237
|
+
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
|
|
238
|
+
this._context.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise);
|
|
239
239
|
}
|
|
240
240
|
isPointInPath(x, y, path, fillRule) {
|
|
241
241
|
if (path) {
|
|
@@ -263,52 +263,52 @@ class Context {
|
|
|
263
263
|
measureText(text) {
|
|
264
264
|
return this._context.measureText(text);
|
|
265
265
|
}
|
|
266
|
-
getImageData(
|
|
267
|
-
return this._context.getImageData(
|
|
266
|
+
getImageData(sx, sy, sw, sh) {
|
|
267
|
+
return this._context.getImageData(sx, sy, sw, sh);
|
|
268
268
|
}
|
|
269
|
-
lineTo(
|
|
270
|
-
this._context.lineTo(
|
|
269
|
+
lineTo(x, y) {
|
|
270
|
+
this._context.lineTo(x, y);
|
|
271
271
|
}
|
|
272
|
-
moveTo(
|
|
273
|
-
this._context.moveTo(
|
|
272
|
+
moveTo(x, y) {
|
|
273
|
+
this._context.moveTo(x, y);
|
|
274
274
|
}
|
|
275
|
-
rect(
|
|
276
|
-
this._context.rect(
|
|
275
|
+
rect(x, y, width, height) {
|
|
276
|
+
this._context.rect(x, y, width, height);
|
|
277
277
|
}
|
|
278
|
-
putImageData(
|
|
279
|
-
this._context.putImageData(
|
|
278
|
+
putImageData(imageData, dx, dy) {
|
|
279
|
+
this._context.putImageData(imageData, dx, dy);
|
|
280
280
|
}
|
|
281
|
-
quadraticCurveTo(
|
|
282
|
-
this._context.quadraticCurveTo(
|
|
281
|
+
quadraticCurveTo(cpx, cpy, x, y) {
|
|
282
|
+
this._context.quadraticCurveTo(cpx, cpy, x, y);
|
|
283
283
|
}
|
|
284
284
|
restore() {
|
|
285
285
|
this._context.restore();
|
|
286
286
|
}
|
|
287
|
-
rotate(
|
|
288
|
-
this._context.rotate(
|
|
287
|
+
rotate(angle) {
|
|
288
|
+
this._context.rotate(angle);
|
|
289
289
|
}
|
|
290
290
|
save() {
|
|
291
291
|
this._context.save();
|
|
292
292
|
}
|
|
293
|
-
scale(
|
|
294
|
-
this._context.scale(
|
|
293
|
+
scale(x, y) {
|
|
294
|
+
this._context.scale(x, y);
|
|
295
295
|
}
|
|
296
|
-
setLineDash(
|
|
296
|
+
setLineDash(segments) {
|
|
297
297
|
if (this._context.setLineDash) {
|
|
298
|
-
this._context.setLineDash(
|
|
298
|
+
this._context.setLineDash(segments);
|
|
299
299
|
}
|
|
300
300
|
else if ('mozDash' in this._context) {
|
|
301
|
-
this._context['mozDash'] =
|
|
301
|
+
this._context['mozDash'] = segments;
|
|
302
302
|
}
|
|
303
303
|
else if ('webkitLineDash' in this._context) {
|
|
304
|
-
this._context['webkitLineDash'] =
|
|
304
|
+
this._context['webkitLineDash'] = segments;
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
getLineDash() {
|
|
308
308
|
return this._context.getLineDash();
|
|
309
309
|
}
|
|
310
|
-
setTransform(
|
|
311
|
-
this._context.setTransform(
|
|
310
|
+
setTransform(a, b, c, d, e, f) {
|
|
311
|
+
this._context.setTransform(a, b, c, d, e, f);
|
|
312
312
|
}
|
|
313
313
|
stroke(path2d) {
|
|
314
314
|
if (path2d) {
|
|
@@ -318,14 +318,14 @@ class Context {
|
|
|
318
318
|
this._context.stroke();
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
strokeText(
|
|
322
|
-
this._context.strokeText(
|
|
321
|
+
strokeText(text, x, y, maxWidth) {
|
|
322
|
+
this._context.strokeText(text, x, y, maxWidth);
|
|
323
323
|
}
|
|
324
|
-
transform(
|
|
325
|
-
this._context.transform(
|
|
324
|
+
transform(a, b, c, d, e, f) {
|
|
325
|
+
this._context.transform(a, b, c, d, e, f);
|
|
326
326
|
}
|
|
327
|
-
translate(
|
|
328
|
-
this._context.translate(
|
|
327
|
+
translate(x, y) {
|
|
328
|
+
this._context.translate(x, y);
|
|
329
329
|
}
|
|
330
330
|
_enableTrace() {
|
|
331
331
|
var that = this, len = CONTEXT_METHODS.length, origSetter = this.setAttr, n, args;
|
package/lib/DragAndDrop.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { Vector2d } from './types.js';
|
|
|
3
3
|
export declare const DD: {
|
|
4
4
|
readonly isDragging: boolean;
|
|
5
5
|
justDragged: boolean;
|
|
6
|
-
readonly node: Node<import("./Node.js").NodeConfig
|
|
6
|
+
readonly node: Node<import("./Node.js").NodeConfig> | undefined;
|
|
7
7
|
_dragElements: Map<number, {
|
|
8
8
|
node: Node;
|
|
9
9
|
startPointerPos: Vector2d;
|
|
10
10
|
offset: Vector2d;
|
|
11
|
-
pointerId?: number;
|
|
11
|
+
pointerId?: number | undefined;
|
|
12
12
|
dragStatus: 'ready' | 'dragging' | 'stopped';
|
|
13
13
|
}>;
|
|
14
14
|
_drag(evt: any): void;
|
package/lib/Factory.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Node } from './Node.js';
|
|
1
2
|
export declare const Factory: {
|
|
2
3
|
addGetterSetter(constructor: any, attr: any, def?: any, validator?: any, after?: any): void;
|
|
3
4
|
addGetter(constructor: any, attr: any, def?: any): void;
|
|
@@ -7,5 +8,5 @@ export declare const Factory: {
|
|
|
7
8
|
addOverloadedGetterSetter(constructor: any, attr: any): void;
|
|
8
9
|
addDeprecatedGetterSetter(constructor: any, attr: any, def: any, validator: any): void;
|
|
9
10
|
backCompat(constructor: any, methods: any): void;
|
|
10
|
-
afterSetFilter(): void;
|
|
11
|
+
afterSetFilter(this: Node): void;
|
|
11
12
|
};
|
package/lib/Global.d.ts
CHANGED
|
@@ -17,9 +17,9 @@ export declare const Konva: {
|
|
|
17
17
|
_mouseInDblClickWindow: boolean;
|
|
18
18
|
_touchInDblClickWindow: boolean;
|
|
19
19
|
_pointerInDblClickWindow: boolean;
|
|
20
|
-
_mouseDblClickPointerId:
|
|
21
|
-
_touchDblClickPointerId:
|
|
22
|
-
_pointerDblClickPointerId:
|
|
20
|
+
_mouseDblClickPointerId: null;
|
|
21
|
+
_touchDblClickPointerId: null;
|
|
22
|
+
_pointerDblClickPointerId: null;
|
|
23
23
|
pixelRatio: number;
|
|
24
24
|
dragDistance: number;
|
|
25
25
|
angleDeg: boolean;
|
package/lib/Global.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._registerNode = exports.Konva = exports.glob = void 0;
|
|
4
|
-
|
|
4
|
+
const PI_OVER_180 = Math.PI / 180;
|
|
5
5
|
function detectBrowser() {
|
|
6
6
|
return (typeof window !== 'undefined' &&
|
|
7
7
|
({}.toString.call(window) === '[object Window]' ||
|
|
@@ -16,7 +16,7 @@ exports.glob = typeof global !== 'undefined'
|
|
|
16
16
|
: {};
|
|
17
17
|
exports.Konva = {
|
|
18
18
|
_global: exports.glob,
|
|
19
|
-
version: '9.2.
|
|
19
|
+
version: '9.2.1',
|
|
20
20
|
isBrowser: detectBrowser(),
|
|
21
21
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
22
22
|
dblClickWindow: 400,
|
package/lib/Layer.d.ts
CHANGED
|
@@ -34,15 +34,15 @@ export declare class Layer extends Container<Group | Shape> {
|
|
|
34
34
|
height: any;
|
|
35
35
|
}): this;
|
|
36
36
|
_validateAdd(child: any): void;
|
|
37
|
-
_toKonvaCanvas(config: any):
|
|
37
|
+
_toKonvaCanvas(config: any): SceneCanvas;
|
|
38
38
|
_checkVisibility(): void;
|
|
39
39
|
_setSmoothEnabled(): void;
|
|
40
|
-
getWidth(): number;
|
|
40
|
+
getWidth(): number | undefined;
|
|
41
41
|
setWidth(): void;
|
|
42
|
-
getHeight(): number;
|
|
42
|
+
getHeight(): number | undefined;
|
|
43
43
|
setHeight(): void;
|
|
44
44
|
batchDraw(): this;
|
|
45
|
-
getIntersection(pos: Vector2d): Shape<import("./Shape.js").ShapeConfig
|
|
45
|
+
getIntersection(pos: Vector2d): Shape<import("./Shape.js").ShapeConfig> | null;
|
|
46
46
|
_getIntersection(pos: Vector2d): {
|
|
47
47
|
shape?: Shape;
|
|
48
48
|
antialiased?: boolean;
|
package/lib/Node.d.ts
CHANGED
|
@@ -58,10 +58,10 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
58
58
|
attrs: any;
|
|
59
59
|
index: number;
|
|
60
60
|
_allEventListeners: null | Array<Function>;
|
|
61
|
-
parent: Container
|
|
61
|
+
parent: Container | null;
|
|
62
62
|
_cache: Map<string, any>;
|
|
63
63
|
_attachedDepsListeners: Map<string, boolean>;
|
|
64
|
-
_lastPos: Vector2d;
|
|
64
|
+
_lastPos: Vector2d | null;
|
|
65
65
|
_attrsAffectingSize: string[];
|
|
66
66
|
_batchingTransformChange: boolean;
|
|
67
67
|
_needClearTransformCache: boolean;
|
|
@@ -89,7 +89,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
89
89
|
pixelRatio?: number;
|
|
90
90
|
imageSmoothingEnabled?: boolean;
|
|
91
91
|
hitCanvasPixelRatio?: number;
|
|
92
|
-
}): this;
|
|
92
|
+
}): this | undefined;
|
|
93
93
|
isCached(): boolean;
|
|
94
94
|
abstract drawScene(canvas?: Canvas, top?: Node): void;
|
|
95
95
|
abstract drawHit(canvas?: Canvas, top?: Node): void;
|
|
@@ -97,14 +97,14 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
97
97
|
skipTransform?: boolean;
|
|
98
98
|
skipShadow?: boolean;
|
|
99
99
|
skipStroke?: boolean;
|
|
100
|
-
relativeTo?: Container
|
|
100
|
+
relativeTo?: Container;
|
|
101
101
|
}): {
|
|
102
102
|
x: number;
|
|
103
103
|
y: number;
|
|
104
104
|
width: number;
|
|
105
105
|
height: number;
|
|
106
106
|
};
|
|
107
|
-
_transformedRect(rect: IRect, top
|
|
107
|
+
_transformedRect(rect: IRect, top?: Node | null): {
|
|
108
108
|
x: number;
|
|
109
109
|
y: number;
|
|
110
110
|
width: number;
|
|
@@ -113,7 +113,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
113
113
|
_drawCachedSceneCanvas(context: Context): void;
|
|
114
114
|
_drawCachedHitCanvas(context: Context): void;
|
|
115
115
|
_getCachedSceneCanvas(): any;
|
|
116
|
-
on<K extends keyof NodeEventMap>(evtStr: K, handler: KonvaEventListener<this, NodeEventMap[K]>):
|
|
116
|
+
on<K extends keyof NodeEventMap>(evtStr: K, handler: KonvaEventListener<this, NodeEventMap[K]>): void | this;
|
|
117
117
|
off(evtStr?: string, callback?: Function): this;
|
|
118
118
|
dispatchEvent(evt: any): this;
|
|
119
119
|
addEventListener(type: string, handler: (e: Event) => void): this;
|
|
@@ -131,7 +131,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
131
131
|
_isListening(relativeTo?: Node): boolean;
|
|
132
132
|
isVisible(): any;
|
|
133
133
|
_isVisible(relativeTo?: Node): boolean;
|
|
134
|
-
shouldDrawHit(top?: Node, skipDragCheck?: boolean):
|
|
134
|
+
shouldDrawHit(top?: Node, skipDragCheck?: boolean): any;
|
|
135
135
|
show(): this;
|
|
136
136
|
hide(): this;
|
|
137
137
|
getZIndex(): number;
|
|
@@ -146,7 +146,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
146
146
|
getRelativePointerPosition(): {
|
|
147
147
|
x: number;
|
|
148
148
|
y: number;
|
|
149
|
-
};
|
|
149
|
+
} | null;
|
|
150
150
|
getAbsolutePosition(top?: Node): {
|
|
151
151
|
x: number;
|
|
152
152
|
y: number;
|
|
@@ -177,16 +177,16 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
177
177
|
moveTo(newContainer: any): this;
|
|
178
178
|
toObject(): any;
|
|
179
179
|
toJSON(): string;
|
|
180
|
-
getParent(): Container<Node<NodeConfig
|
|
181
|
-
findAncestors(selector: string, includeSelf?: boolean, stopNode?: Node): Node<NodeConfig>[];
|
|
180
|
+
getParent(): Container<Node<NodeConfig>> | null;
|
|
181
|
+
findAncestors(selector: string | Function, includeSelf?: boolean, stopNode?: Node): Node<NodeConfig>[];
|
|
182
182
|
isAncestorOf(node: Node): boolean;
|
|
183
|
-
findAncestor(selector
|
|
183
|
+
findAncestor(selector: string | Function, includeSelf?: boolean, stopNode?: Container): Node<NodeConfig>;
|
|
184
184
|
_isMatch(selector: string | Function): any;
|
|
185
185
|
getLayer(): Layer | null;
|
|
186
186
|
getStage(): Stage | null;
|
|
187
|
-
_getStage(): Stage |
|
|
187
|
+
_getStage(): Stage | null;
|
|
188
188
|
fire(eventType: string, evt?: any, bubble?: boolean): this;
|
|
189
|
-
getAbsoluteTransform(top?: Node): Transform;
|
|
189
|
+
getAbsoluteTransform(top?: Node | null): Transform;
|
|
190
190
|
_getAbsoluteTransform(top?: Node): Transform;
|
|
191
191
|
getAbsoluteScale(top?: Node): {
|
|
192
192
|
x: number;
|
|
@@ -226,7 +226,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
226
226
|
pixelRatio?: number;
|
|
227
227
|
mimeType?: string;
|
|
228
228
|
quality?: number;
|
|
229
|
-
callback?: (blob: Blob) => void;
|
|
229
|
+
callback?: (blob: Blob | null) => void;
|
|
230
230
|
}): Promise<unknown>;
|
|
231
231
|
setSize(size: any): this;
|
|
232
232
|
getSize(): {
|
|
@@ -280,7 +280,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
280
280
|
saturation: GetSet<number, this>;
|
|
281
281
|
threshold: GetSet<number, this>;
|
|
282
282
|
value: GetSet<number, this>;
|
|
283
|
-
dragBoundFunc: GetSet<(this: Node, pos: Vector2d) => Vector2d, this>;
|
|
283
|
+
dragBoundFunc: GetSet<(this: Node, pos: Vector2d, event: any) => Vector2d, this>;
|
|
284
284
|
draggable: GetSet<boolean, this>;
|
|
285
285
|
dragDistance: GetSet<number, this>;
|
|
286
286
|
embossBlend: GetSet<boolean, this>;
|