@leafer/core 1.0.0-rc.22 → 1.0.0-rc.23
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/lib/core.cjs +163 -110
- package/lib/core.esm.js +163 -111
- package/lib/core.esm.min.js +1 -1
- package/lib/core.min.cjs +1 -1
- package/package.json +18 -18
package/lib/core.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const Platform = {
|
|
|
5
5
|
hitCanvasSize: 100,
|
|
6
6
|
maxCacheSize: 2560 * 1600,
|
|
7
7
|
maxPatternSize: 4096 * 2160,
|
|
8
|
-
suffix: '
|
|
8
|
+
suffix: '',
|
|
9
9
|
crossOrigin: 'anonymous'
|
|
10
10
|
}
|
|
11
11
|
};
|
|
@@ -35,24 +35,12 @@ const I$1 = IncrementId;
|
|
|
35
35
|
const { round, pow: pow$1, PI: PI$2 } = Math;
|
|
36
36
|
const MathHelper = {
|
|
37
37
|
within(value, min, max) {
|
|
38
|
-
if (value < min)
|
|
38
|
+
if (min !== undefined && value < min)
|
|
39
39
|
value = min;
|
|
40
|
-
if (value > max)
|
|
40
|
+
if (max !== undefined && value > max)
|
|
41
41
|
value = max;
|
|
42
42
|
return value;
|
|
43
43
|
},
|
|
44
|
-
minus(value, isFourNumber) {
|
|
45
|
-
if (value instanceof Array) {
|
|
46
|
-
if (isFourNumber)
|
|
47
|
-
value = MathHelper.fourNumber(value, 0);
|
|
48
|
-
for (let i = 0; i < value.length; i++)
|
|
49
|
-
value[i] = -value[i];
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
value = -value;
|
|
53
|
-
}
|
|
54
|
-
return value;
|
|
55
|
-
},
|
|
56
44
|
fourNumber(num, maxValue) {
|
|
57
45
|
let data;
|
|
58
46
|
if (num instanceof Array) {
|
|
@@ -149,9 +137,11 @@ const MatrixHelper = {
|
|
|
149
137
|
t.e += x;
|
|
150
138
|
t.f += y;
|
|
151
139
|
},
|
|
152
|
-
translateInner(t, x, y) {
|
|
140
|
+
translateInner(t, x, y, isMoveOrigin) {
|
|
153
141
|
t.e += t.a * x + t.c * y;
|
|
154
142
|
t.f += t.b * x + t.d * y;
|
|
143
|
+
if (isMoveOrigin)
|
|
144
|
+
t.e -= x, t.f -= y;
|
|
155
145
|
},
|
|
156
146
|
scale(t, scaleX, scaleY = scaleX) {
|
|
157
147
|
t.a *= scaleX;
|
|
@@ -218,8 +208,10 @@ const MatrixHelper = {
|
|
|
218
208
|
t.e = child.e * a + child.f * c + e;
|
|
219
209
|
t.f = child.e * b + child.f * d + f;
|
|
220
210
|
},
|
|
221
|
-
multiplyParent(t, parent, to, abcdChanged, childScaleData) {
|
|
222
|
-
|
|
211
|
+
multiplyParent(t, parent, to, abcdChanged, childScaleData, scrollData) {
|
|
212
|
+
let { e, f } = t;
|
|
213
|
+
if (scrollData)
|
|
214
|
+
e += scrollData.scrollX, f += scrollData.scrollY;
|
|
223
215
|
to || (to = t);
|
|
224
216
|
if (abcdChanged === undefined)
|
|
225
217
|
abcdChanged = t.a !== 1 || t.b || t.c || t.d !== 1;
|
|
@@ -340,7 +332,7 @@ const MatrixHelper = {
|
|
|
340
332
|
t.e = x;
|
|
341
333
|
t.f = y;
|
|
342
334
|
if (origin)
|
|
343
|
-
M$6.translateInner(t, -origin.x, -origin.y);
|
|
335
|
+
M$6.translateInner(t, -origin.x, -origin.y, true);
|
|
344
336
|
},
|
|
345
337
|
getLayout(t, origin, firstSkewY) {
|
|
346
338
|
const { a, b, c, d, e, f } = t;
|
|
@@ -760,7 +752,7 @@ const { float, fourNumber } = MathHelper;
|
|
|
760
752
|
const { floor, ceil: ceil$1 } = Math;
|
|
761
753
|
let right, bottom, boundsRight, boundsBottom;
|
|
762
754
|
const point = {};
|
|
763
|
-
const toPoint$
|
|
755
|
+
const toPoint$2 = {};
|
|
764
756
|
const BoundsHelper = {
|
|
765
757
|
tempBounds: {},
|
|
766
758
|
set(t, x = 0, y = 0, width = 0, height = 0) {
|
|
@@ -775,15 +767,17 @@ const BoundsHelper = {
|
|
|
775
767
|
t.width = bounds.width;
|
|
776
768
|
t.height = bounds.height;
|
|
777
769
|
},
|
|
778
|
-
copyAndSpread(t, bounds,
|
|
779
|
-
if (
|
|
780
|
-
const four = fourNumber(
|
|
781
|
-
|
|
770
|
+
copyAndSpread(t, bounds, spread, isShrink) {
|
|
771
|
+
if (spread instanceof Array) {
|
|
772
|
+
const four = fourNumber(spread);
|
|
773
|
+
isShrink
|
|
774
|
+
? B.set(t, bounds.x + four[3], bounds.y + four[0], bounds.width - four[1] - four[3], bounds.height - four[2] - four[0])
|
|
775
|
+
: B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0]);
|
|
782
776
|
}
|
|
783
777
|
else {
|
|
784
|
-
if (
|
|
785
|
-
|
|
786
|
-
B.set(t, bounds.x -
|
|
778
|
+
if (isShrink)
|
|
779
|
+
spread = -spread;
|
|
780
|
+
B.set(t, bounds.x - spread, bounds.y - spread, bounds.width + spread * 2, bounds.height + spread * 2);
|
|
787
781
|
}
|
|
788
782
|
},
|
|
789
783
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -860,17 +854,17 @@ const BoundsHelper = {
|
|
|
860
854
|
else {
|
|
861
855
|
point.x = t.x;
|
|
862
856
|
point.y = t.y;
|
|
863
|
-
toOuterPoint$1(matrix, point, toPoint$
|
|
864
|
-
setPoint$2(tempPointBounds$1, toPoint$
|
|
857
|
+
toOuterPoint$1(matrix, point, toPoint$2);
|
|
858
|
+
setPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
|
|
865
859
|
point.x = t.x + t.width;
|
|
866
|
-
toOuterPoint$1(matrix, point, toPoint$
|
|
867
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
860
|
+
toOuterPoint$1(matrix, point, toPoint$2);
|
|
861
|
+
addPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
|
|
868
862
|
point.y = t.y + t.height;
|
|
869
|
-
toOuterPoint$1(matrix, point, toPoint$
|
|
870
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
863
|
+
toOuterPoint$1(matrix, point, toPoint$2);
|
|
864
|
+
addPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
|
|
871
865
|
point.x = t.x;
|
|
872
|
-
toOuterPoint$1(matrix, point, toPoint$
|
|
873
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
866
|
+
toOuterPoint$1(matrix, point, toPoint$2);
|
|
867
|
+
addPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
|
|
874
868
|
toBounds$2(tempPointBounds$1, to);
|
|
875
869
|
}
|
|
876
870
|
},
|
|
@@ -883,13 +877,16 @@ const BoundsHelper = {
|
|
|
883
877
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
884
878
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
885
879
|
},
|
|
886
|
-
getSpread(t,
|
|
880
|
+
getSpread(t, spread) {
|
|
887
881
|
const n = {};
|
|
888
|
-
B.copyAndSpread(n, t,
|
|
882
|
+
B.copyAndSpread(n, t, spread);
|
|
889
883
|
return n;
|
|
890
884
|
},
|
|
891
|
-
spread(t,
|
|
892
|
-
B.copyAndSpread(t, t,
|
|
885
|
+
spread(t, spread) {
|
|
886
|
+
B.copyAndSpread(t, t, spread);
|
|
887
|
+
},
|
|
888
|
+
shrink(t, shrink) {
|
|
889
|
+
B.copyAndSpread(t, t, shrink, true);
|
|
893
890
|
},
|
|
894
891
|
ceil(t) {
|
|
895
892
|
const { x, y } = t;
|
|
@@ -1069,12 +1066,12 @@ class Bounds {
|
|
|
1069
1066
|
getFitMatrix(put, baseScale) {
|
|
1070
1067
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1071
1068
|
}
|
|
1072
|
-
spread(fourNumber
|
|
1073
|
-
BoundsHelper.spread(this, fourNumber
|
|
1069
|
+
spread(fourNumber) {
|
|
1070
|
+
BoundsHelper.spread(this, fourNumber);
|
|
1074
1071
|
return this;
|
|
1075
1072
|
}
|
|
1076
1073
|
shrink(fourNumber) {
|
|
1077
|
-
BoundsHelper.
|
|
1074
|
+
BoundsHelper.shrink(this, fourNumber);
|
|
1078
1075
|
return this;
|
|
1079
1076
|
}
|
|
1080
1077
|
ceil() {
|
|
@@ -1191,6 +1188,10 @@ exports.Direction9 = void 0;
|
|
|
1191
1188
|
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
1192
1189
|
Direction9[Direction9["left"] = 7] = "left";
|
|
1193
1190
|
Direction9[Direction9["center"] = 8] = "center";
|
|
1191
|
+
Direction9[Direction9["top-left"] = 0] = "top-left";
|
|
1192
|
+
Direction9[Direction9["top-right"] = 2] = "top-right";
|
|
1193
|
+
Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
|
|
1194
|
+
Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
|
|
1194
1195
|
})(exports.Direction9 || (exports.Direction9 = {}));
|
|
1195
1196
|
|
|
1196
1197
|
const directionData = [
|
|
@@ -1204,6 +1205,7 @@ const directionData = [
|
|
|
1204
1205
|
{ x: 0, y: 0.5 },
|
|
1205
1206
|
{ x: 0.5, y: 0.5 }
|
|
1206
1207
|
];
|
|
1208
|
+
directionData.forEach(item => item.type = 'percent');
|
|
1207
1209
|
const AroundHelper = {
|
|
1208
1210
|
directionData,
|
|
1209
1211
|
tempPoint: {},
|
|
@@ -1211,15 +1213,19 @@ const AroundHelper = {
|
|
|
1211
1213
|
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1212
1214
|
to || (to = {});
|
|
1213
1215
|
const point = get(around);
|
|
1214
|
-
to.x = point.x
|
|
1215
|
-
to.y = point.y
|
|
1216
|
-
if (
|
|
1217
|
-
to.x
|
|
1218
|
-
to.y
|
|
1219
|
-
if (
|
|
1220
|
-
to.x -=
|
|
1221
|
-
|
|
1222
|
-
|
|
1216
|
+
to.x = point.x;
|
|
1217
|
+
to.y = point.y;
|
|
1218
|
+
if (point.type === 'percent') {
|
|
1219
|
+
to.x *= bounds.width;
|
|
1220
|
+
to.y *= bounds.height;
|
|
1221
|
+
if (pointBounds) {
|
|
1222
|
+
to.x -= pointBounds.x;
|
|
1223
|
+
to.y -= pointBounds.y;
|
|
1224
|
+
if (point.x)
|
|
1225
|
+
to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
|
|
1226
|
+
if (point.y)
|
|
1227
|
+
to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
|
|
1228
|
+
}
|
|
1223
1229
|
}
|
|
1224
1230
|
if (!onlySize) {
|
|
1225
1231
|
to.x += bounds.x;
|
|
@@ -1231,6 +1237,13 @@ function get(around) {
|
|
|
1231
1237
|
return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
|
|
1232
1238
|
}
|
|
1233
1239
|
|
|
1240
|
+
const { toPoint: toPoint$1 } = AroundHelper;
|
|
1241
|
+
const AlignHelper = {
|
|
1242
|
+
toPoint(align, contentBounds, bounds, to, onlySize) {
|
|
1243
|
+
toPoint$1(align, bounds, to, onlySize, contentBounds);
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
|
|
1234
1247
|
const StringNumberMap = {
|
|
1235
1248
|
'0': 1,
|
|
1236
1249
|
'1': 1,
|
|
@@ -1463,13 +1476,19 @@ const DataHelper = {
|
|
|
1463
1476
|
},
|
|
1464
1477
|
clone(data) {
|
|
1465
1478
|
return JSON.parse(JSON.stringify(data));
|
|
1479
|
+
},
|
|
1480
|
+
toMap(list) {
|
|
1481
|
+
const map = {};
|
|
1482
|
+
for (let i = 0, len = list.length; i < len; i++)
|
|
1483
|
+
map[list[i]] = true;
|
|
1484
|
+
return map;
|
|
1466
1485
|
}
|
|
1467
1486
|
};
|
|
1468
1487
|
const { assign } = DataHelper;
|
|
1469
1488
|
|
|
1470
1489
|
class LeafData {
|
|
1471
1490
|
get __blendMode() {
|
|
1472
|
-
if (this.eraser)
|
|
1491
|
+
if (this.eraser && this.eraser !== 'path')
|
|
1473
1492
|
return 'destination-out';
|
|
1474
1493
|
const { blendMode } = this;
|
|
1475
1494
|
return blendMode === 'pass-through' ? null : blendMode;
|
|
@@ -2099,7 +2118,7 @@ class LeaferCanvasBase extends Canvas {
|
|
|
2099
2118
|
}
|
|
2100
2119
|
clear() {
|
|
2101
2120
|
const { pixelRatio } = this;
|
|
2102
|
-
this.clearRect(0, 0, this.width * pixelRatio, this.height * pixelRatio);
|
|
2121
|
+
this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
|
|
2103
2122
|
}
|
|
2104
2123
|
isSameSize(size) {
|
|
2105
2124
|
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
@@ -3755,6 +3774,8 @@ function maskType(defaultValue) {
|
|
|
3755
3774
|
this.__setAttr(key, value);
|
|
3756
3775
|
this.__layout.boxChanged || this.__layout.boxChange();
|
|
3757
3776
|
this.waitParent(() => { this.parent.__updateMask(value); });
|
|
3777
|
+
if (typeof value === 'string')
|
|
3778
|
+
this.maskType = value;
|
|
3758
3779
|
}
|
|
3759
3780
|
}));
|
|
3760
3781
|
}
|
|
@@ -4184,11 +4205,19 @@ const WaitHelper = {
|
|
|
4184
4205
|
|
|
4185
4206
|
const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
|
|
4186
4207
|
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$2 } = BoundsHelper;
|
|
4208
|
+
const localContent = '_localContentBounds';
|
|
4209
|
+
const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
|
|
4187
4210
|
class LeafLayout {
|
|
4211
|
+
get contentBounds() { return this._contentBounds || this.boxBounds; }
|
|
4212
|
+
set contentBounds(bounds) { this._contentBounds = bounds; }
|
|
4188
4213
|
get strokeBounds() { return this._strokeBounds || this.boxBounds; }
|
|
4189
4214
|
get renderBounds() { return this._renderBounds || this.boxBounds; }
|
|
4215
|
+
get localContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {})); return this[localContent]; }
|
|
4190
4216
|
get localStrokeBounds() { return this._localStrokeBounds || this; }
|
|
4191
4217
|
get localRenderBounds() { return this._localRenderBounds || this; }
|
|
4218
|
+
get worldContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {})); return this[worldContent]; }
|
|
4219
|
+
get worldBoxBounds() { toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {})); return this[worldBox]; }
|
|
4220
|
+
get worldStrokeBounds() { toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {})); return this[worldStroke]; }
|
|
4192
4221
|
get a() { return 1; }
|
|
4193
4222
|
get b() { return 0; }
|
|
4194
4223
|
get c() { return 0; }
|
|
@@ -4271,7 +4300,6 @@ class LeafLayout {
|
|
|
4271
4300
|
case 'content':
|
|
4272
4301
|
if (this.contentBounds)
|
|
4273
4302
|
return this.contentBounds;
|
|
4274
|
-
case 'margin':
|
|
4275
4303
|
case 'box':
|
|
4276
4304
|
return this.boxBounds;
|
|
4277
4305
|
case 'stroke':
|
|
@@ -4284,8 +4312,9 @@ class LeafLayout {
|
|
|
4284
4312
|
return this.localRenderBounds;
|
|
4285
4313
|
case 'stroke':
|
|
4286
4314
|
return this.localStrokeBounds;
|
|
4287
|
-
case 'margin':
|
|
4288
4315
|
case 'content':
|
|
4316
|
+
if (this.contentBounds)
|
|
4317
|
+
return this.localContentBounds;
|
|
4289
4318
|
case 'box':
|
|
4290
4319
|
return this.leaf.__localBoxBounds;
|
|
4291
4320
|
}
|
|
@@ -4294,15 +4323,13 @@ class LeafLayout {
|
|
|
4294
4323
|
switch (type) {
|
|
4295
4324
|
case 'render':
|
|
4296
4325
|
return this.leaf.__world;
|
|
4326
|
+
case 'stroke':
|
|
4327
|
+
return this.worldStrokeBounds;
|
|
4297
4328
|
case 'content':
|
|
4298
4329
|
if (this.contentBounds)
|
|
4299
|
-
return this.
|
|
4300
|
-
case 'margin':
|
|
4330
|
+
return this.worldContentBounds;
|
|
4301
4331
|
case 'box':
|
|
4302
|
-
return this.
|
|
4303
|
-
case 'margin':
|
|
4304
|
-
case 'stroke':
|
|
4305
|
-
return this.getWorldStrokeBounds();
|
|
4332
|
+
return this.worldBoxBounds;
|
|
4306
4333
|
}
|
|
4307
4334
|
}
|
|
4308
4335
|
getLayoutBounds(type, relative = 'world', unscale) {
|
|
@@ -4365,20 +4392,24 @@ class LeafLayout {
|
|
|
4365
4392
|
points.forEach(point => leaf.innerToWorld(point, null, false, relativeLeaf));
|
|
4366
4393
|
return points;
|
|
4367
4394
|
}
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
return this._worldContentBounds;
|
|
4395
|
+
shrinkContent() {
|
|
4396
|
+
const { x, y, width, height } = this.boxBounds;
|
|
4397
|
+
this._contentBounds = { x, y, width, height };
|
|
4372
4398
|
}
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4399
|
+
spreadStroke() {
|
|
4400
|
+
const { x, y, width, height } = this.strokeBounds;
|
|
4401
|
+
this._strokeBounds = { x, y, width, height };
|
|
4402
|
+
this._localStrokeBounds = { x, y, width, height };
|
|
4403
|
+
if (!this.renderSpread)
|
|
4404
|
+
this.spreadRenderCancel();
|
|
4405
|
+
}
|
|
4406
|
+
spreadRender() {
|
|
4407
|
+
const { x, y, width, height } = this.renderBounds;
|
|
4408
|
+
this._renderBounds = { x, y, width, height };
|
|
4409
|
+
this._localRenderBounds = { x, y, width, height };
|
|
4377
4410
|
}
|
|
4378
|
-
|
|
4379
|
-
this.
|
|
4380
|
-
toOuterOf$2(this.strokeBounds, this.leaf.__world, this._worldStrokeBounds);
|
|
4381
|
-
return this._worldStrokeBounds;
|
|
4411
|
+
shrinkContentCancel() {
|
|
4412
|
+
this._contentBounds = undefined;
|
|
4382
4413
|
}
|
|
4383
4414
|
spreadStrokeCancel() {
|
|
4384
4415
|
const same = this.renderBounds === this.strokeBounds;
|
|
@@ -4391,18 +4422,6 @@ class LeafLayout {
|
|
|
4391
4422
|
this._renderBounds = this._strokeBounds;
|
|
4392
4423
|
this._localRenderBounds = this._localStrokeBounds;
|
|
4393
4424
|
}
|
|
4394
|
-
spreadStroke() {
|
|
4395
|
-
const { x, y, width, height } = this.strokeBounds;
|
|
4396
|
-
this._strokeBounds = { x, y, width, height };
|
|
4397
|
-
this._localStrokeBounds = { x, y, width, height };
|
|
4398
|
-
if (!this.renderSpread)
|
|
4399
|
-
this.spreadRenderCancel();
|
|
4400
|
-
}
|
|
4401
|
-
spreadRender() {
|
|
4402
|
-
const { x, y, width, height } = this.renderBounds;
|
|
4403
|
-
this._renderBounds = { x, y, width, height };
|
|
4404
|
-
this._localRenderBounds = { x, y, width, height };
|
|
4405
|
-
}
|
|
4406
4425
|
boxChange() {
|
|
4407
4426
|
this.boxChanged = true;
|
|
4408
4427
|
this.localBoxChanged || this.localBoxChange();
|
|
@@ -4489,24 +4508,40 @@ const LeafEventer = {
|
|
|
4489
4508
|
});
|
|
4490
4509
|
},
|
|
4491
4510
|
off(type, listener, options) {
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4511
|
+
if (type) {
|
|
4512
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4513
|
+
if (listener) {
|
|
4514
|
+
let capture;
|
|
4515
|
+
if (options)
|
|
4516
|
+
capture = typeof options === 'boolean' ? options : options.capture;
|
|
4517
|
+
let events, index;
|
|
4518
|
+
const map = __getListenerMap(this, capture);
|
|
4519
|
+
typeList.forEach(type => {
|
|
4520
|
+
if (type) {
|
|
4521
|
+
events = map[type];
|
|
4522
|
+
if (events) {
|
|
4523
|
+
index = events.findIndex(item => item.listener === listener);
|
|
4524
|
+
if (index > -1)
|
|
4525
|
+
events.splice(index, 1);
|
|
4526
|
+
if (!events.length)
|
|
4527
|
+
delete map[type];
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4530
|
+
});
|
|
4508
4531
|
}
|
|
4509
|
-
|
|
4532
|
+
else {
|
|
4533
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4534
|
+
typeList.forEach(type => {
|
|
4535
|
+
if (b)
|
|
4536
|
+
delete b[type];
|
|
4537
|
+
if (c)
|
|
4538
|
+
delete c[type];
|
|
4539
|
+
});
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
else {
|
|
4543
|
+
this.__bubbleMap = this.__captureMap = undefined;
|
|
4544
|
+
}
|
|
4510
4545
|
},
|
|
4511
4546
|
on_(type, listener, bind, options) {
|
|
4512
4547
|
if (bind)
|
|
@@ -4773,7 +4808,7 @@ const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorl
|
|
|
4773
4808
|
const { toPoint, tempPoint } = AroundHelper;
|
|
4774
4809
|
const LeafMatrix = {
|
|
4775
4810
|
__updateWorldMatrix() {
|
|
4776
|
-
multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
|
|
4811
|
+
multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
|
|
4777
4812
|
},
|
|
4778
4813
|
__updateLocalMatrix() {
|
|
4779
4814
|
if (this.__local) {
|
|
@@ -4784,11 +4819,11 @@ const LeafMatrix = {
|
|
|
4784
4819
|
layout.scaleChanged = layout.rotationChanged = false;
|
|
4785
4820
|
}
|
|
4786
4821
|
}
|
|
4787
|
-
local.e = data.x;
|
|
4788
|
-
local.f = data.y;
|
|
4789
|
-
if (data.around) {
|
|
4790
|
-
toPoint(data.around, layout.boxBounds, tempPoint);
|
|
4791
|
-
translateInner(local, -tempPoint.x, -tempPoint.y);
|
|
4822
|
+
local.e = data.x + data.offsetX;
|
|
4823
|
+
local.f = data.y + data.offsetY;
|
|
4824
|
+
if (data.around || data.origin) {
|
|
4825
|
+
toPoint(data.around || data.origin, layout.boxBounds, tempPoint);
|
|
4826
|
+
translateInner(local, -tempPoint.x, -tempPoint.y, data.origin);
|
|
4792
4827
|
}
|
|
4793
4828
|
}
|
|
4794
4829
|
this.__layout.matrixChanged = false;
|
|
@@ -4894,6 +4929,8 @@ const LeafBounds = {
|
|
|
4894
4929
|
if (this.isBranch) {
|
|
4895
4930
|
if (this.leafer)
|
|
4896
4931
|
this.leafer.layouter.addExtra(this);
|
|
4932
|
+
if (this.__.flow)
|
|
4933
|
+
this.__updateFlowLayout();
|
|
4897
4934
|
if (hasParentAutoLayout(this)) {
|
|
4898
4935
|
updateMatrix(this);
|
|
4899
4936
|
}
|
|
@@ -4926,6 +4963,8 @@ const LeafRender = {
|
|
|
4926
4963
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
4927
4964
|
canvas.opacity = this.__.opacity;
|
|
4928
4965
|
if (this.__.__single) {
|
|
4966
|
+
if (this.__.eraser === 'path')
|
|
4967
|
+
return this.__renderEraser(canvas, options);
|
|
4929
4968
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
4930
4969
|
this.__draw(tempCanvas, options);
|
|
4931
4970
|
if (this.__worldFlipped) {
|
|
@@ -4968,6 +5007,8 @@ const BranchRender = {
|
|
|
4968
5007
|
__render(canvas, options) {
|
|
4969
5008
|
if (this.__worldOpacity) {
|
|
4970
5009
|
if (this.__.__single) {
|
|
5010
|
+
if (this.__.eraser === 'path')
|
|
5011
|
+
return this.__renderEraser(canvas, options);
|
|
4971
5012
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
4972
5013
|
this.__renderBranch(tempCanvas, options);
|
|
4973
5014
|
const nowWorld = this.__getNowWorld(options);
|
|
@@ -5107,7 +5148,9 @@ exports.Leaf = class Leaf {
|
|
|
5107
5148
|
setProxyAttr(_attrName, _newValue) { }
|
|
5108
5149
|
getProxyAttr(_attrName) { return undefined; }
|
|
5109
5150
|
find(_condition, _options) { return undefined; }
|
|
5151
|
+
findTag(_tag) { return undefined; }
|
|
5110
5152
|
findOne(_condition, _options) { return undefined; }
|
|
5153
|
+
findId(_id) { return undefined; }
|
|
5111
5154
|
focus(_value) { }
|
|
5112
5155
|
forceUpdate(attrName) {
|
|
5113
5156
|
if (attrName === undefined)
|
|
@@ -5129,9 +5172,11 @@ exports.Leaf = class Leaf {
|
|
|
5129
5172
|
__updateLocalStrokeBounds() { }
|
|
5130
5173
|
__updateLocalRenderBounds() { }
|
|
5131
5174
|
__updateBoxBounds() { }
|
|
5175
|
+
__updateContentBounds() { }
|
|
5132
5176
|
__updateStrokeBounds() { }
|
|
5133
5177
|
__updateRenderBounds() { }
|
|
5134
5178
|
__updateAutoLayout() { }
|
|
5179
|
+
__updateFlowLayout() { }
|
|
5135
5180
|
__updateNaturalSize() { }
|
|
5136
5181
|
__updateStrokeSpread() { return 0; }
|
|
5137
5182
|
__updateRenderSpread() { return 0; }
|
|
@@ -5139,6 +5184,13 @@ exports.Leaf = class Leaf {
|
|
|
5139
5184
|
__updateEraser(value) {
|
|
5140
5185
|
this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
|
|
5141
5186
|
}
|
|
5187
|
+
__renderEraser(canvas, options) {
|
|
5188
|
+
canvas.save();
|
|
5189
|
+
this.__clip(canvas, options);
|
|
5190
|
+
const { renderBounds: r } = this.__layout;
|
|
5191
|
+
canvas.clearRect(r.x, r.y, r.width, r.height);
|
|
5192
|
+
canvas.restore();
|
|
5193
|
+
}
|
|
5142
5194
|
__updateMask(value) {
|
|
5143
5195
|
this.__hasMask = value ? true : this.children.some(item => item.__.mask);
|
|
5144
5196
|
}
|
|
@@ -5319,8 +5371,8 @@ exports.Leaf = class Leaf {
|
|
|
5319
5371
|
emit(_type, _event, _capture) { }
|
|
5320
5372
|
emitEvent(_event, _capture) { }
|
|
5321
5373
|
hasEvent(_type, _capture) { return false; }
|
|
5322
|
-
static changeAttr(attrName, defaultValue) {
|
|
5323
|
-
defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5374
|
+
static changeAttr(attrName, defaultValue, fn) {
|
|
5375
|
+
fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5324
5376
|
}
|
|
5325
5377
|
static addAttr(attrName, defaultValue, fn) {
|
|
5326
5378
|
if (!fn)
|
|
@@ -5634,6 +5686,7 @@ class LeafLevelList {
|
|
|
5634
5686
|
}
|
|
5635
5687
|
}
|
|
5636
5688
|
|
|
5689
|
+
exports.AlignHelper = AlignHelper;
|
|
5637
5690
|
exports.AnimateEvent = AnimateEvent;
|
|
5638
5691
|
exports.AroundHelper = AroundHelper;
|
|
5639
5692
|
exports.AutoBounds = AutoBounds;
|