konva 9.1.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 +273 -682
- package/konva.min.js +3 -3
- package/lib/Animation.d.ts +4 -4
- package/lib/Animation.js +27 -26
- package/lib/Container.d.ts +9 -7
- package/lib/Container.js +5 -5
- package/lib/Context.d.ts +29 -27
- package/lib/Context.js +55 -60
- 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 +9 -7
- package/lib/Shape.js +17 -5
- 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 +11 -11
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>;
|
package/lib/Node.js
CHANGED
|
@@ -103,7 +103,7 @@ class Node {
|
|
|
103
103
|
conf.height === undefined) {
|
|
104
104
|
rect = this.getClientRect({
|
|
105
105
|
skipTransform: true,
|
|
106
|
-
relativeTo: this.getParent(),
|
|
106
|
+
relativeTo: this.getParent() || undefined,
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
|
|
@@ -182,7 +182,7 @@ class Node {
|
|
|
182
182
|
{ x: rect.x + rect.width, y: rect.y + rect.height },
|
|
183
183
|
{ x: rect.x, y: rect.y + rect.height },
|
|
184
184
|
];
|
|
185
|
-
var minX, minY, maxX, maxY;
|
|
185
|
+
var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
186
186
|
var trans = this.getAbsoluteTransform(top);
|
|
187
187
|
points.forEach(function (point) {
|
|
188
188
|
var transformed = trans.point(point);
|
|
@@ -482,8 +482,9 @@ class Node {
|
|
|
482
482
|
addChildren(nodes);
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
|
|
486
|
-
|
|
485
|
+
const stage = this.getStage();
|
|
486
|
+
if (that.nodeType !== UPPER_STAGE && stage) {
|
|
487
|
+
addChildren(stage.getChildren());
|
|
487
488
|
}
|
|
488
489
|
return index;
|
|
489
490
|
}
|
|
@@ -519,10 +520,11 @@ class Node {
|
|
|
519
520
|
};
|
|
520
521
|
}
|
|
521
522
|
getRelativePointerPosition() {
|
|
522
|
-
|
|
523
|
+
const stage = this.getStage();
|
|
524
|
+
if (!stage) {
|
|
523
525
|
return null;
|
|
524
526
|
}
|
|
525
|
-
var pos =
|
|
527
|
+
var pos = stage.getPointerPosition();
|
|
526
528
|
if (!pos) {
|
|
527
529
|
return null;
|
|
528
530
|
}
|
|
@@ -549,11 +551,9 @@ class Node {
|
|
|
549
551
|
return absoluteTransform.getTranslation();
|
|
550
552
|
}
|
|
551
553
|
setAbsolutePosition(pos) {
|
|
552
|
-
|
|
553
|
-
this.attrs.x =
|
|
554
|
-
this.attrs.y =
|
|
555
|
-
delete origTrans.x;
|
|
556
|
-
delete origTrans.y;
|
|
554
|
+
const { x, y, ...origTrans } = this._clearTransform();
|
|
555
|
+
this.attrs.x = x;
|
|
556
|
+
this.attrs.y = y;
|
|
557
557
|
this._clearCache(TRANSFORM);
|
|
558
558
|
var it = this._getAbsoluteTransform().copy();
|
|
559
559
|
it.invert();
|
|
@@ -815,7 +815,7 @@ class Node {
|
|
|
815
815
|
return parent.getStage();
|
|
816
816
|
}
|
|
817
817
|
else {
|
|
818
|
-
return
|
|
818
|
+
return null;
|
|
819
819
|
}
|
|
820
820
|
}
|
|
821
821
|
fire(eventType, evt = {}, bubble) {
|
|
@@ -1198,6 +1198,9 @@ class Node {
|
|
|
1198
1198
|
var pointerId = evt ? evt.pointerId : undefined;
|
|
1199
1199
|
var stage = this.getStage();
|
|
1200
1200
|
var ap = this.getAbsolutePosition();
|
|
1201
|
+
if (!stage) {
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1201
1204
|
var pos = stage._getPointerById(pointerId) ||
|
|
1202
1205
|
stage._changedPointerPositions[0] ||
|
|
1203
1206
|
ap;
|
package/lib/PointerEvents.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Stage } from './Stage.js';
|
|
|
4
4
|
export interface KonvaPointerEvent extends KonvaEventObject<PointerEvent> {
|
|
5
5
|
pointerId: number;
|
|
6
6
|
}
|
|
7
|
-
export declare function getCapturedShape(pointerId: number): Shape<import("./Shape.js").ShapeConfig> |
|
|
7
|
+
export declare function getCapturedShape(pointerId: number): Stage | Shape<import("./Shape.js").ShapeConfig> | undefined;
|
|
8
8
|
export declare function createEvent(evt: PointerEvent): KonvaPointerEvent;
|
|
9
9
|
export declare function hasPointerCapture(pointerId: number, shape: Shape | Stage): boolean;
|
|
10
10
|
export declare function setPointerCapture(pointerId: number, shape: Shape | Stage): void;
|
package/lib/Shape.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export interface ShapeConfig extends NodeConfig {
|
|
|
38
38
|
fillRadialGradientColorStops?: Array<number | string>;
|
|
39
39
|
fillEnabled?: boolean;
|
|
40
40
|
fillPriority?: string;
|
|
41
|
+
fillRule?: CanvasFillRule;
|
|
41
42
|
stroke?: string | CanvasGradient;
|
|
42
43
|
strokeWidth?: number;
|
|
43
44
|
fillAfterStrokeEnabled?: boolean;
|
|
@@ -68,13 +69,14 @@ export interface ShapeGetClientRectConfig {
|
|
|
68
69
|
skipStroke?: boolean;
|
|
69
70
|
relativeTo?: Node;
|
|
70
71
|
}
|
|
72
|
+
export type FillFuncOutput = void | [Path2D | CanvasFillRule] | [Path2D, CanvasFillRule];
|
|
71
73
|
export declare const shapes: {
|
|
72
74
|
[key: string]: Shape;
|
|
73
75
|
};
|
|
74
76
|
export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<Config> {
|
|
75
77
|
_centroid: boolean;
|
|
76
78
|
colorKey: string;
|
|
77
|
-
_fillFunc: (ctx: Context) =>
|
|
79
|
+
_fillFunc: (ctx: Context) => FillFuncOutput;
|
|
78
80
|
_strokeFunc: (ctx: Context) => void;
|
|
79
81
|
_fillFuncHit: (ctx: Context) => void;
|
|
80
82
|
_strokeFuncHit: (ctx: Context) => void;
|
|
@@ -86,13 +88,13 @@ export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Nod
|
|
|
86
88
|
hasShadow(): any;
|
|
87
89
|
_hasShadow(): boolean;
|
|
88
90
|
_getFillPattern(): any;
|
|
89
|
-
__getFillPattern(): CanvasPattern;
|
|
91
|
+
__getFillPattern(): CanvasPattern | null | undefined;
|
|
90
92
|
_getLinearGradient(): any;
|
|
91
|
-
__getLinearGradient(): CanvasGradient;
|
|
93
|
+
__getLinearGradient(): CanvasGradient | undefined;
|
|
92
94
|
_getRadialGradient(): any;
|
|
93
|
-
__getRadialGradient(): CanvasGradient;
|
|
95
|
+
__getRadialGradient(): CanvasGradient | undefined;
|
|
94
96
|
getShadowRGBA(): any;
|
|
95
|
-
_getShadowRGBA(): string;
|
|
97
|
+
_getShadowRGBA(): string | undefined;
|
|
96
98
|
hasFill(): any;
|
|
97
99
|
hasStroke(): any;
|
|
98
100
|
hasHitStroke(): any;
|
|
@@ -108,8 +110,8 @@ export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Nod
|
|
|
108
110
|
height: number;
|
|
109
111
|
};
|
|
110
112
|
getClientRect(config?: ShapeGetClientRectConfig): {
|
|
111
|
-
width:
|
|
112
|
-
height:
|
|
113
|
+
width: any;
|
|
114
|
+
height: any;
|
|
113
115
|
x: number;
|
|
114
116
|
y: number;
|
|
115
117
|
};
|
package/lib/Shape.js
CHANGED
|
@@ -23,7 +23,13 @@ function getDummyContext() {
|
|
|
23
23
|
}
|
|
24
24
|
exports.shapes = {};
|
|
25
25
|
function _fillFunc(context) {
|
|
26
|
-
|
|
26
|
+
const fillRule = this.attrs.fillRule;
|
|
27
|
+
if (fillRule) {
|
|
28
|
+
context.fill(fillRule);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
context.fill();
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
34
|
function _strokeFunc(context) {
|
|
29
35
|
context.stroke();
|
|
@@ -203,10 +209,14 @@ class Shape extends Node_1.Node {
|
|
|
203
209
|
return this.strokeEnabled() && !!width;
|
|
204
210
|
}
|
|
205
211
|
intersects(point) {
|
|
206
|
-
var stage = this.getStage()
|
|
212
|
+
var stage = this.getStage();
|
|
213
|
+
if (!stage) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
const bufferHitCanvas = stage.bufferHitCanvas;
|
|
207
217
|
bufferHitCanvas.getContext().clear();
|
|
208
|
-
this.drawHit(bufferHitCanvas,
|
|
209
|
-
p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;
|
|
218
|
+
this.drawHit(bufferHitCanvas, undefined, true);
|
|
219
|
+
const p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;
|
|
210
220
|
return p[3] > 0;
|
|
211
221
|
}
|
|
212
222
|
destroy() {
|
|
@@ -295,7 +305,8 @@ class Shape extends Node_1.Node {
|
|
|
295
305
|
return rect;
|
|
296
306
|
}
|
|
297
307
|
drawScene(can, top) {
|
|
298
|
-
var layer = this.getLayer()
|
|
308
|
+
var layer = this.getLayer();
|
|
309
|
+
var canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferCanvas, bufferContext;
|
|
299
310
|
var skipBuffer = canvas.isCache;
|
|
300
311
|
var cachingSelf = top === this;
|
|
301
312
|
if (!this.isVisible() && !cachingSelf) {
|
|
@@ -508,6 +519,7 @@ Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint',
|
|
|
508
519
|
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);
|
|
509
520
|
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);
|
|
510
521
|
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);
|
|
522
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillRule', undefined, (0, Validators_1.getStringValidator)());
|
|
511
523
|
Factory_1.Factory.backCompat(Shape, {
|
|
512
524
|
dashArray: 'dash',
|
|
513
525
|
getDashArray: 'getDash',
|
package/lib/Stage.d.ts
CHANGED
|
@@ -36,31 +36,31 @@ export declare class Stage extends Container<Layer> {
|
|
|
36
36
|
setContainer(container: any): this;
|
|
37
37
|
shouldDrawHit(): boolean;
|
|
38
38
|
clear(): this;
|
|
39
|
-
clone(obj?: any):
|
|
39
|
+
clone(obj?: any): this;
|
|
40
40
|
destroy(): this;
|
|
41
41
|
getPointerPosition(): Vector2d | null;
|
|
42
|
-
_getPointerById(id?: number): Vector2d & {
|
|
43
|
-
id?: number;
|
|
44
|
-
};
|
|
42
|
+
_getPointerById(id?: number): (Vector2d & {
|
|
43
|
+
id?: number | undefined;
|
|
44
|
+
}) | undefined;
|
|
45
45
|
getPointersPositions(): (Vector2d & {
|
|
46
|
-
id?: number;
|
|
46
|
+
id?: number | undefined;
|
|
47
47
|
})[];
|
|
48
48
|
getStage(): this;
|
|
49
49
|
getContent(): HTMLDivElement;
|
|
50
50
|
_toKonvaCanvas(config: any): SceneCanvas;
|
|
51
|
-
getIntersection(pos: Vector2d): Shape<import("./Shape.js").ShapeConfig
|
|
51
|
+
getIntersection(pos: Vector2d): Shape<import("./Shape.js").ShapeConfig> | null;
|
|
52
52
|
_resizeDOM(): void;
|
|
53
53
|
add(layer: Layer, ...rest: any[]): this;
|
|
54
|
-
getParent():
|
|
55
|
-
getLayer():
|
|
54
|
+
getParent(): null;
|
|
55
|
+
getLayer(): null;
|
|
56
56
|
hasPointerCapture(pointerId: number): boolean;
|
|
57
57
|
setPointerCapture(pointerId: number): void;
|
|
58
58
|
releaseCapture(pointerId: number): void;
|
|
59
59
|
getLayers(): Layer[];
|
|
60
60
|
_bindContentEvents(): void;
|
|
61
|
-
_pointerenter(evt:
|
|
61
|
+
_pointerenter(evt: PointerEvent): void;
|
|
62
62
|
_pointerover(evt: any): void;
|
|
63
|
-
_getTargetShape(evenType: any): Shape<import("./Shape.js").ShapeConfig
|
|
63
|
+
_getTargetShape(evenType: any): Shape<import("./Shape.js").ShapeConfig> | null;
|
|
64
64
|
_pointerleave(evt: any): void;
|
|
65
65
|
_pointerdown(evt: TouchEvent | MouseEvent | PointerEvent): void;
|
|
66
66
|
_pointermove(evt: TouchEvent | MouseEvent | PointerEvent): void;
|
package/lib/Stage.js
CHANGED
|
@@ -312,20 +312,24 @@ class Stage extends Container_1.Container {
|
|
|
312
312
|
_pointerenter(evt) {
|
|
313
313
|
this.setPointersPositions(evt);
|
|
314
314
|
const events = getEventsMap(evt.type);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
315
|
+
if (events) {
|
|
316
|
+
this._fire(events.pointerenter, {
|
|
317
|
+
evt: evt,
|
|
318
|
+
target: this,
|
|
319
|
+
currentTarget: this,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
320
322
|
}
|
|
321
323
|
_pointerover(evt) {
|
|
322
324
|
this.setPointersPositions(evt);
|
|
323
325
|
const events = getEventsMap(evt.type);
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
326
|
+
if (events) {
|
|
327
|
+
this._fire(events.pointerover, {
|
|
328
|
+
evt: evt,
|
|
329
|
+
target: this,
|
|
330
|
+
currentTarget: this,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
329
333
|
}
|
|
330
334
|
_getTargetShape(evenType) {
|
|
331
335
|
let shape = this[evenType + 'targetShape'];
|
|
@@ -365,7 +369,7 @@ class Stage extends Container_1.Container {
|
|
|
365
369
|
currentTarget: this,
|
|
366
370
|
});
|
|
367
371
|
}
|
|
368
|
-
this.pointerPos =
|
|
372
|
+
this.pointerPos = null;
|
|
369
373
|
this._pointerPositions = [];
|
|
370
374
|
}
|
|
371
375
|
_pointerdown(evt) {
|
|
@@ -380,8 +384,7 @@ class Stage extends Container_1.Container {
|
|
|
380
384
|
var shape = this.getIntersection(pos);
|
|
381
385
|
DragAndDrop_1.DD.justDragged = false;
|
|
382
386
|
Global_1.Konva['_' + eventType + 'ListenClick'] = true;
|
|
383
|
-
|
|
384
|
-
if (!hasShape) {
|
|
387
|
+
if (!shape || !shape.isListening()) {
|
|
385
388
|
return;
|
|
386
389
|
}
|
|
387
390
|
if (Global_1.Konva.capturePointerEventsEnabled) {
|
|
@@ -431,8 +434,8 @@ class Stage extends Container_1.Container {
|
|
|
431
434
|
const event = { evt: evt, pointerId };
|
|
432
435
|
var differentTarget = targetShape !== shape;
|
|
433
436
|
if (differentTarget && targetShape) {
|
|
434
|
-
targetShape._fireAndBubble(events.pointerout,
|
|
435
|
-
targetShape._fireAndBubble(events.pointerleave,
|
|
437
|
+
targetShape._fireAndBubble(events.pointerout, { ...event }, shape);
|
|
438
|
+
targetShape._fireAndBubble(events.pointerleave, { ...event }, shape);
|
|
436
439
|
}
|
|
437
440
|
if (shape) {
|
|
438
441
|
if (processedShapesIds[shape._id]) {
|
|
@@ -443,11 +446,11 @@ class Stage extends Container_1.Container {
|
|
|
443
446
|
if (shape && shape.isListening()) {
|
|
444
447
|
triggeredOnShape = true;
|
|
445
448
|
if (differentTarget) {
|
|
446
|
-
shape._fireAndBubble(events.pointerover,
|
|
447
|
-
shape._fireAndBubble(events.pointerenter,
|
|
449
|
+
shape._fireAndBubble(events.pointerover, { ...event }, targetShape);
|
|
450
|
+
shape._fireAndBubble(events.pointerenter, { ...event }, targetShape);
|
|
448
451
|
this[eventType + 'targetShape'] = shape;
|
|
449
452
|
}
|
|
450
|
-
shape._fireAndBubble(events.pointermove,
|
|
453
|
+
shape._fireAndBubble(events.pointermove, { ...event });
|
|
451
454
|
}
|
|
452
455
|
else {
|
|
453
456
|
if (targetShape) {
|
|
@@ -508,13 +511,13 @@ class Stage extends Container_1.Container {
|
|
|
508
511
|
if (shape && shape.isListening()) {
|
|
509
512
|
triggeredOnShape = true;
|
|
510
513
|
this[eventType + 'ClickEndShape'] = shape;
|
|
511
|
-
shape._fireAndBubble(events.pointerup,
|
|
514
|
+
shape._fireAndBubble(events.pointerup, { ...event });
|
|
512
515
|
if (Global_1.Konva['_' + eventType + 'ListenClick'] &&
|
|
513
516
|
clickStartShape &&
|
|
514
517
|
clickStartShape === shape) {
|
|
515
|
-
shape._fireAndBubble(events.pointerclick,
|
|
518
|
+
shape._fireAndBubble(events.pointerclick, { ...event });
|
|
516
519
|
if (fireDblClick && clickEndShape && clickEndShape === shape) {
|
|
517
|
-
shape._fireAndBubble(events.pointerdblclick,
|
|
520
|
+
shape._fireAndBubble(events.pointerdblclick, { ...event });
|
|
518
521
|
}
|
|
519
522
|
}
|
|
520
523
|
}
|
package/lib/Tween.d.ts
CHANGED
|
@@ -50,9 +50,9 @@ export declare class Tween {
|
|
|
50
50
|
anim: Animation;
|
|
51
51
|
tween: TweenEngine;
|
|
52
52
|
_id: number;
|
|
53
|
-
onFinish: Function;
|
|
54
|
-
onReset: Function;
|
|
55
|
-
onUpdate: Function;
|
|
53
|
+
onFinish: Function | undefined;
|
|
54
|
+
onReset: Function | undefined;
|
|
55
|
+
onUpdate: Function | undefined;
|
|
56
56
|
constructor(config: TweenConfig);
|
|
57
57
|
_addAttr(key: any, end: any): void;
|
|
58
58
|
_tweenFunc(i: any): void;
|
package/lib/Util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from './Context.js';
|
|
2
|
-
import { IRect, RGB,
|
|
2
|
+
import { IRect, RGB, Vector2d } from './types.js';
|
|
3
3
|
export declare class Transform {
|
|
4
4
|
m: Array<number>;
|
|
5
5
|
dirty: boolean;
|
|
@@ -52,20 +52,60 @@ export declare const Util: {
|
|
|
52
52
|
_hexToRgb(hex: string): RGB;
|
|
53
53
|
getRandomColor(): string;
|
|
54
54
|
getRGB(color: string): RGB;
|
|
55
|
-
colorToRGBA(str: string):
|
|
55
|
+
colorToRGBA(str: string): {
|
|
56
|
+
r: number;
|
|
57
|
+
g: number;
|
|
58
|
+
b: number;
|
|
59
|
+
a: number;
|
|
60
|
+
} | undefined;
|
|
56
61
|
_namedColorToRBA(str: string): {
|
|
57
|
-
r:
|
|
58
|
-
g:
|
|
59
|
-
b:
|
|
62
|
+
r: number;
|
|
63
|
+
g: number;
|
|
64
|
+
b: number;
|
|
60
65
|
a: number;
|
|
61
|
-
};
|
|
62
|
-
_rgbColorToRGBA(str: string):
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
} | null;
|
|
67
|
+
_rgbColorToRGBA(str: string): {
|
|
68
|
+
r: number;
|
|
69
|
+
g: number;
|
|
70
|
+
b: number;
|
|
71
|
+
a: number;
|
|
72
|
+
} | undefined;
|
|
73
|
+
_rgbaColorToRGBA(str: string): {
|
|
74
|
+
r: number;
|
|
75
|
+
g: number;
|
|
76
|
+
b: number;
|
|
77
|
+
a: number;
|
|
78
|
+
} | undefined;
|
|
79
|
+
_hex8ColorToRGBA(str: string): {
|
|
80
|
+
r: number;
|
|
81
|
+
g: number;
|
|
82
|
+
b: number;
|
|
83
|
+
a: number;
|
|
84
|
+
} | undefined;
|
|
85
|
+
_hex6ColorToRGBA(str: string): {
|
|
86
|
+
r: number;
|
|
87
|
+
g: number;
|
|
88
|
+
b: number;
|
|
89
|
+
a: number;
|
|
90
|
+
} | undefined;
|
|
91
|
+
_hex4ColorToRGBA(str: string): {
|
|
92
|
+
r: number;
|
|
93
|
+
g: number;
|
|
94
|
+
b: number;
|
|
95
|
+
a: number;
|
|
96
|
+
} | undefined;
|
|
97
|
+
_hex3ColorToRGBA(str: string): {
|
|
98
|
+
r: number;
|
|
99
|
+
g: number;
|
|
100
|
+
b: number;
|
|
101
|
+
a: number;
|
|
102
|
+
} | undefined;
|
|
103
|
+
_hslColorToRGBA(str: string): {
|
|
104
|
+
r: number;
|
|
105
|
+
g: number;
|
|
106
|
+
b: number;
|
|
107
|
+
a: number;
|
|
108
|
+
} | undefined;
|
|
69
109
|
haveIntersection(r1: IRect, r2: IRect): boolean;
|
|
70
110
|
cloneObject<Any>(obj: Any): Any;
|
|
71
111
|
cloneArray(arr: Array<any>): any[];
|
|
@@ -73,16 +113,16 @@ export declare const Util: {
|
|
|
73
113
|
radToDeg(rad: number): number;
|
|
74
114
|
_degToRad(deg: number): number;
|
|
75
115
|
_radToDeg(rad: number): number;
|
|
76
|
-
_getRotation(radians:
|
|
116
|
+
_getRotation(radians: number): number;
|
|
77
117
|
_capitalize(str: string): string;
|
|
78
118
|
throw(str: string): never;
|
|
79
119
|
error(str: string): void;
|
|
80
120
|
warn(str: string): void;
|
|
81
|
-
each(obj:
|
|
82
|
-
_inRange(val:
|
|
121
|
+
each(obj: Object, func: Function): void;
|
|
122
|
+
_inRange(val: number, left: number, right: number): boolean;
|
|
83
123
|
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
|
|
84
|
-
_getProjectionToLine(pt: Vector2d, line:
|
|
85
|
-
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any):
|
|
124
|
+
_getProjectionToLine(pt: Vector2d, line: Array<Vector2d>, isClosed: boolean): Vector2d;
|
|
125
|
+
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
|
|
86
126
|
_prepareToStringify(obj: any): any;
|
|
87
127
|
_assign<T, U>(target: T, source: U): T & U;
|
|
88
128
|
_getFirstPointerId(evt: any): any;
|
package/lib/Util.js
CHANGED
|
@@ -769,7 +769,7 @@ exports.Util = {
|
|
|
769
769
|
releaseCanvas(...canvases) {
|
|
770
770
|
if (!Global_1.Konva.releaseCanvasOnDestroy)
|
|
771
771
|
return;
|
|
772
|
-
canvases.forEach(c => {
|
|
772
|
+
canvases.forEach((c) => {
|
|
773
773
|
c.width = 0;
|
|
774
774
|
c.height = 0;
|
|
775
775
|
});
|
|
@@ -780,7 +780,11 @@ exports.Util = {
|
|
|
780
780
|
let bottomLeft = 0;
|
|
781
781
|
let bottomRight = 0;
|
|
782
782
|
if (typeof cornerRadius === 'number') {
|
|
783
|
-
topLeft =
|
|
783
|
+
topLeft =
|
|
784
|
+
topRight =
|
|
785
|
+
bottomLeft =
|
|
786
|
+
bottomRight =
|
|
787
|
+
Math.min(cornerRadius, width / 2, height / 2);
|
|
784
788
|
}
|
|
785
789
|
else {
|
|
786
790
|
topLeft = Math.min(cornerRadius[0] || 0, width / 2, height / 2);
|
|
@@ -797,5 +801,5 @@ exports.Util = {
|
|
|
797
801
|
context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);
|
|
798
802
|
context.lineTo(0, topLeft);
|
|
799
803
|
context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
|
|
800
|
-
}
|
|
804
|
+
},
|
|
801
805
|
};
|
package/lib/Validators.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare function RGBComponent(val: number): number;
|
|
2
2
|
export declare function alphaComponent(val: number): number;
|
|
3
|
-
export declare function getNumberValidator(): <T>(val: T, attr: string) => void | T;
|
|
4
|
-
export declare function getNumberOrArrayOfNumbersValidator(noOfElements: number): <T>(val: T, attr: string) => void | T;
|
|
5
|
-
export declare function getNumberOrAutoValidator(): <T extends string>(val: T, attr: string) => void | T;
|
|
6
|
-
export declare function getStringValidator(): (val: any, attr: string) => any;
|
|
7
|
-
export declare function getStringOrGradientValidator(): (val: any, attr: string) => any;
|
|
8
|
-
export declare function getFunctionValidator(): (val: any, attr: string) => any;
|
|
9
|
-
export declare function getNumberArrayValidator(): (val: any, attr: string) => any;
|
|
10
|
-
export declare function getBooleanValidator(): (val: any, attr: string) => any;
|
|
11
|
-
export declare function getComponentValidator(components: any): (val: any, attr: string) => any;
|
|
3
|
+
export declare function getNumberValidator(): (<T>(val: T, attr: string) => void | T) | undefined;
|
|
4
|
+
export declare function getNumberOrArrayOfNumbersValidator(noOfElements: number): (<T>(val: T, attr: string) => void | T) | undefined;
|
|
5
|
+
export declare function getNumberOrAutoValidator(): (<T extends string>(val: T, attr: string) => void | T) | undefined;
|
|
6
|
+
export declare function getStringValidator(): ((val: any, attr: string) => any) | undefined;
|
|
7
|
+
export declare function getStringOrGradientValidator(): ((val: any, attr: string) => any) | undefined;
|
|
8
|
+
export declare function getFunctionValidator(): ((val: any, attr: string) => any) | undefined;
|
|
9
|
+
export declare function getNumberArrayValidator(): ((val: any, attr: string) => any) | undefined;
|
|
10
|
+
export declare function getBooleanValidator(): ((val: any, attr: string) => any) | undefined;
|
|
11
|
+
export declare function getComponentValidator(components: any): ((val: any, attr: string) => any) | undefined;
|