konva 8.4.3 → 9.0.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/README.md +1 -9
- package/konva.js +17691 -16989
- package/konva.min.js +3 -3
- package/lib/Animation.js +11 -7
- package/lib/BezierFunctions.d.ts +6 -0
- package/lib/BezierFunctions.js +791 -0
- package/lib/Canvas.d.ts +1 -0
- package/lib/Canvas.js +26 -18
- package/lib/Container.js +16 -12
- package/lib/Context.d.ts +3 -1
- package/lib/Context.js +18 -10
- package/lib/Core.js +7 -3
- package/lib/DragAndDrop.js +25 -22
- package/lib/Factory.js +27 -24
- package/lib/FastLayer.js +10 -6
- package/lib/Global.js +16 -12
- package/lib/Group.js +10 -6
- package/lib/Layer.js +37 -33
- package/lib/Node.d.ts +1 -0
- package/lib/Node.js +105 -104
- package/lib/PointerEvents.js +15 -7
- package/lib/Shape.js +90 -86
- package/lib/Stage.js +51 -47
- package/lib/Tween.js +26 -22
- package/lib/Util.js +29 -25
- package/lib/Validators.js +58 -44
- package/lib/_CoreInternals.js +36 -33
- package/lib/_FullInternals.js +78 -75
- package/lib/filters/Blur.js +9 -5
- package/lib/filters/Brighten.js +9 -5
- package/lib/filters/Contrast.js +9 -5
- package/lib/filters/Emboss.js +14 -10
- package/lib/filters/Enhance.js +9 -5
- package/lib/filters/Grayscale.js +5 -1
- package/lib/filters/HSL.js +11 -7
- package/lib/filters/HSV.js +11 -7
- package/lib/filters/Invert.js +5 -1
- package/lib/filters/Kaleidoscope.js +13 -9
- package/lib/filters/Mask.js +9 -5
- package/lib/filters/Noise.js +9 -5
- package/lib/filters/Pixelate.js +11 -7
- package/lib/filters/Posterize.js +9 -5
- package/lib/filters/RGB.js +11 -7
- package/lib/filters/RGBA.js +12 -8
- package/lib/filters/Sepia.js +5 -1
- package/lib/filters/Solarize.js +5 -1
- package/lib/filters/Threshold.js +9 -5
- package/lib/index-node.js +7 -5
- package/lib/index.js +4 -2
- package/lib/shapes/Arc.js +17 -13
- package/lib/shapes/Arrow.js +17 -13
- package/lib/shapes/Circle.js +11 -7
- package/lib/shapes/Ellipse.js +13 -9
- package/lib/shapes/Image.js +21 -17
- package/lib/shapes/Label.js +18 -13
- package/lib/shapes/Line.js +14 -10
- package/lib/shapes/Path.d.ts +5 -2
- package/lib/shapes/Path.js +44 -43
- package/lib/shapes/Rect.js +13 -9
- package/lib/shapes/RegularPolygon.js +12 -8
- package/lib/shapes/Ring.js +12 -8
- package/lib/shapes/Sprite.js +19 -15
- package/lib/shapes/Star.js +13 -9
- package/lib/shapes/Text.js +31 -26
- package/lib/shapes/TextPath.d.ts +5 -1
- package/lib/shapes/TextPath.js +82 -188
- package/lib/shapes/Transformer.d.ts +2 -0
- package/lib/shapes/Transformer.js +97 -82
- package/lib/shapes/Wedge.js +16 -12
- package/lib/types.d.ts +6 -0
- package/lib/types.js +5 -2
- package/package.json +13 -42
- package/cmj/Animation.d.ts +0 -24
- package/cmj/Animation.js +0 -145
- package/cmj/Canvas.d.ts +0 -32
- package/cmj/Canvas.js +0 -114
- package/cmj/Container.d.ts +0 -47
- package/cmj/Container.js +0 -325
- package/cmj/Context.d.ts +0 -85
- package/cmj/Context.js +0 -538
- package/cmj/Core.d.ts +0 -3
- package/cmj/Core.js +0 -7
- package/cmj/DragAndDrop.d.ts +0 -17
- package/cmj/DragAndDrop.js +0 -111
- package/cmj/Factory.d.ts +0 -11
- package/cmj/Factory.js +0 -125
- package/cmj/FastLayer.d.ts +0 -4
- package/cmj/FastLayer.js +0 -16
- package/cmj/Global.d.ts +0 -34
- package/cmj/Global.js +0 -61
- package/cmj/Group.d.ts +0 -8
- package/cmj/Group.js +0 -17
- package/cmj/Layer.d.ts +0 -61
- package/cmj/Layer.js +0 -309
- package/cmj/Node.d.ts +0 -328
- package/cmj/Node.js +0 -1420
- package/cmj/PointerEvents.d.ts +0 -11
- package/cmj/PointerEvents.js +0 -45
- package/cmj/Shape.d.ts +0 -186
- package/cmj/Shape.js +0 -521
- package/cmj/Stage.d.ts +0 -85
- package/cmj/Stage.js +0 -692
- package/cmj/Tween.d.ts +0 -86
- package/cmj/Tween.js +0 -520
- package/cmj/Util.d.ts +0 -91
- package/cmj/Util.js +0 -801
- package/cmj/Validators.d.ts +0 -11
- package/cmj/Validators.js +0 -192
- package/cmj/_CoreInternals.d.ts +0 -152
- package/cmj/_CoreInternals.js +0 -37
- package/cmj/_FullInternals.d.ts +0 -196
- package/cmj/_FullInternals.js +0 -81
- package/cmj/filters/Blur.d.ts +0 -2
- package/cmj/filters/Blur.js +0 -701
- package/cmj/filters/Brighten.d.ts +0 -2
- package/cmj/filters/Brighten.js +0 -16
- package/cmj/filters/Contrast.d.ts +0 -2
- package/cmj/filters/Contrast.js +0 -38
- package/cmj/filters/Emboss.d.ts +0 -2
- package/cmj/filters/Emboss.js +0 -106
- package/cmj/filters/Enhance.d.ts +0 -2
- package/cmj/filters/Enhance.js +0 -87
- package/cmj/filters/Grayscale.d.ts +0 -2
- package/cmj/filters/Grayscale.js +0 -13
- package/cmj/filters/HSL.d.ts +0 -2
- package/cmj/filters/HSL.js +0 -28
- package/cmj/filters/HSV.d.ts +0 -2
- package/cmj/filters/HSV.js +0 -28
- package/cmj/filters/Invert.d.ts +0 -2
- package/cmj/filters/Invert.js +0 -12
- package/cmj/filters/Kaleidoscope.d.ts +0 -2
- package/cmj/filters/Kaleidoscope.js +0 -137
- package/cmj/filters/Mask.d.ts +0 -2
- package/cmj/filters/Mask.js +0 -144
- package/cmj/filters/Noise.d.ts +0 -2
- package/cmj/filters/Noise.js +0 -16
- package/cmj/filters/Pixelate.d.ts +0 -2
- package/cmj/filters/Pixelate.js +0 -64
- package/cmj/filters/Posterize.d.ts +0 -2
- package/cmj/filters/Posterize.js +0 -14
- package/cmj/filters/RGB.d.ts +0 -2
- package/cmj/filters/RGB.js +0 -43
- package/cmj/filters/RGBA.d.ts +0 -2
- package/cmj/filters/RGBA.js +0 -53
- package/cmj/filters/Sepia.d.ts +0 -2
- package/cmj/filters/Sepia.js +0 -15
- package/cmj/filters/Solarize.d.ts +0 -2
- package/cmj/filters/Solarize.js +0 -29
- package/cmj/filters/Threshold.d.ts +0 -2
- package/cmj/filters/Threshold.js +0 -14
- package/cmj/index-node.d.ts +0 -2
- package/cmj/index-node.js +0 -21
- package/cmj/index-types.d.ts +0 -181
- package/cmj/index.d.ts +0 -2
- package/cmj/index.js +0 -4
- package/cmj/package.json +0 -6
- package/cmj/shapes/Arc.d.ts +0 -26
- package/cmj/shapes/Arc.js +0 -59
- package/cmj/shapes/Arrow.d.ts +0 -26
- package/cmj/shapes/Arrow.js +0 -103
- package/cmj/shapes/Circle.d.ts +0 -14
- package/cmj/shapes/Circle.js +0 -37
- package/cmj/shapes/Ellipse.d.ts +0 -17
- package/cmj/shapes/Ellipse.js +0 -41
- package/cmj/shapes/Image.d.ts +0 -25
- package/cmj/shapes/Image.js +0 -117
- package/cmj/shapes/Label.d.ts +0 -36
- package/cmj/shapes/Label.js +0 -178
- package/cmj/shapes/Line.d.ts +0 -28
- package/cmj/shapes/Line.js +0 -159
- package/cmj/shapes/Path.d.ts +0 -37
- package/cmj/shapes/Path.js +0 -631
- package/cmj/shapes/Rect.d.ts +0 -10
- package/cmj/shapes/Rect.js +0 -26
- package/cmj/shapes/RegularPolygon.d.ts +0 -23
- package/cmj/shapes/RegularPolygon.js +0 -69
- package/cmj/shapes/Ring.d.ts +0 -16
- package/cmj/shapes/Ring.js +0 -37
- package/cmj/shapes/Sprite.d.ts +0 -31
- package/cmj/shapes/Sprite.js +0 -112
- package/cmj/shapes/Star.d.ts +0 -18
- package/cmj/shapes/Star.js +0 -42
- package/cmj/shapes/Text.d.ts +0 -63
- package/cmj/shapes/Text.js +0 -373
- package/cmj/shapes/TextPath.d.ts +0 -56
- package/cmj/shapes/TextPath.js +0 -351
- package/cmj/shapes/Transformer.d.ts +0 -116
- package/cmj/shapes/Transformer.js +0 -971
- package/cmj/shapes/Wedge.d.ts +0 -18
- package/cmj/shapes/Wedge.js +0 -42
- package/cmj/types.d.ts +0 -50
- package/cmj/types.js +0 -25
package/lib/Shape.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Shape = exports.shapes = void 0;
|
|
4
|
+
const Global_1 = require("./Global");
|
|
5
|
+
const Util_1 = require("./Util");
|
|
6
|
+
const Factory_1 = require("./Factory");
|
|
7
|
+
const Node_1 = require("./Node");
|
|
8
|
+
const Validators_1 = require("./Validators");
|
|
9
|
+
const Global_2 = require("./Global");
|
|
10
|
+
const PointerEvents = require("./PointerEvents");
|
|
8
11
|
var HAS_SHADOW = 'hasShadow';
|
|
9
12
|
var SHADOW_RGBA = 'shadowRGBA';
|
|
10
13
|
var patternImage = 'patternImage';
|
|
@@ -15,10 +18,10 @@ function getDummyContext() {
|
|
|
15
18
|
if (dummyContext) {
|
|
16
19
|
return dummyContext;
|
|
17
20
|
}
|
|
18
|
-
dummyContext = Util.createCanvasElement().getContext('2d');
|
|
21
|
+
dummyContext = Util_1.Util.createCanvasElement().getContext('2d');
|
|
19
22
|
return dummyContext;
|
|
20
23
|
}
|
|
21
|
-
|
|
24
|
+
exports.shapes = {};
|
|
22
25
|
function _fillFunc(context) {
|
|
23
26
|
context.fill();
|
|
24
27
|
}
|
|
@@ -46,25 +49,25 @@ function _clearLinearGradientCache() {
|
|
|
46
49
|
function _clearRadialGradientCache() {
|
|
47
50
|
this._clearCache(radialGradient);
|
|
48
51
|
}
|
|
49
|
-
|
|
52
|
+
class Shape extends Node_1.Node {
|
|
50
53
|
constructor(config) {
|
|
51
54
|
super(config);
|
|
52
55
|
let key;
|
|
53
56
|
while (true) {
|
|
54
|
-
key = Util.getRandomColor();
|
|
55
|
-
if (key && !(key in shapes)) {
|
|
57
|
+
key = Util_1.Util.getRandomColor();
|
|
58
|
+
if (key && !(key in exports.shapes)) {
|
|
56
59
|
break;
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
this.colorKey = key;
|
|
60
|
-
shapes[key] = this;
|
|
63
|
+
exports.shapes[key] = this;
|
|
61
64
|
}
|
|
62
65
|
getContext() {
|
|
63
|
-
Util.warn('shape.getContext() method is deprecated. Please do not use it.');
|
|
66
|
+
Util_1.Util.warn('shape.getContext() method is deprecated. Please do not use it.');
|
|
64
67
|
return this.getLayer().getContext();
|
|
65
68
|
}
|
|
66
69
|
getCanvas() {
|
|
67
|
-
Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');
|
|
70
|
+
Util_1.Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');
|
|
68
71
|
return this.getLayer().getCanvas();
|
|
69
72
|
}
|
|
70
73
|
getSceneFunc() {
|
|
@@ -92,9 +95,9 @@ export class Shape extends Node {
|
|
|
92
95
|
var ctx = getDummyContext();
|
|
93
96
|
const pattern = ctx.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || 'repeat');
|
|
94
97
|
if (pattern && pattern.setTransform) {
|
|
95
|
-
const tr = new Transform();
|
|
98
|
+
const tr = new Util_1.Transform();
|
|
96
99
|
tr.translate(this.fillPatternX(), this.fillPatternY());
|
|
97
|
-
tr.rotate(Konva.getAngle(this.fillPatternRotation()));
|
|
100
|
+
tr.rotate(Global_1.Konva.getAngle(this.fillPatternRotation()));
|
|
98
101
|
tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
|
|
99
102
|
tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
|
|
100
103
|
const m = tr.getMatrix();
|
|
@@ -152,7 +155,7 @@ export class Shape extends Node {
|
|
|
152
155
|
if (!this.hasShadow()) {
|
|
153
156
|
return;
|
|
154
157
|
}
|
|
155
|
-
var rgba = Util.colorToRGBA(this.shadowColor());
|
|
158
|
+
var rgba = Util_1.Util.colorToRGBA(this.shadowColor());
|
|
156
159
|
if (rgba) {
|
|
157
160
|
return ('rgba(' +
|
|
158
161
|
rgba.r +
|
|
@@ -207,8 +210,8 @@ export class Shape extends Node {
|
|
|
207
210
|
return p[3] > 0;
|
|
208
211
|
}
|
|
209
212
|
destroy() {
|
|
210
|
-
Node.prototype.destroy.call(this);
|
|
211
|
-
delete shapes[this.colorKey];
|
|
213
|
+
Node_1.Node.prototype.destroy.call(this);
|
|
214
|
+
delete exports.shapes[this.colorKey];
|
|
212
215
|
delete this.colorKey;
|
|
213
216
|
return this;
|
|
214
217
|
}
|
|
@@ -235,7 +238,7 @@ export class Shape extends Node {
|
|
|
235
238
|
return false;
|
|
236
239
|
}
|
|
237
240
|
setStrokeHitEnabled(val) {
|
|
238
|
-
Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');
|
|
241
|
+
Util_1.Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');
|
|
239
242
|
if (val) {
|
|
240
243
|
this.hitStrokeWidth('auto');
|
|
241
244
|
}
|
|
@@ -351,7 +354,7 @@ export class Shape extends Node {
|
|
|
351
354
|
}
|
|
352
355
|
var layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
|
|
353
356
|
if (!this.colorKey) {
|
|
354
|
-
Util.warn('Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()');
|
|
357
|
+
Util_1.Util.warn('Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()');
|
|
355
358
|
}
|
|
356
359
|
if (cachedHitCanvas) {
|
|
357
360
|
context.save();
|
|
@@ -383,7 +386,7 @@ export class Shape extends Node {
|
|
|
383
386
|
hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight);
|
|
384
387
|
hitData = hitImageData.data;
|
|
385
388
|
len = hitData.length;
|
|
386
|
-
rgbColorKey = Util._hexToRgb(this.colorKey);
|
|
389
|
+
rgbColorKey = Util_1.Util._hexToRgb(this.colorKey);
|
|
387
390
|
for (i = 0; i < len; i += 4) {
|
|
388
391
|
alpha = hitData[i + 3];
|
|
389
392
|
if (alpha > alphaThreshold) {
|
|
@@ -399,7 +402,7 @@ export class Shape extends Node {
|
|
|
399
402
|
hitContext.putImageData(hitImageData, 0, 0);
|
|
400
403
|
}
|
|
401
404
|
catch (e) {
|
|
402
|
-
Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);
|
|
405
|
+
Util_1.Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);
|
|
403
406
|
}
|
|
404
407
|
return this;
|
|
405
408
|
}
|
|
@@ -413,98 +416,99 @@ export class Shape extends Node {
|
|
|
413
416
|
PointerEvents.releaseCapture(pointerId, this);
|
|
414
417
|
}
|
|
415
418
|
}
|
|
419
|
+
exports.Shape = Shape;
|
|
416
420
|
Shape.prototype._fillFunc = _fillFunc;
|
|
417
421
|
Shape.prototype._strokeFunc = _strokeFunc;
|
|
418
422
|
Shape.prototype._fillFuncHit = _fillFuncHit;
|
|
419
423
|
Shape.prototype._strokeFuncHit = _strokeFuncHit;
|
|
420
424
|
Shape.prototype._centroid = false;
|
|
421
425
|
Shape.prototype.nodeType = 'Shape';
|
|
422
|
-
_registerNode(Shape);
|
|
426
|
+
(0, Global_2._registerNode)(Shape);
|
|
423
427
|
Shape.prototype.eventListeners = {};
|
|
424
428
|
Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);
|
|
425
429
|
Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);
|
|
426
430
|
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);
|
|
427
431
|
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);
|
|
428
432
|
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);
|
|
429
|
-
Factory.addGetterSetter(Shape, 'stroke', undefined, getStringOrGradientValidator());
|
|
430
|
-
Factory.addGetterSetter(Shape, 'strokeWidth', 2, getNumberValidator());
|
|
431
|
-
Factory.addGetterSetter(Shape, 'fillAfterStrokeEnabled', false);
|
|
432
|
-
Factory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', getNumberOrAutoValidator());
|
|
433
|
-
Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, getBooleanValidator());
|
|
434
|
-
Factory.addGetterSetter(Shape, 'perfectDrawEnabled', true, getBooleanValidator());
|
|
435
|
-
Factory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, getBooleanValidator());
|
|
436
|
-
Factory.addGetterSetter(Shape, 'lineJoin');
|
|
437
|
-
Factory.addGetterSetter(Shape, 'lineCap');
|
|
438
|
-
Factory.addGetterSetter(Shape, 'sceneFunc');
|
|
439
|
-
Factory.addGetterSetter(Shape, 'hitFunc');
|
|
440
|
-
Factory.addGetterSetter(Shape, 'dash');
|
|
441
|
-
Factory.addGetterSetter(Shape, 'dashOffset', 0, getNumberValidator());
|
|
442
|
-
Factory.addGetterSetter(Shape, 'shadowColor', undefined, getStringValidator());
|
|
443
|
-
Factory.addGetterSetter(Shape, 'shadowBlur', 0, getNumberValidator());
|
|
444
|
-
Factory.addGetterSetter(Shape, 'shadowOpacity', 1, getNumberValidator());
|
|
445
|
-
Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);
|
|
446
|
-
Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, getNumberValidator());
|
|
447
|
-
Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, getNumberValidator());
|
|
448
|
-
Factory.addGetterSetter(Shape, 'fillPatternImage');
|
|
449
|
-
Factory.addGetterSetter(Shape, 'fill', undefined, getStringOrGradientValidator());
|
|
450
|
-
Factory.addGetterSetter(Shape, 'fillPatternX', 0, getNumberValidator());
|
|
451
|
-
Factory.addGetterSetter(Shape, 'fillPatternY', 0, getNumberValidator());
|
|
452
|
-
Factory.addGetterSetter(Shape, 'fillLinearGradientColorStops');
|
|
453
|
-
Factory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');
|
|
454
|
-
Factory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);
|
|
455
|
-
Factory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);
|
|
456
|
-
Factory.addGetterSetter(Shape, 'fillRadialGradientColorStops');
|
|
457
|
-
Factory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');
|
|
458
|
-
Factory.addGetterSetter(Shape, 'fillEnabled', true);
|
|
459
|
-
Factory.addGetterSetter(Shape, 'strokeEnabled', true);
|
|
460
|
-
Factory.addGetterSetter(Shape, 'shadowEnabled', true);
|
|
461
|
-
Factory.addGetterSetter(Shape, 'dashEnabled', true);
|
|
462
|
-
Factory.addGetterSetter(Shape, 'strokeScaleEnabled', true);
|
|
463
|
-
Factory.addGetterSetter(Shape, 'fillPriority', 'color');
|
|
464
|
-
Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);
|
|
465
|
-
Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, getNumberValidator());
|
|
466
|
-
Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, getNumberValidator());
|
|
467
|
-
Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);
|
|
468
|
-
Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, getNumberValidator());
|
|
469
|
-
Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, getNumberValidator());
|
|
470
|
-
Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [
|
|
433
|
+
Factory_1.Factory.addGetterSetter(Shape, 'stroke', undefined, (0, Validators_1.getStringOrGradientValidator)());
|
|
434
|
+
Factory_1.Factory.addGetterSetter(Shape, 'strokeWidth', 2, (0, Validators_1.getNumberValidator)());
|
|
435
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillAfterStrokeEnabled', false);
|
|
436
|
+
Factory_1.Factory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', (0, Validators_1.getNumberOrAutoValidator)());
|
|
437
|
+
Factory_1.Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, (0, Validators_1.getBooleanValidator)());
|
|
438
|
+
Factory_1.Factory.addGetterSetter(Shape, 'perfectDrawEnabled', true, (0, Validators_1.getBooleanValidator)());
|
|
439
|
+
Factory_1.Factory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, (0, Validators_1.getBooleanValidator)());
|
|
440
|
+
Factory_1.Factory.addGetterSetter(Shape, 'lineJoin');
|
|
441
|
+
Factory_1.Factory.addGetterSetter(Shape, 'lineCap');
|
|
442
|
+
Factory_1.Factory.addGetterSetter(Shape, 'sceneFunc');
|
|
443
|
+
Factory_1.Factory.addGetterSetter(Shape, 'hitFunc');
|
|
444
|
+
Factory_1.Factory.addGetterSetter(Shape, 'dash');
|
|
445
|
+
Factory_1.Factory.addGetterSetter(Shape, 'dashOffset', 0, (0, Validators_1.getNumberValidator)());
|
|
446
|
+
Factory_1.Factory.addGetterSetter(Shape, 'shadowColor', undefined, (0, Validators_1.getStringValidator)());
|
|
447
|
+
Factory_1.Factory.addGetterSetter(Shape, 'shadowBlur', 0, (0, Validators_1.getNumberValidator)());
|
|
448
|
+
Factory_1.Factory.addGetterSetter(Shape, 'shadowOpacity', 1, (0, Validators_1.getNumberValidator)());
|
|
449
|
+
Factory_1.Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);
|
|
450
|
+
Factory_1.Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, (0, Validators_1.getNumberValidator)());
|
|
451
|
+
Factory_1.Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, (0, Validators_1.getNumberValidator)());
|
|
452
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternImage');
|
|
453
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fill', undefined, (0, Validators_1.getStringOrGradientValidator)());
|
|
454
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternX', 0, (0, Validators_1.getNumberValidator)());
|
|
455
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternY', 0, (0, Validators_1.getNumberValidator)());
|
|
456
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientColorStops');
|
|
457
|
+
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');
|
|
458
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);
|
|
459
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);
|
|
460
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientColorStops');
|
|
461
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');
|
|
462
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillEnabled', true);
|
|
463
|
+
Factory_1.Factory.addGetterSetter(Shape, 'strokeEnabled', true);
|
|
464
|
+
Factory_1.Factory.addGetterSetter(Shape, 'shadowEnabled', true);
|
|
465
|
+
Factory_1.Factory.addGetterSetter(Shape, 'dashEnabled', true);
|
|
466
|
+
Factory_1.Factory.addGetterSetter(Shape, 'strokeScaleEnabled', true);
|
|
467
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPriority', 'color');
|
|
468
|
+
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);
|
|
469
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, (0, Validators_1.getNumberValidator)());
|
|
470
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, (0, Validators_1.getNumberValidator)());
|
|
471
|
+
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);
|
|
472
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, (0, Validators_1.getNumberValidator)());
|
|
473
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, (0, Validators_1.getNumberValidator)());
|
|
474
|
+
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [
|
|
471
475
|
'x',
|
|
472
476
|
'y',
|
|
473
477
|
]);
|
|
474
|
-
Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [
|
|
478
|
+
Factory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [
|
|
475
479
|
'x',
|
|
476
480
|
'y',
|
|
477
481
|
]);
|
|
478
|
-
Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);
|
|
479
|
-
Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);
|
|
480
|
-
Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);
|
|
481
|
-
Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);
|
|
482
|
-
Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [
|
|
482
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);
|
|
483
|
+
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);
|
|
484
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);
|
|
485
|
+
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);
|
|
486
|
+
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [
|
|
483
487
|
'x',
|
|
484
488
|
'y',
|
|
485
489
|
]);
|
|
486
|
-
Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [
|
|
490
|
+
Factory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [
|
|
487
491
|
'x',
|
|
488
492
|
'y',
|
|
489
493
|
]);
|
|
490
|
-
Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);
|
|
491
|
-
Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);
|
|
492
|
-
Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);
|
|
493
|
-
Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);
|
|
494
|
-
Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [
|
|
494
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);
|
|
495
|
+
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);
|
|
496
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);
|
|
497
|
+
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);
|
|
498
|
+
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [
|
|
495
499
|
'x',
|
|
496
500
|
'y',
|
|
497
501
|
]);
|
|
498
|
-
Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);
|
|
499
|
-
Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);
|
|
500
|
-
Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [
|
|
502
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);
|
|
503
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);
|
|
504
|
+
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [
|
|
501
505
|
'x',
|
|
502
506
|
'y',
|
|
503
507
|
]);
|
|
504
|
-
Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);
|
|
505
|
-
Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);
|
|
506
|
-
Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);
|
|
507
|
-
Factory.backCompat(Shape, {
|
|
508
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);
|
|
509
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);
|
|
510
|
+
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);
|
|
511
|
+
Factory_1.Factory.backCompat(Shape, {
|
|
508
512
|
dashArray: 'dash',
|
|
509
513
|
getDashArray: 'getDash',
|
|
510
514
|
setDashArray: 'getDash',
|
package/lib/Stage.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Stage = exports.stages = void 0;
|
|
4
|
+
const Util_1 = require("./Util");
|
|
5
|
+
const Factory_1 = require("./Factory");
|
|
6
|
+
const Container_1 = require("./Container");
|
|
7
|
+
const Global_1 = require("./Global");
|
|
8
|
+
const Canvas_1 = require("./Canvas");
|
|
9
|
+
const DragAndDrop_1 = require("./DragAndDrop");
|
|
10
|
+
const Global_2 = require("./Global");
|
|
11
|
+
const PointerEvents = require("./PointerEvents");
|
|
9
12
|
var STAGE = 'Stage', STRING = 'string', PX = 'px', MOUSEOUT = 'mouseout', MOUSELEAVE = 'mouseleave', MOUSEOVER = 'mouseover', MOUSEENTER = 'mouseenter', MOUSEMOVE = 'mousemove', MOUSEDOWN = 'mousedown', MOUSEUP = 'mouseup', POINTERMOVE = 'pointermove', POINTERDOWN = 'pointerdown', POINTERUP = 'pointerup', POINTERCANCEL = 'pointercancel', LOSTPOINTERCAPTURE = 'lostpointercapture', POINTEROUT = 'pointerout', POINTERLEAVE = 'pointerleave', POINTEROVER = 'pointerover', POINTERENTER = 'pointerenter', CONTEXTMENU = 'contextmenu', TOUCHSTART = 'touchstart', TOUCHEND = 'touchend', TOUCHMOVE = 'touchmove', TOUCHCANCEL = 'touchcancel', WHEEL = 'wheel', MAX_LAYERS_NUMBER = 5, EVENTS = [
|
|
10
13
|
[MOUSEENTER, '_pointerenter'],
|
|
11
14
|
[MOUSEDOWN, '_pointerdown'],
|
|
@@ -75,7 +78,7 @@ const getEventType = (type) => {
|
|
|
75
78
|
const getEventsMap = (eventType) => {
|
|
76
79
|
const type = getEventType(eventType);
|
|
77
80
|
if (type === 'pointer') {
|
|
78
|
-
return Konva.pointerEventsEnabled && EVENTS_MAP.pointer;
|
|
81
|
+
return Global_1.Konva.pointerEventsEnabled && EVENTS_MAP.pointer;
|
|
79
82
|
}
|
|
80
83
|
if (type === 'touch') {
|
|
81
84
|
return EVENTS_MAP.touch;
|
|
@@ -86,20 +89,20 @@ const getEventsMap = (eventType) => {
|
|
|
86
89
|
};
|
|
87
90
|
function checkNoClip(attrs = {}) {
|
|
88
91
|
if (attrs.clipFunc || attrs.clipWidth || attrs.clipHeight) {
|
|
89
|
-
Util.warn('Stage does not support clipping. Please use clip for Layers or Groups.');
|
|
92
|
+
Util_1.Util.warn('Stage does not support clipping. Please use clip for Layers or Groups.');
|
|
90
93
|
}
|
|
91
94
|
return attrs;
|
|
92
95
|
}
|
|
93
96
|
const NO_POINTERS_MESSAGE = `Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`;
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
exports.stages = [];
|
|
98
|
+
class Stage extends Container_1.Container {
|
|
96
99
|
constructor(config) {
|
|
97
100
|
super(checkNoClip(config));
|
|
98
101
|
this._pointerPositions = [];
|
|
99
102
|
this._changedPointerPositions = [];
|
|
100
103
|
this._buildDOM();
|
|
101
104
|
this._bindContentEvents();
|
|
102
|
-
stages.push(this);
|
|
105
|
+
exports.stages.push(this);
|
|
103
106
|
this.on('widthChange.konva heightChange.konva', this._resizeDOM);
|
|
104
107
|
this.on('visibleChange.konva', this._checkVisibility);
|
|
105
108
|
this.on('clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva', () => {
|
|
@@ -112,7 +115,7 @@ export class Stage extends Container {
|
|
|
112
115
|
const isFastLayer = child.getType() === 'FastLayer';
|
|
113
116
|
const valid = isLayer || isFastLayer;
|
|
114
117
|
if (!valid) {
|
|
115
|
-
Util.throw('You may only add layers to the stage.');
|
|
118
|
+
Util_1.Util.throw('You may only add layers to the stage.');
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
_checkVisibility() {
|
|
@@ -167,25 +170,25 @@ export class Stage extends Container {
|
|
|
167
170
|
}
|
|
168
171
|
obj.container =
|
|
169
172
|
typeof document !== 'undefined' && document.createElement('div');
|
|
170
|
-
return Container.prototype.clone.call(this, obj);
|
|
173
|
+
return Container_1.Container.prototype.clone.call(this, obj);
|
|
171
174
|
}
|
|
172
175
|
destroy() {
|
|
173
176
|
super.destroy();
|
|
174
177
|
var content = this.content;
|
|
175
|
-
if (content && Util._isInDocument(content)) {
|
|
178
|
+
if (content && Util_1.Util._isInDocument(content)) {
|
|
176
179
|
this.container().removeChild(content);
|
|
177
180
|
}
|
|
178
|
-
var index = stages.indexOf(this);
|
|
181
|
+
var index = exports.stages.indexOf(this);
|
|
179
182
|
if (index > -1) {
|
|
180
|
-
stages.splice(index, 1);
|
|
183
|
+
exports.stages.splice(index, 1);
|
|
181
184
|
}
|
|
182
|
-
Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas);
|
|
185
|
+
Util_1.Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas);
|
|
183
186
|
return this;
|
|
184
187
|
}
|
|
185
188
|
getPointerPosition() {
|
|
186
189
|
const pos = this._pointerPositions[0] || this._changedPointerPositions[0];
|
|
187
190
|
if (!pos) {
|
|
188
|
-
Util.warn(NO_POINTERS_MESSAGE);
|
|
191
|
+
Util_1.Util.warn(NO_POINTERS_MESSAGE);
|
|
189
192
|
return null;
|
|
190
193
|
}
|
|
191
194
|
return {
|
|
@@ -211,7 +214,7 @@ export class Stage extends Container {
|
|
|
211
214
|
config.y = config.y || 0;
|
|
212
215
|
config.width = config.width || this.width();
|
|
213
216
|
config.height = config.height || this.height();
|
|
214
|
-
var canvas = new SceneCanvas({
|
|
217
|
+
var canvas = new Canvas_1.SceneCanvas({
|
|
215
218
|
width: config.width,
|
|
216
219
|
height: config.height,
|
|
217
220
|
pixelRatio: config.pixelRatio || 1,
|
|
@@ -267,13 +270,13 @@ export class Stage extends Container {
|
|
|
267
270
|
super.add(layer);
|
|
268
271
|
var length = this.children.length;
|
|
269
272
|
if (length > MAX_LAYERS_NUMBER) {
|
|
270
|
-
Util.warn('The stage has ' +
|
|
273
|
+
Util_1.Util.warn('The stage has ' +
|
|
271
274
|
length +
|
|
272
275
|
' layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.');
|
|
273
276
|
}
|
|
274
277
|
layer.setSize({ width: this.width(), height: this.height() });
|
|
275
278
|
layer.draw();
|
|
276
|
-
if (Konva.isBrowser) {
|
|
279
|
+
if (Global_1.Konva.isBrowser) {
|
|
277
280
|
this.content.appendChild(layer.canvas._canvas);
|
|
278
281
|
}
|
|
279
282
|
return this;
|
|
@@ -297,7 +300,7 @@ export class Stage extends Container {
|
|
|
297
300
|
return this.children;
|
|
298
301
|
}
|
|
299
302
|
_bindContentEvents() {
|
|
300
|
-
if (!Konva.isBrowser) {
|
|
303
|
+
if (!Global_1.Konva.isBrowser) {
|
|
301
304
|
return;
|
|
302
305
|
}
|
|
303
306
|
EVENTS.forEach(([event, methodName]) => {
|
|
@@ -339,7 +342,7 @@ export class Stage extends Container {
|
|
|
339
342
|
}
|
|
340
343
|
this.setPointersPositions(evt);
|
|
341
344
|
var targetShape = this._getTargetShape(eventType);
|
|
342
|
-
var eventsEnabled = !DD.isDragging || Konva.hitOnDragEnabled;
|
|
345
|
+
var eventsEnabled = !DragAndDrop_1.DD.isDragging || Global_1.Konva.hitOnDragEnabled;
|
|
343
346
|
if (targetShape && eventsEnabled) {
|
|
344
347
|
targetShape._fireAndBubble(events.pointerout, { evt: evt });
|
|
345
348
|
targetShape._fireAndBubble(events.pointerleave, { evt: evt });
|
|
@@ -375,13 +378,13 @@ export class Stage extends Container {
|
|
|
375
378
|
var triggeredOnShape = false;
|
|
376
379
|
this._changedPointerPositions.forEach((pos) => {
|
|
377
380
|
var shape = this.getIntersection(pos);
|
|
378
|
-
DD.justDragged = false;
|
|
379
|
-
Konva['_' + eventType + 'ListenClick'] = true;
|
|
381
|
+
DragAndDrop_1.DD.justDragged = false;
|
|
382
|
+
Global_1.Konva['_' + eventType + 'ListenClick'] = true;
|
|
380
383
|
const hasShape = shape && shape.isListening();
|
|
381
384
|
if (!hasShape) {
|
|
382
385
|
return;
|
|
383
386
|
}
|
|
384
|
-
if (Konva.capturePointerEventsEnabled) {
|
|
387
|
+
if (Global_1.Konva.capturePointerEventsEnabled) {
|
|
385
388
|
shape.setPointerCapture(pos.id);
|
|
386
389
|
}
|
|
387
390
|
this[eventType + 'ClickStartShape'] = shape;
|
|
@@ -410,11 +413,11 @@ export class Stage extends Container {
|
|
|
410
413
|
if (!events) {
|
|
411
414
|
return;
|
|
412
415
|
}
|
|
413
|
-
if (DD.isDragging && DD.node.preventDefault() && evt.cancelable) {
|
|
416
|
+
if (DragAndDrop_1.DD.isDragging && DragAndDrop_1.DD.node.preventDefault() && evt.cancelable) {
|
|
414
417
|
evt.preventDefault();
|
|
415
418
|
}
|
|
416
419
|
this.setPointersPositions(evt);
|
|
417
|
-
var eventsEnabled = !DD.isDragging || Konva.hitOnDragEnabled;
|
|
420
|
+
var eventsEnabled = !DragAndDrop_1.DD.isDragging || Global_1.Konva.hitOnDragEnabled;
|
|
418
421
|
if (!eventsEnabled) {
|
|
419
422
|
return;
|
|
420
423
|
}
|
|
@@ -491,22 +494,22 @@ export class Stage extends Container {
|
|
|
491
494
|
const pointerId = pos.id;
|
|
492
495
|
const event = { evt: evt, pointerId };
|
|
493
496
|
let fireDblClick = false;
|
|
494
|
-
if (Konva['_' + eventType + 'InDblClickWindow']) {
|
|
497
|
+
if (Global_1.Konva['_' + eventType + 'InDblClickWindow']) {
|
|
495
498
|
fireDblClick = true;
|
|
496
499
|
clearTimeout(this[eventType + 'DblTimeout']);
|
|
497
500
|
}
|
|
498
|
-
else if (!DD.justDragged) {
|
|
499
|
-
Konva['_' + eventType + 'InDblClickWindow'] = true;
|
|
501
|
+
else if (!DragAndDrop_1.DD.justDragged) {
|
|
502
|
+
Global_1.Konva['_' + eventType + 'InDblClickWindow'] = true;
|
|
500
503
|
clearTimeout(this[eventType + 'DblTimeout']);
|
|
501
504
|
}
|
|
502
505
|
this[eventType + 'DblTimeout'] = setTimeout(function () {
|
|
503
|
-
Konva['_' + eventType + 'InDblClickWindow'] = false;
|
|
504
|
-
}, Konva.dblClickWindow);
|
|
506
|
+
Global_1.Konva['_' + eventType + 'InDblClickWindow'] = false;
|
|
507
|
+
}, Global_1.Konva.dblClickWindow);
|
|
505
508
|
if (shape && shape.isListening()) {
|
|
506
509
|
triggeredOnShape = true;
|
|
507
510
|
this[eventType + 'ClickEndShape'] = shape;
|
|
508
511
|
shape._fireAndBubble(events.pointerup, Object.assign({}, event));
|
|
509
|
-
if (Konva['_' + eventType + 'ListenClick'] &&
|
|
512
|
+
if (Global_1.Konva['_' + eventType + 'ListenClick'] &&
|
|
510
513
|
clickStartShape &&
|
|
511
514
|
clickStartShape === shape) {
|
|
512
515
|
shape._fireAndBubble(events.pointerclick, Object.assign({}, event));
|
|
@@ -517,7 +520,7 @@ export class Stage extends Container {
|
|
|
517
520
|
}
|
|
518
521
|
else {
|
|
519
522
|
this[eventType + 'ClickEndShape'] = null;
|
|
520
|
-
if (Konva['_' + eventType + 'ListenClick']) {
|
|
523
|
+
if (Global_1.Konva['_' + eventType + 'ListenClick']) {
|
|
521
524
|
this._fire(events.pointerclick, {
|
|
522
525
|
evt: evt,
|
|
523
526
|
target: this,
|
|
@@ -543,7 +546,7 @@ export class Stage extends Container {
|
|
|
543
546
|
pointerId: this._changedPointerPositions[0].id,
|
|
544
547
|
});
|
|
545
548
|
}
|
|
546
|
-
Konva['_' + eventType + 'ListenClick'] = false;
|
|
549
|
+
Global_1.Konva['_' + eventType + 'ListenClick'] = false;
|
|
547
550
|
if (evt.cancelable && eventType !== 'touch') {
|
|
548
551
|
evt.preventDefault();
|
|
549
552
|
}
|
|
@@ -616,14 +619,14 @@ export class Stage extends Container {
|
|
|
616
619
|
x: x,
|
|
617
620
|
y: y,
|
|
618
621
|
};
|
|
619
|
-
this._pointerPositions = [{ x, y, id: Util._getFirstPointerId(evt) }];
|
|
622
|
+
this._pointerPositions = [{ x, y, id: Util_1.Util._getFirstPointerId(evt) }];
|
|
620
623
|
this._changedPointerPositions = [
|
|
621
|
-
{ x, y, id: Util._getFirstPointerId(evt) },
|
|
624
|
+
{ x, y, id: Util_1.Util._getFirstPointerId(evt) },
|
|
622
625
|
];
|
|
623
626
|
}
|
|
624
627
|
}
|
|
625
628
|
_setPointerPosition(evt) {
|
|
626
|
-
Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.');
|
|
629
|
+
Util_1.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.');
|
|
627
630
|
this.setPointersPositions(evt);
|
|
628
631
|
}
|
|
629
632
|
_getContentPosition() {
|
|
@@ -644,16 +647,16 @@ export class Stage extends Container {
|
|
|
644
647
|
};
|
|
645
648
|
}
|
|
646
649
|
_buildDOM() {
|
|
647
|
-
this.bufferCanvas = new SceneCanvas({
|
|
650
|
+
this.bufferCanvas = new Canvas_1.SceneCanvas({
|
|
648
651
|
width: this.width(),
|
|
649
652
|
height: this.height(),
|
|
650
653
|
});
|
|
651
|
-
this.bufferHitCanvas = new HitCanvas({
|
|
654
|
+
this.bufferHitCanvas = new Canvas_1.HitCanvas({
|
|
652
655
|
pixelRatio: 1,
|
|
653
656
|
width: this.width(),
|
|
654
657
|
height: this.height(),
|
|
655
658
|
});
|
|
656
|
-
if (!Konva.isBrowser) {
|
|
659
|
+
if (!Global_1.Konva.isBrowser) {
|
|
657
660
|
return;
|
|
658
661
|
}
|
|
659
662
|
var container = this.container();
|
|
@@ -670,7 +673,7 @@ export class Stage extends Container {
|
|
|
670
673
|
this._resizeDOM();
|
|
671
674
|
}
|
|
672
675
|
cache() {
|
|
673
|
-
Util.warn('Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.');
|
|
676
|
+
Util_1.Util.warn('Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.');
|
|
674
677
|
return this;
|
|
675
678
|
}
|
|
676
679
|
clearCache() {
|
|
@@ -683,6 +686,7 @@ export class Stage extends Container {
|
|
|
683
686
|
return this;
|
|
684
687
|
}
|
|
685
688
|
}
|
|
689
|
+
exports.Stage = Stage;
|
|
686
690
|
Stage.prototype.nodeType = STAGE;
|
|
687
|
-
_registerNode(Stage);
|
|
688
|
-
Factory.addGetterSetter(Stage, 'container');
|
|
691
|
+
(0, Global_2._registerNode)(Stage);
|
|
692
|
+
Factory_1.Factory.addGetterSetter(Stage, 'container');
|