konva 9.2.3 → 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 +65 -35
- 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 +17 -8
- 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/index-types.d.ts +9 -9
- package/lib/shapes/Transformer.d.ts +10 -1
- package/lib/shapes/Transformer.js +2 -1
- package/package.json +7 -7
package/lib/Container.d.ts
CHANGED
|
@@ -25,15 +25,19 @@ export declare abstract class Container<ChildType extends Node = Node> extends N
|
|
|
25
25
|
findOne<ChildNode extends Node = Node>(selector: string | Function): ChildNode | undefined;
|
|
26
26
|
_generalFind<ChildNode extends Node>(selector: string | Function, findOne: boolean): ChildNode[];
|
|
27
27
|
private _descendants;
|
|
28
|
-
toObject():
|
|
28
|
+
toObject(): {
|
|
29
|
+
attrs: any;
|
|
30
|
+
className: string;
|
|
31
|
+
children?: any[] | undefined;
|
|
32
|
+
};
|
|
29
33
|
isAncestorOf(node: Node): boolean;
|
|
30
34
|
clone(obj?: any): this;
|
|
31
35
|
getAllIntersections(pos: any): Shape<import("./Shape.js").ShapeConfig>[];
|
|
32
36
|
_clearSelfAndDescendantCache(attr?: string): void;
|
|
33
37
|
_setChildrenIndices(): void;
|
|
34
|
-
drawScene(can?: SceneCanvas, top?: Node): this;
|
|
38
|
+
drawScene(can?: SceneCanvas, top?: Node, bufferCanvas?: SceneCanvas): this;
|
|
35
39
|
drawHit(can?: HitCanvas, top?: Node): this;
|
|
36
|
-
_drawChildren(drawMethod: any, canvas: any, top: any): void;
|
|
40
|
+
_drawChildren(drawMethod: any, canvas: any, top: any, bufferCanvas?: any): void;
|
|
37
41
|
getClientRect(config?: {
|
|
38
42
|
skipTransform?: boolean;
|
|
39
43
|
skipShadow?: boolean;
|
package/lib/Container.js
CHANGED
|
@@ -168,7 +168,7 @@ class Container extends Node_1.Node {
|
|
|
168
168
|
});
|
|
169
169
|
this._requestDraw();
|
|
170
170
|
}
|
|
171
|
-
drawScene(can, top) {
|
|
171
|
+
drawScene(can, top, bufferCanvas) {
|
|
172
172
|
var layer = this.getLayer(), canvas = can || (layer && layer.getCanvas()), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedSceneCanvas = cachedCanvas && cachedCanvas.scene;
|
|
173
173
|
var caching = canvas && canvas.isCache;
|
|
174
174
|
if (!this.isVisible() && !caching) {
|
|
@@ -182,7 +182,7 @@ class Container extends Node_1.Node {
|
|
|
182
182
|
context.restore();
|
|
183
183
|
}
|
|
184
184
|
else {
|
|
185
|
-
this._drawChildren('drawScene', canvas, top);
|
|
185
|
+
this._drawChildren('drawScene', canvas, top, bufferCanvas);
|
|
186
186
|
}
|
|
187
187
|
return this;
|
|
188
188
|
}
|
|
@@ -203,7 +203,7 @@ class Container extends Node_1.Node {
|
|
|
203
203
|
}
|
|
204
204
|
return this;
|
|
205
205
|
}
|
|
206
|
-
_drawChildren(drawMethod, canvas, top) {
|
|
206
|
+
_drawChildren(drawMethod, canvas, top, bufferCanvas) {
|
|
207
207
|
var _a;
|
|
208
208
|
var context = canvas && canvas.getContext(), clipWidth = this.clipWidth(), clipHeight = this.clipHeight(), clipFunc = this.clipFunc(), hasClip = (clipWidth && clipHeight) || clipFunc;
|
|
209
209
|
const selfCache = top === this;
|
|
@@ -234,7 +234,7 @@ class Container extends Node_1.Node {
|
|
|
234
234
|
context._applyGlobalCompositeOperation(this);
|
|
235
235
|
}
|
|
236
236
|
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
|
|
237
|
-
child[drawMethod](canvas, top);
|
|
237
|
+
child[drawMethod](canvas, top, bufferCanvas);
|
|
238
238
|
});
|
|
239
239
|
if (hasComposition) {
|
|
240
240
|
context.restore();
|
package/lib/Context.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare class Context {
|
|
|
51
51
|
lineTo(x: number, y: number): void;
|
|
52
52
|
moveTo(x: number, y: number): void;
|
|
53
53
|
rect(x: number, y: number, width: number, height: number): void;
|
|
54
|
+
roundRect(x: number, y: number, width: number, height: number, radii: number | DOMPointInit | (number | DOMPointInit)[]): void;
|
|
54
55
|
putImageData(imageData: ImageData, dx: number, dy: number): void;
|
|
55
56
|
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
56
57
|
restore(): void;
|
package/lib/Context.js
CHANGED
|
@@ -39,6 +39,7 @@ var COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([',
|
|
|
39
39
|
'putImageData',
|
|
40
40
|
'quadraticCurveTo',
|
|
41
41
|
'rect',
|
|
42
|
+
'roundRect',
|
|
42
43
|
'restore',
|
|
43
44
|
'rotate',
|
|
44
45
|
'save',
|
|
@@ -277,6 +278,9 @@ class Context {
|
|
|
277
278
|
rect(x, y, width, height) {
|
|
278
279
|
this._context.rect(x, y, width, height);
|
|
279
280
|
}
|
|
281
|
+
roundRect(x, y, width, height, radii) {
|
|
282
|
+
this._context.roundRect(x, y, width, height, radii);
|
|
283
|
+
}
|
|
280
284
|
putImageData(imageData, dx, dy) {
|
|
281
285
|
this._context.putImageData(imageData, dx, dy);
|
|
282
286
|
}
|
package/lib/Global.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.glob = typeof global !== 'undefined'
|
|
|
16
16
|
: {};
|
|
17
17
|
exports.Konva = {
|
|
18
18
|
_global: exports.glob,
|
|
19
|
-
version: '9.
|
|
19
|
+
version: '9.3.1',
|
|
20
20
|
isBrowser: detectBrowser(),
|
|
21
21
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
22
22
|
dblClickWindow: 400,
|
package/lib/Node.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface NodeConfig {
|
|
|
21
21
|
opacity?: number;
|
|
22
22
|
scale?: Vector2d;
|
|
23
23
|
scaleX?: number;
|
|
24
|
+
skewX?: number;
|
|
25
|
+
skewY?: number;
|
|
24
26
|
scaleY?: number;
|
|
25
27
|
rotation?: number;
|
|
26
28
|
rotationDeg?: number;
|
|
@@ -91,7 +93,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
91
93
|
hitCanvasPixelRatio?: number;
|
|
92
94
|
}): this | undefined;
|
|
93
95
|
isCached(): boolean;
|
|
94
|
-
abstract drawScene(canvas?: Canvas, top?: Node): void;
|
|
96
|
+
abstract drawScene(canvas?: Canvas, top?: Node, bufferCanvas?: Canvas): void;
|
|
95
97
|
abstract drawHit(canvas?: Canvas, top?: Node): void;
|
|
96
98
|
getClientRect(config?: {
|
|
97
99
|
skipTransform?: boolean;
|
|
@@ -125,7 +127,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
125
127
|
destroy(): this;
|
|
126
128
|
getAttr(attr: string): any;
|
|
127
129
|
getAncestors(): Node<NodeConfig>[];
|
|
128
|
-
getAttrs(): any
|
|
130
|
+
getAttrs(): Config & Record<string, any>;
|
|
129
131
|
setAttrs(config: any): this;
|
|
130
132
|
isListening(): any;
|
|
131
133
|
_isListening(relativeTo?: Node): boolean;
|
|
@@ -175,7 +177,11 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
175
177
|
getAbsoluteOpacity(): any;
|
|
176
178
|
_getAbsoluteOpacity(): number;
|
|
177
179
|
moveTo(newContainer: any): this;
|
|
178
|
-
toObject():
|
|
180
|
+
toObject(): {
|
|
181
|
+
attrs: Config & Record<string, any>;
|
|
182
|
+
className: string;
|
|
183
|
+
children?: any[] | undefined;
|
|
184
|
+
};
|
|
179
185
|
toJSON(): string;
|
|
180
186
|
getParent(): Container<Node<NodeConfig>> | null;
|
|
181
187
|
findAncestors(selector: string | Function, includeSelf?: boolean, stopNode?: Node): Node<NodeConfig>[];
|
package/lib/Node.js
CHANGED
|
@@ -111,8 +111,10 @@ class Node {
|
|
|
111
111
|
Util_1.Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
const extraPaddingX = Math.abs(Math.round(rect.x) - x) > 0.5 ? 1 : 0;
|
|
115
|
+
const extraPaddingY = Math.abs(Math.round(rect.y) - y) > 0.5 ? 1 : 0;
|
|
116
|
+
width += offset * 2 + extraPaddingX;
|
|
117
|
+
height += offset * 2 + extraPaddingY;
|
|
116
118
|
x -= offset;
|
|
117
119
|
y -= offset;
|
|
118
120
|
var cachedSceneCanvas = new Canvas_1.SceneCanvas({
|
|
@@ -377,7 +379,7 @@ class Node {
|
|
|
377
379
|
return ancestors;
|
|
378
380
|
}
|
|
379
381
|
getAttrs() {
|
|
380
|
-
return this.attrs || {};
|
|
382
|
+
return (this.attrs || {});
|
|
381
383
|
}
|
|
382
384
|
setAttrs(config) {
|
|
383
385
|
this._batchTransformChanges(() => {
|
|
@@ -720,8 +722,11 @@ class Node {
|
|
|
720
722
|
return this;
|
|
721
723
|
}
|
|
722
724
|
toObject() {
|
|
723
|
-
var
|
|
724
|
-
obj
|
|
725
|
+
var attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;
|
|
726
|
+
const obj = {
|
|
727
|
+
attrs: {},
|
|
728
|
+
className: this.getClassName(),
|
|
729
|
+
};
|
|
725
730
|
for (key in attrs) {
|
|
726
731
|
val = attrs[key];
|
|
727
732
|
nonPlainObject =
|
|
@@ -737,7 +742,6 @@ class Node {
|
|
|
737
742
|
obj.attrs[key] = val;
|
|
738
743
|
}
|
|
739
744
|
}
|
|
740
|
-
obj.className = this.getClassName();
|
|
741
745
|
return Util_1.Util._prepareToStringify(obj);
|
|
742
746
|
}
|
|
743
747
|
toJSON() {
|
|
@@ -949,6 +953,11 @@ class Node {
|
|
|
949
953
|
(stage ? stage.height() : 0),
|
|
950
954
|
pixelRatio: pixelRatio,
|
|
951
955
|
}), context = canvas.getContext();
|
|
956
|
+
const bufferCanvas = new Canvas_1.SceneCanvas({
|
|
957
|
+
width: canvas.width,
|
|
958
|
+
height: canvas.height,
|
|
959
|
+
pixelRatio: canvas.pixelRatio,
|
|
960
|
+
});
|
|
952
961
|
if (config.imageSmoothingEnabled === false) {
|
|
953
962
|
context._context.imageSmoothingEnabled = false;
|
|
954
963
|
}
|
|
@@ -956,7 +965,7 @@ class Node {
|
|
|
956
965
|
if (x || y) {
|
|
957
966
|
context.translate(-1 * x, -1 * y);
|
|
958
967
|
}
|
|
959
|
-
this.drawScene(canvas);
|
|
968
|
+
this.drawScene(canvas, undefined, bufferCanvas);
|
|
960
969
|
context.restore();
|
|
961
970
|
return canvas;
|
|
962
971
|
}
|
|
@@ -997,7 +1006,7 @@ class Node {
|
|
|
997
1006
|
this.toCanvas(config).toBlob((blob) => {
|
|
998
1007
|
resolve(blob);
|
|
999
1008
|
callback === null || callback === void 0 ? void 0 : callback(blob);
|
|
1000
|
-
});
|
|
1009
|
+
}, config === null || config === void 0 ? void 0 : config.mimeType, config === null || config === void 0 ? void 0 : config.quality);
|
|
1001
1010
|
}
|
|
1002
1011
|
catch (err) {
|
|
1003
1012
|
reject(err);
|
package/lib/Shape.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Nod
|
|
|
115
115
|
x: number;
|
|
116
116
|
y: number;
|
|
117
117
|
};
|
|
118
|
-
drawScene(can?: SceneCanvas, top?: Node): this;
|
|
118
|
+
drawScene(can?: SceneCanvas, top?: Node, bufferCanvas?: SceneCanvas): this;
|
|
119
119
|
drawHit(can?: HitCanvas, top?: Node, skipDragCheck?: boolean): this;
|
|
120
120
|
drawHitFromCache(alphaThreshold?: number): this;
|
|
121
121
|
hasPointerCapture(pointerId: number): boolean;
|
package/lib/Shape.js
CHANGED
|
@@ -227,9 +227,6 @@ class Shape extends Node_1.Node {
|
|
|
227
227
|
}
|
|
228
228
|
_useBufferCanvas(forceFill) {
|
|
229
229
|
var _a;
|
|
230
|
-
if (!this.getStage()) {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
230
|
const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;
|
|
234
231
|
if (!perfectDrawEnabled) {
|
|
235
232
|
return false;
|
|
@@ -304,9 +301,9 @@ class Shape extends Node_1.Node {
|
|
|
304
301
|
}
|
|
305
302
|
return rect;
|
|
306
303
|
}
|
|
307
|
-
drawScene(can, top) {
|
|
304
|
+
drawScene(can, top, bufferCanvas) {
|
|
308
305
|
var layer = this.getLayer();
|
|
309
|
-
var canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage,
|
|
306
|
+
var canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferContext;
|
|
310
307
|
var skipBuffer = canvas.isCache;
|
|
311
308
|
var cachingSelf = top === this;
|
|
312
309
|
if (!this.isVisible() && !cachingSelf) {
|
|
@@ -326,8 +323,8 @@ class Shape extends Node_1.Node {
|
|
|
326
323
|
context.save();
|
|
327
324
|
if (this._useBufferCanvas() && !skipBuffer) {
|
|
328
325
|
stage = this.getStage();
|
|
329
|
-
|
|
330
|
-
bufferContext =
|
|
326
|
+
const bc = bufferCanvas || stage.bufferCanvas;
|
|
327
|
+
bufferContext = bc.getContext();
|
|
331
328
|
bufferContext.clear();
|
|
332
329
|
bufferContext.save();
|
|
333
330
|
bufferContext._applyLineJoin(this);
|
|
@@ -335,13 +332,13 @@ class Shape extends Node_1.Node {
|
|
|
335
332
|
bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
|
|
336
333
|
drawFunc.call(this, bufferContext, this);
|
|
337
334
|
bufferContext.restore();
|
|
338
|
-
var ratio =
|
|
335
|
+
var ratio = bc.pixelRatio;
|
|
339
336
|
if (hasShadow) {
|
|
340
337
|
context._applyShadow(this);
|
|
341
338
|
}
|
|
342
339
|
context._applyOpacity(this);
|
|
343
340
|
context._applyGlobalCompositeOperation(this);
|
|
344
|
-
context.drawImage(
|
|
341
|
+
context.drawImage(bc._canvas, 0, 0, bc.width / ratio, bc.height / ratio);
|
|
345
342
|
}
|
|
346
343
|
else {
|
|
347
344
|
context._applyLineJoin(this);
|
package/lib/Util.d.ts
CHANGED
|
@@ -123,8 +123,8 @@ export declare const Util: {
|
|
|
123
123
|
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
|
|
124
124
|
_getProjectionToLine(pt: Vector2d, line: Array<Vector2d>, isClosed: boolean): Vector2d;
|
|
125
125
|
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
|
|
126
|
-
_prepareToStringify(obj: any):
|
|
127
|
-
_assign<
|
|
126
|
+
_prepareToStringify<T>(obj: any): T | null;
|
|
127
|
+
_assign<T_1, U>(target: T_1, source: U): T_1 & U;
|
|
128
128
|
_getFirstPointerId(evt: any): any;
|
|
129
129
|
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
130
130
|
drawRoundedRectPath(context: Context, width: number, height: number, cornerRadius: number | number[]): void;
|
package/lib/_CoreInternals.d.ts
CHANGED
|
@@ -133,8 +133,8 @@ export declare const Konva: {
|
|
|
133
133
|
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
|
|
134
134
|
_getProjectionToLine(pt: import("./types").Vector2d, line: import("./types").Vector2d[], isClosed: boolean): import("./types.js").Vector2d;
|
|
135
135
|
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
|
|
136
|
-
_prepareToStringify(obj: any):
|
|
137
|
-
_assign<
|
|
136
|
+
_prepareToStringify<T>(obj: any): T | null;
|
|
137
|
+
_assign<T_1, U>(target: T_1, source: U): T_1 & U;
|
|
138
138
|
_getFirstPointerId(evt: any): any;
|
|
139
139
|
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
140
140
|
drawRoundedRectPath(context: Context, width: number, height: number, cornerRadius: number | number[]): void;
|
package/lib/_FullInternals.d.ts
CHANGED
|
@@ -138,8 +138,8 @@ export declare const Konva: {
|
|
|
138
138
|
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
|
|
139
139
|
_getProjectionToLine(pt: import("./types").Vector2d, line: import("./types").Vector2d[], isClosed: boolean): import("./types.js").Vector2d;
|
|
140
140
|
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
|
|
141
|
-
_prepareToStringify(obj: any):
|
|
142
|
-
_assign<
|
|
141
|
+
_prepareToStringify<T>(obj: any): T | null;
|
|
142
|
+
_assign<T_1, U>(target: T_1, source: U): T_1 & U;
|
|
143
143
|
_getFirstPointerId(evt: any): any;
|
|
144
144
|
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
145
145
|
drawRoundedRectPath(context: import("./Context.js").Context, width: number, height: number, cornerRadius: number | number[]): void;
|
package/lib/index-types.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ declare namespace Konva {
|
|
|
39
39
|
export let hitOnDragEnabled: boolean;
|
|
40
40
|
export const isDragging: () => boolean;
|
|
41
41
|
export const isDragReady: () => boolean;
|
|
42
|
+
export const getAngle: (angle: number) => number;
|
|
42
43
|
|
|
43
44
|
export type Vector2d = import('./types.js').Vector2d;
|
|
44
45
|
|
|
@@ -46,16 +47,13 @@ declare namespace Konva {
|
|
|
46
47
|
export type Node = import('./Node.js').Node;
|
|
47
48
|
export type NodeConfig = import('./Node.js').NodeConfig;
|
|
48
49
|
|
|
49
|
-
export type KonvaEventObject<
|
|
50
|
-
EventType
|
|
51
|
-
> = import('./Node.js').KonvaEventObject<EventType>;
|
|
50
|
+
export type KonvaEventObject<EventType> =
|
|
51
|
+
import('./Node.js').KonvaEventObject<EventType>;
|
|
52
52
|
|
|
53
53
|
export type KonvaPointerEvent = import('./PointerEvents.js').KonvaPointerEvent;
|
|
54
54
|
|
|
55
|
-
export type KonvaEventListener<
|
|
56
|
-
This,
|
|
57
|
-
EventType
|
|
58
|
-
> = import('./Node.js').KonvaEventListener<This, EventType>;
|
|
55
|
+
export type KonvaEventListener<This, EventType> =
|
|
56
|
+
import('./Node.js').KonvaEventListener<This, EventType>;
|
|
59
57
|
|
|
60
58
|
export const Container: typeof import('./Container.js').Container;
|
|
61
59
|
export type Container = import('./Container.js').Container<Node>;
|
|
@@ -132,7 +130,8 @@ declare namespace Konva {
|
|
|
132
130
|
export type RectConfig = import('./shapes/Rect.js').RectConfig;
|
|
133
131
|
export const RegularPolygon: typeof import('./shapes/RegularPolygon.js').RegularPolygon;
|
|
134
132
|
export type RegularPolygon = import('./shapes/RegularPolygon.js').RegularPolygon;
|
|
135
|
-
export type RegularPolygonConfig =
|
|
133
|
+
export type RegularPolygonConfig =
|
|
134
|
+
import('./shapes/RegularPolygon.js').RegularPolygonConfig;
|
|
136
135
|
export const Ring: typeof import('./shapes/Ring.js').Ring;
|
|
137
136
|
export type Ring = import('./shapes/Ring.js').Ring;
|
|
138
137
|
export type RingConfig = import('./shapes/Ring.js').RingConfig;
|
|
@@ -150,7 +149,8 @@ declare namespace Konva {
|
|
|
150
149
|
export type TextPathConfig = import('./shapes/TextPath.js').TextPathConfig;
|
|
151
150
|
export const Transformer: typeof import('./shapes/Transformer.js').Transformer;
|
|
152
151
|
export type Transformer = import('./shapes/Transformer.js').Transformer;
|
|
153
|
-
export type TransformerConfig =
|
|
152
|
+
export type TransformerConfig =
|
|
153
|
+
import('./shapes/Transformer.js').TransformerConfig;
|
|
154
154
|
export const Wedge: typeof import('./shapes/Wedge.js').Wedge;
|
|
155
155
|
export type Wedge = import('./shapes/Wedge.js').Wedge;
|
|
156
156
|
export type WedgeConfig = import('./shapes/Wedge.js').WedgeConfig;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Transform } from '../Util.js';
|
|
2
2
|
import { Node } from '../Node.js';
|
|
3
|
+
import { Shape } from '../Shape.js';
|
|
3
4
|
import { Rect } from './Rect.js';
|
|
4
5
|
import { Group } from '../Group.js';
|
|
5
6
|
import { ContainerConfig } from '../Container.js';
|
|
@@ -10,6 +11,7 @@ export interface Box extends IRect {
|
|
|
10
11
|
export interface TransformerConfig extends ContainerConfig {
|
|
11
12
|
resizeEnabled?: boolean;
|
|
12
13
|
rotateEnabled?: boolean;
|
|
14
|
+
rotateLineVisible?: boolean;
|
|
13
15
|
rotationSnaps?: Array<number>;
|
|
14
16
|
rotationSnapTolerance?: number;
|
|
15
17
|
rotateAnchorOffset?: number;
|
|
@@ -33,6 +35,8 @@ export interface TransformerConfig extends ContainerConfig {
|
|
|
33
35
|
boundBoxFunc?: (oldBox: Box, newBox: Box) => Box;
|
|
34
36
|
useSingleNodeRotation?: boolean;
|
|
35
37
|
shouldOverdrawWholeArea?: boolean;
|
|
38
|
+
anchorDragBoundFunc?: (oldPos: Vector2d, newPos: Vector2d, evt: any) => Vector2d;
|
|
39
|
+
anchorStyleFunc?: (anchor: Shape) => void;
|
|
36
40
|
}
|
|
37
41
|
export declare class Transformer extends Group {
|
|
38
42
|
_nodes: Array<Node>;
|
|
@@ -87,7 +91,11 @@ export declare class Transformer extends Group {
|
|
|
87
91
|
isTransforming(): boolean;
|
|
88
92
|
stopTransform(): void;
|
|
89
93
|
destroy(): this;
|
|
90
|
-
toObject():
|
|
94
|
+
toObject(): {
|
|
95
|
+
attrs: any;
|
|
96
|
+
className: string;
|
|
97
|
+
children?: any[] | undefined;
|
|
98
|
+
};
|
|
91
99
|
clone(obj?: any): this;
|
|
92
100
|
getClientRect(): IRect;
|
|
93
101
|
nodes: GetSet<Node[], this>;
|
|
@@ -96,6 +104,7 @@ export declare class Transformer extends Group {
|
|
|
96
104
|
anchorSize: GetSet<number, this>;
|
|
97
105
|
resizeEnabled: GetSet<boolean, this>;
|
|
98
106
|
rotateEnabled: GetSet<boolean, this>;
|
|
107
|
+
rotateLineVisible: GetSet<boolean, this>;
|
|
99
108
|
rotateAnchorOffset: GetSet<number, this>;
|
|
100
109
|
rotationSnapTolerance: GetSet<number, this>;
|
|
101
110
|
rotateAnchorCursor: GetSet<string, this>;
|
|
@@ -412,7 +412,7 @@ class Transformer extends Group_1.Group {
|
|
|
412
412
|
ctx.beginPath();
|
|
413
413
|
ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);
|
|
414
414
|
ctx.moveTo(shape.width() / 2, -padding);
|
|
415
|
-
if (tr.rotateEnabled()) {
|
|
415
|
+
if (tr.rotateEnabled() && tr.rotateLineVisible()) {
|
|
416
416
|
ctx.lineTo(shape.width() / 2, -tr.rotateAnchorOffset() * Util_1.Util._sign(shape.height()) - padding);
|
|
417
417
|
}
|
|
418
418
|
ctx.fillStrokeShape(shape);
|
|
@@ -960,6 +960,7 @@ Factory_1.Factory.addGetterSetter(Transformer, 'flipEnabled', true, (0, Validato
|
|
|
960
960
|
Factory_1.Factory.addGetterSetter(Transformer, 'resizeEnabled', true);
|
|
961
961
|
Factory_1.Factory.addGetterSetter(Transformer, 'anchorSize', 10, (0, Validators_1.getNumberValidator)());
|
|
962
962
|
Factory_1.Factory.addGetterSetter(Transformer, 'rotateEnabled', true);
|
|
963
|
+
Factory_1.Factory.addGetterSetter(Transformer, 'rotateLineVisible', true);
|
|
963
964
|
Factory_1.Factory.addGetterSetter(Transformer, 'rotationSnaps', []);
|
|
964
965
|
Factory_1.Factory.addGetterSetter(Transformer, 'rotateAnchorOffset', 50, (0, Validators_1.getNumberValidator)());
|
|
965
966
|
Factory_1.Factory.addGetterSetter(Transformer, 'rotateAnchorCursor', 'crosshair');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "konva",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.1",
|
|
4
4
|
"author": "Anton Lavrenov",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
],
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@parcel/transformer-image": "2.10.1",
|
|
63
|
-
"@size-limit/preset-big-lib": "^
|
|
64
|
-
"@types/mocha": "^10.0.
|
|
63
|
+
"@size-limit/preset-big-lib": "^11.0.1",
|
|
64
|
+
"@types/mocha": "^10.0.6",
|
|
65
65
|
"canvas": "^2.11.2",
|
|
66
66
|
"chai": "4.3.10",
|
|
67
67
|
"filehound": "^1.17.6",
|
|
@@ -80,15 +80,15 @@
|
|
|
80
80
|
"mocha-headless-chrome": "^4.0.0",
|
|
81
81
|
"parcel": "2.10.1",
|
|
82
82
|
"process": "^0.11.10",
|
|
83
|
-
"rollup": "^4.
|
|
83
|
+
"rollup": "^4.9.1",
|
|
84
84
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
85
85
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
86
86
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
87
87
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
88
|
-
"size-limit": "^
|
|
88
|
+
"size-limit": "^11.0.1",
|
|
89
89
|
"ts-mocha": "^10.0.0",
|
|
90
|
-
"ts-node": "^10.9.
|
|
91
|
-
"typescript": "^5.
|
|
90
|
+
"ts-node": "^10.9.2",
|
|
91
|
+
"typescript": "^5.3.3"
|
|
92
92
|
},
|
|
93
93
|
"keywords": [
|
|
94
94
|
"canvas",
|