@leafer/core 1.0.0-rc.21 → 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 +178 -108
- package/lib/core.esm.js +178 -109
- 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,15 +1205,28 @@ 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: {},
|
|
1210
1212
|
get,
|
|
1211
|
-
toPoint(around, bounds, to, onlySize) {
|
|
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
|
+
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
|
+
}
|
|
1229
|
+
}
|
|
1216
1230
|
if (!onlySize) {
|
|
1217
1231
|
to.x += bounds.x;
|
|
1218
1232
|
to.y += bounds.y;
|
|
@@ -1223,6 +1237,13 @@ function get(around) {
|
|
|
1223
1237
|
return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
|
|
1224
1238
|
}
|
|
1225
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
|
+
|
|
1226
1247
|
const StringNumberMap = {
|
|
1227
1248
|
'0': 1,
|
|
1228
1249
|
'1': 1,
|
|
@@ -1455,13 +1476,19 @@ const DataHelper = {
|
|
|
1455
1476
|
},
|
|
1456
1477
|
clone(data) {
|
|
1457
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;
|
|
1458
1485
|
}
|
|
1459
1486
|
};
|
|
1460
1487
|
const { assign } = DataHelper;
|
|
1461
1488
|
|
|
1462
1489
|
class LeafData {
|
|
1463
1490
|
get __blendMode() {
|
|
1464
|
-
if (this.eraser)
|
|
1491
|
+
if (this.eraser && this.eraser !== 'path')
|
|
1465
1492
|
return 'destination-out';
|
|
1466
1493
|
const { blendMode } = this;
|
|
1467
1494
|
return blendMode === 'pass-through' ? null : blendMode;
|
|
@@ -2091,7 +2118,7 @@ class LeaferCanvasBase extends Canvas {
|
|
|
2091
2118
|
}
|
|
2092
2119
|
clear() {
|
|
2093
2120
|
const { pixelRatio } = this;
|
|
2094
|
-
this.clearRect(0, 0, this.width * pixelRatio, this.height * pixelRatio);
|
|
2121
|
+
this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
|
|
2095
2122
|
}
|
|
2096
2123
|
isSameSize(size) {
|
|
2097
2124
|
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
@@ -3747,6 +3774,8 @@ function maskType(defaultValue) {
|
|
|
3747
3774
|
this.__setAttr(key, value);
|
|
3748
3775
|
this.__layout.boxChanged || this.__layout.boxChange();
|
|
3749
3776
|
this.waitParent(() => { this.parent.__updateMask(value); });
|
|
3777
|
+
if (typeof value === 'string')
|
|
3778
|
+
this.maskType = value;
|
|
3750
3779
|
}
|
|
3751
3780
|
}));
|
|
3752
3781
|
}
|
|
@@ -3958,15 +3987,21 @@ const LeafHelper = {
|
|
|
3958
3987
|
}
|
|
3959
3988
|
return true;
|
|
3960
3989
|
},
|
|
3961
|
-
moveWorld(t, x, y) {
|
|
3962
|
-
const local = { x, y };
|
|
3990
|
+
moveWorld(t, x, y = 0) {
|
|
3991
|
+
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
3963
3992
|
if (t.parent)
|
|
3964
3993
|
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
3965
3994
|
L.moveLocal(t, local.x, local.y);
|
|
3966
3995
|
},
|
|
3967
3996
|
moveLocal(t, x, y = 0) {
|
|
3968
|
-
|
|
3969
|
-
|
|
3997
|
+
if (typeof x === 'object') {
|
|
3998
|
+
t.x += x.x;
|
|
3999
|
+
t.y += x.y;
|
|
4000
|
+
}
|
|
4001
|
+
else {
|
|
4002
|
+
t.x += x;
|
|
4003
|
+
t.y += y;
|
|
4004
|
+
}
|
|
3970
4005
|
},
|
|
3971
4006
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
3972
4007
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -4170,11 +4205,19 @@ const WaitHelper = {
|
|
|
4170
4205
|
|
|
4171
4206
|
const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
|
|
4172
4207
|
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$2 } = BoundsHelper;
|
|
4208
|
+
const localContent = '_localContentBounds';
|
|
4209
|
+
const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
|
|
4173
4210
|
class LeafLayout {
|
|
4211
|
+
get contentBounds() { return this._contentBounds || this.boxBounds; }
|
|
4212
|
+
set contentBounds(bounds) { this._contentBounds = bounds; }
|
|
4174
4213
|
get strokeBounds() { return this._strokeBounds || this.boxBounds; }
|
|
4175
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]; }
|
|
4176
4216
|
get localStrokeBounds() { return this._localStrokeBounds || this; }
|
|
4177
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]; }
|
|
4178
4221
|
get a() { return 1; }
|
|
4179
4222
|
get b() { return 0; }
|
|
4180
4223
|
get c() { return 0; }
|
|
@@ -4257,7 +4300,6 @@ class LeafLayout {
|
|
|
4257
4300
|
case 'content':
|
|
4258
4301
|
if (this.contentBounds)
|
|
4259
4302
|
return this.contentBounds;
|
|
4260
|
-
case 'margin':
|
|
4261
4303
|
case 'box':
|
|
4262
4304
|
return this.boxBounds;
|
|
4263
4305
|
case 'stroke':
|
|
@@ -4270,8 +4312,9 @@ class LeafLayout {
|
|
|
4270
4312
|
return this.localRenderBounds;
|
|
4271
4313
|
case 'stroke':
|
|
4272
4314
|
return this.localStrokeBounds;
|
|
4273
|
-
case 'margin':
|
|
4274
4315
|
case 'content':
|
|
4316
|
+
if (this.contentBounds)
|
|
4317
|
+
return this.localContentBounds;
|
|
4275
4318
|
case 'box':
|
|
4276
4319
|
return this.leaf.__localBoxBounds;
|
|
4277
4320
|
}
|
|
@@ -4280,15 +4323,13 @@ class LeafLayout {
|
|
|
4280
4323
|
switch (type) {
|
|
4281
4324
|
case 'render':
|
|
4282
4325
|
return this.leaf.__world;
|
|
4326
|
+
case 'stroke':
|
|
4327
|
+
return this.worldStrokeBounds;
|
|
4283
4328
|
case 'content':
|
|
4284
4329
|
if (this.contentBounds)
|
|
4285
|
-
return this.
|
|
4286
|
-
case 'margin':
|
|
4330
|
+
return this.worldContentBounds;
|
|
4287
4331
|
case 'box':
|
|
4288
|
-
return this.
|
|
4289
|
-
case 'margin':
|
|
4290
|
-
case 'stroke':
|
|
4291
|
-
return this.getWorldStrokeBounds();
|
|
4332
|
+
return this.worldBoxBounds;
|
|
4292
4333
|
}
|
|
4293
4334
|
}
|
|
4294
4335
|
getLayoutBounds(type, relative = 'world', unscale) {
|
|
@@ -4351,20 +4392,24 @@ class LeafLayout {
|
|
|
4351
4392
|
points.forEach(point => leaf.innerToWorld(point, null, false, relativeLeaf));
|
|
4352
4393
|
return points;
|
|
4353
4394
|
}
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4395
|
+
shrinkContent() {
|
|
4396
|
+
const { x, y, width, height } = this.boxBounds;
|
|
4397
|
+
this._contentBounds = { x, y, width, height };
|
|
4398
|
+
}
|
|
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();
|
|
4358
4405
|
}
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4406
|
+
spreadRender() {
|
|
4407
|
+
const { x, y, width, height } = this.renderBounds;
|
|
4408
|
+
this._renderBounds = { x, y, width, height };
|
|
4409
|
+
this._localRenderBounds = { x, y, width, height };
|
|
4363
4410
|
}
|
|
4364
|
-
|
|
4365
|
-
this.
|
|
4366
|
-
toOuterOf$2(this.strokeBounds, this.leaf.__world, this._worldStrokeBounds);
|
|
4367
|
-
return this._worldStrokeBounds;
|
|
4411
|
+
shrinkContentCancel() {
|
|
4412
|
+
this._contentBounds = undefined;
|
|
4368
4413
|
}
|
|
4369
4414
|
spreadStrokeCancel() {
|
|
4370
4415
|
const same = this.renderBounds === this.strokeBounds;
|
|
@@ -4377,18 +4422,6 @@ class LeafLayout {
|
|
|
4377
4422
|
this._renderBounds = this._strokeBounds;
|
|
4378
4423
|
this._localRenderBounds = this._localStrokeBounds;
|
|
4379
4424
|
}
|
|
4380
|
-
spreadStroke() {
|
|
4381
|
-
const { x, y, width, height } = this.strokeBounds;
|
|
4382
|
-
this._strokeBounds = { x, y, width, height };
|
|
4383
|
-
this._localStrokeBounds = { x, y, width, height };
|
|
4384
|
-
if (!this.renderSpread)
|
|
4385
|
-
this.spreadRenderCancel();
|
|
4386
|
-
}
|
|
4387
|
-
spreadRender() {
|
|
4388
|
-
const { x, y, width, height } = this.renderBounds;
|
|
4389
|
-
this._renderBounds = { x, y, width, height };
|
|
4390
|
-
this._localRenderBounds = { x, y, width, height };
|
|
4391
|
-
}
|
|
4392
4425
|
boxChange() {
|
|
4393
4426
|
this.boxChanged = true;
|
|
4394
4427
|
this.localBoxChanged || this.localBoxChange();
|
|
@@ -4475,24 +4508,40 @@ const LeafEventer = {
|
|
|
4475
4508
|
});
|
|
4476
4509
|
},
|
|
4477
4510
|
off(type, listener, options) {
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
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
|
+
});
|
|
4494
4531
|
}
|
|
4495
|
-
|
|
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
|
+
}
|
|
4496
4545
|
},
|
|
4497
4546
|
on_(type, listener, bind, options) {
|
|
4498
4547
|
if (bind)
|
|
@@ -4528,12 +4577,15 @@ const LeafEventer = {
|
|
|
4528
4577
|
break;
|
|
4529
4578
|
}
|
|
4530
4579
|
}
|
|
4580
|
+
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4531
4581
|
},
|
|
4532
4582
|
emitEvent(event, capture) {
|
|
4533
4583
|
event.current = this;
|
|
4534
4584
|
this.emit(event.type, event, capture);
|
|
4535
4585
|
},
|
|
4536
4586
|
hasEvent(type, capture) {
|
|
4587
|
+
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4588
|
+
return true;
|
|
4537
4589
|
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4538
4590
|
const hasB = b && b[type], hasC = c && c[type];
|
|
4539
4591
|
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
@@ -4756,7 +4808,7 @@ const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorl
|
|
|
4756
4808
|
const { toPoint, tempPoint } = AroundHelper;
|
|
4757
4809
|
const LeafMatrix = {
|
|
4758
4810
|
__updateWorldMatrix() {
|
|
4759
|
-
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.__);
|
|
4760
4812
|
},
|
|
4761
4813
|
__updateLocalMatrix() {
|
|
4762
4814
|
if (this.__local) {
|
|
@@ -4767,11 +4819,11 @@ const LeafMatrix = {
|
|
|
4767
4819
|
layout.scaleChanged = layout.rotationChanged = false;
|
|
4768
4820
|
}
|
|
4769
4821
|
}
|
|
4770
|
-
local.e = data.x;
|
|
4771
|
-
local.f = data.y;
|
|
4772
|
-
if (data.around) {
|
|
4773
|
-
toPoint(data.around, layout.boxBounds, tempPoint);
|
|
4774
|
-
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);
|
|
4775
4827
|
}
|
|
4776
4828
|
}
|
|
4777
4829
|
this.__layout.matrixChanged = false;
|
|
@@ -4877,6 +4929,8 @@ const LeafBounds = {
|
|
|
4877
4929
|
if (this.isBranch) {
|
|
4878
4930
|
if (this.leafer)
|
|
4879
4931
|
this.leafer.layouter.addExtra(this);
|
|
4932
|
+
if (this.__.flow)
|
|
4933
|
+
this.__updateFlowLayout();
|
|
4880
4934
|
if (hasParentAutoLayout(this)) {
|
|
4881
4935
|
updateMatrix(this);
|
|
4882
4936
|
}
|
|
@@ -4909,6 +4963,8 @@ const LeafRender = {
|
|
|
4909
4963
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
4910
4964
|
canvas.opacity = this.__.opacity;
|
|
4911
4965
|
if (this.__.__single) {
|
|
4966
|
+
if (this.__.eraser === 'path')
|
|
4967
|
+
return this.__renderEraser(canvas, options);
|
|
4912
4968
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
4913
4969
|
this.__draw(tempCanvas, options);
|
|
4914
4970
|
if (this.__worldFlipped) {
|
|
@@ -4951,6 +5007,8 @@ const BranchRender = {
|
|
|
4951
5007
|
__render(canvas, options) {
|
|
4952
5008
|
if (this.__worldOpacity) {
|
|
4953
5009
|
if (this.__.__single) {
|
|
5010
|
+
if (this.__.eraser === 'path')
|
|
5011
|
+
return this.__renderEraser(canvas, options);
|
|
4954
5012
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
4955
5013
|
this.__renderBranch(tempCanvas, options);
|
|
4956
5014
|
const nowWorld = this.__getNowWorld(options);
|
|
@@ -5090,7 +5148,9 @@ exports.Leaf = class Leaf {
|
|
|
5090
5148
|
setProxyAttr(_attrName, _newValue) { }
|
|
5091
5149
|
getProxyAttr(_attrName) { return undefined; }
|
|
5092
5150
|
find(_condition, _options) { return undefined; }
|
|
5151
|
+
findTag(_tag) { return undefined; }
|
|
5093
5152
|
findOne(_condition, _options) { return undefined; }
|
|
5153
|
+
findId(_id) { return undefined; }
|
|
5094
5154
|
focus(_value) { }
|
|
5095
5155
|
forceUpdate(attrName) {
|
|
5096
5156
|
if (attrName === undefined)
|
|
@@ -5112,9 +5172,11 @@ exports.Leaf = class Leaf {
|
|
|
5112
5172
|
__updateLocalStrokeBounds() { }
|
|
5113
5173
|
__updateLocalRenderBounds() { }
|
|
5114
5174
|
__updateBoxBounds() { }
|
|
5175
|
+
__updateContentBounds() { }
|
|
5115
5176
|
__updateStrokeBounds() { }
|
|
5116
5177
|
__updateRenderBounds() { }
|
|
5117
5178
|
__updateAutoLayout() { }
|
|
5179
|
+
__updateFlowLayout() { }
|
|
5118
5180
|
__updateNaturalSize() { }
|
|
5119
5181
|
__updateStrokeSpread() { return 0; }
|
|
5120
5182
|
__updateRenderSpread() { return 0; }
|
|
@@ -5122,6 +5184,13 @@ exports.Leaf = class Leaf {
|
|
|
5122
5184
|
__updateEraser(value) {
|
|
5123
5185
|
this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
|
|
5124
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
|
+
}
|
|
5125
5194
|
__updateMask(value) {
|
|
5126
5195
|
this.__hasMask = value ? true : this.children.some(item => item.__.mask);
|
|
5127
5196
|
}
|
|
@@ -5302,8 +5371,8 @@ exports.Leaf = class Leaf {
|
|
|
5302
5371
|
emit(_type, _event, _capture) { }
|
|
5303
5372
|
emitEvent(_event, _capture) { }
|
|
5304
5373
|
hasEvent(_type, _capture) { return false; }
|
|
5305
|
-
static changeAttr(attrName, defaultValue) {
|
|
5306
|
-
defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5374
|
+
static changeAttr(attrName, defaultValue, fn) {
|
|
5375
|
+
fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5307
5376
|
}
|
|
5308
5377
|
static addAttr(attrName, defaultValue, fn) {
|
|
5309
5378
|
if (!fn)
|
|
@@ -5617,6 +5686,7 @@ class LeafLevelList {
|
|
|
5617
5686
|
}
|
|
5618
5687
|
}
|
|
5619
5688
|
|
|
5689
|
+
exports.AlignHelper = AlignHelper;
|
|
5620
5690
|
exports.AnimateEvent = AnimateEvent;
|
|
5621
5691
|
exports.AroundHelper = AroundHelper;
|
|
5622
5692
|
exports.AutoBounds = AutoBounds;
|