@leafer/core 1.0.1 → 1.0.3
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 +352 -223
- package/lib/core.esm.js +350 -222
- package/lib/core.esm.min.js +1 -1
- package/lib/core.min.cjs +1 -1
- package/package.json +17 -18
- package/src/index.ts +1 -4
- package/types/index.d.ts +2 -4
package/lib/core.cjs
CHANGED
|
@@ -113,6 +113,26 @@ const MathHelper = {
|
|
|
113
113
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
114
114
|
num = round(num * a) / a;
|
|
115
115
|
return num === -0 ? 0 : num;
|
|
116
|
+
},
|
|
117
|
+
getScaleData(scale, size, originSize, scaleData) {
|
|
118
|
+
if (!scaleData)
|
|
119
|
+
scaleData = {};
|
|
120
|
+
if (size) {
|
|
121
|
+
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
122
|
+
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
123
|
+
}
|
|
124
|
+
else if (scale)
|
|
125
|
+
MathHelper.assignScale(scaleData, scale);
|
|
126
|
+
return scaleData;
|
|
127
|
+
},
|
|
128
|
+
assignScale(scaleData, scale) {
|
|
129
|
+
if (typeof scale === 'number') {
|
|
130
|
+
scaleData.scaleX = scaleData.scaleY = scale;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
scaleData.scaleX = scale.x;
|
|
134
|
+
scaleData.scaleY = scale.y;
|
|
135
|
+
}
|
|
116
136
|
}
|
|
117
137
|
};
|
|
118
138
|
const OneRadian = PI$2 / 180;
|
|
@@ -411,7 +431,7 @@ const MatrixHelper = {
|
|
|
411
431
|
};
|
|
412
432
|
const M$6 = MatrixHelper;
|
|
413
433
|
|
|
414
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
434
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
415
435
|
const { sin: sin$2, cos: cos$2, abs: abs$2, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$1 } = Math;
|
|
416
436
|
const PointHelper = {
|
|
417
437
|
defaultPoint: getPointData(),
|
|
@@ -467,7 +487,7 @@ const PointHelper = {
|
|
|
467
487
|
tempToOuterOf(t, matrix) {
|
|
468
488
|
const { tempPoint: temp } = P$5;
|
|
469
489
|
copy$7(temp, t);
|
|
470
|
-
toOuterPoint$
|
|
490
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
471
491
|
return temp;
|
|
472
492
|
},
|
|
473
493
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -486,7 +506,7 @@ const PointHelper = {
|
|
|
486
506
|
toInnerPoint$2(matrix, t, to);
|
|
487
507
|
},
|
|
488
508
|
toOuterOf(t, matrix, to) {
|
|
489
|
-
toOuterPoint$
|
|
509
|
+
toOuterPoint$3(matrix, t, to);
|
|
490
510
|
},
|
|
491
511
|
getCenter(t, to) {
|
|
492
512
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -766,7 +786,7 @@ const TwoPointBoundsHelper = {
|
|
|
766
786
|
const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
|
|
767
787
|
|
|
768
788
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2 } = TwoPointBoundsHelper;
|
|
769
|
-
const { toOuterPoint: toOuterPoint$
|
|
789
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
770
790
|
const { float, fourNumber } = MathHelper;
|
|
771
791
|
const { floor, ceil: ceil$1 } = Math;
|
|
772
792
|
let right, bottom, boundsRight, boundsBottom;
|
|
@@ -786,17 +806,24 @@ const BoundsHelper = {
|
|
|
786
806
|
t.width = bounds.width;
|
|
787
807
|
t.height = bounds.height;
|
|
788
808
|
},
|
|
789
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
809
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
810
|
+
const { x, y, width, height } = bounds;
|
|
790
811
|
if (spread instanceof Array) {
|
|
791
812
|
const four = fourNumber(spread);
|
|
792
813
|
isShrink
|
|
793
|
-
? B.set(t,
|
|
794
|
-
: B.set(t,
|
|
814
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
815
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
795
816
|
}
|
|
796
817
|
else {
|
|
797
818
|
if (isShrink)
|
|
798
819
|
spread = -spread;
|
|
799
|
-
B.set(t,
|
|
820
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
821
|
+
}
|
|
822
|
+
if (side) {
|
|
823
|
+
if (side === 'width')
|
|
824
|
+
t.y = y, t.height = height;
|
|
825
|
+
else
|
|
826
|
+
t.x = x, t.width = width;
|
|
800
827
|
}
|
|
801
828
|
},
|
|
802
829
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -873,16 +900,16 @@ const BoundsHelper = {
|
|
|
873
900
|
else {
|
|
874
901
|
point.x = t.x;
|
|
875
902
|
point.y = t.y;
|
|
876
|
-
toOuterPoint$
|
|
903
|
+
toOuterPoint$2(matrix, point, toPoint$2);
|
|
877
904
|
setPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
|
|
878
905
|
point.x = t.x + t.width;
|
|
879
|
-
toOuterPoint$
|
|
906
|
+
toOuterPoint$2(matrix, point, toPoint$2);
|
|
880
907
|
addPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
|
|
881
908
|
point.y = t.y + t.height;
|
|
882
|
-
toOuterPoint$
|
|
909
|
+
toOuterPoint$2(matrix, point, toPoint$2);
|
|
883
910
|
addPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
|
|
884
911
|
point.x = t.x;
|
|
885
|
-
toOuterPoint$
|
|
912
|
+
toOuterPoint$2(matrix, point, toPoint$2);
|
|
886
913
|
addPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
|
|
887
914
|
toBounds$2(tempPointBounds$1, to);
|
|
888
915
|
}
|
|
@@ -896,16 +923,16 @@ const BoundsHelper = {
|
|
|
896
923
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
897
924
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
898
925
|
},
|
|
899
|
-
getSpread(t, spread) {
|
|
926
|
+
getSpread(t, spread, side) {
|
|
900
927
|
const n = {};
|
|
901
|
-
B.copyAndSpread(n, t, spread);
|
|
928
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
902
929
|
return n;
|
|
903
930
|
},
|
|
904
|
-
spread(t, spread) {
|
|
905
|
-
B.copyAndSpread(t, t, spread);
|
|
931
|
+
spread(t, spread, side) {
|
|
932
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
906
933
|
},
|
|
907
|
-
shrink(t, shrink) {
|
|
908
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
934
|
+
shrink(t, shrink, side) {
|
|
935
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
909
936
|
},
|
|
910
937
|
ceil(t) {
|
|
911
938
|
const { x, y } = t;
|
|
@@ -1088,12 +1115,12 @@ class Bounds {
|
|
|
1088
1115
|
getFitMatrix(put, baseScale) {
|
|
1089
1116
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1090
1117
|
}
|
|
1091
|
-
spread(fourNumber) {
|
|
1092
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1118
|
+
spread(fourNumber, side) {
|
|
1119
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1093
1120
|
return this;
|
|
1094
1121
|
}
|
|
1095
|
-
shrink(fourNumber) {
|
|
1096
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1122
|
+
shrink(fourNumber, side) {
|
|
1123
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1097
1124
|
return this;
|
|
1098
1125
|
}
|
|
1099
1126
|
ceil() {
|
|
@@ -1237,7 +1264,6 @@ const AroundHelper = {
|
|
|
1237
1264
|
tempPoint: {},
|
|
1238
1265
|
get,
|
|
1239
1266
|
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1240
|
-
to || (to = {});
|
|
1241
1267
|
const point = get(around);
|
|
1242
1268
|
to.x = point.x;
|
|
1243
1269
|
to.y = point.y;
|
|
@@ -1372,6 +1398,10 @@ const Run = {
|
|
|
1372
1398
|
};
|
|
1373
1399
|
const R = Run;
|
|
1374
1400
|
|
|
1401
|
+
function needPlugin(name) {
|
|
1402
|
+
console.error('need plugin: @leafer-in/' + name);
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1375
1405
|
const debug$7 = Debug.get('UICreator');
|
|
1376
1406
|
const UICreator = {
|
|
1377
1407
|
list: {},
|
|
@@ -1634,6 +1664,9 @@ exports.Answer = void 0;
|
|
|
1634
1664
|
Answer[Answer["YesAndSkip"] = 3] = "YesAndSkip";
|
|
1635
1665
|
})(exports.Answer || (exports.Answer = {}));
|
|
1636
1666
|
const emptyData = {};
|
|
1667
|
+
function isNull(value) {
|
|
1668
|
+
return value === undefined || value === null;
|
|
1669
|
+
}
|
|
1637
1670
|
|
|
1638
1671
|
/******************************************************************************
|
|
1639
1672
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2399,7 +2432,7 @@ const BezierHelper = {
|
|
|
2399
2432
|
let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
|
|
2400
2433
|
let fromX = cx + x, fromY = cy + y;
|
|
2401
2434
|
if (data)
|
|
2402
|
-
data.push(L$6, fromX, fromY);
|
|
2435
|
+
data.push(data.length ? L$6 : M$5, fromX, fromY);
|
|
2403
2436
|
if (setPointBounds)
|
|
2404
2437
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
2405
2438
|
if (setStartPoint)
|
|
@@ -2910,60 +2943,75 @@ class PathCreator {
|
|
|
2910
2943
|
}
|
|
2911
2944
|
beginPath() {
|
|
2912
2945
|
beginPath(this.__path);
|
|
2946
|
+
this.paint();
|
|
2913
2947
|
return this;
|
|
2914
2948
|
}
|
|
2915
2949
|
moveTo(x, y) {
|
|
2916
2950
|
moveTo(this.__path, x, y);
|
|
2951
|
+
this.paint();
|
|
2917
2952
|
return this;
|
|
2918
2953
|
}
|
|
2919
2954
|
lineTo(x, y) {
|
|
2920
2955
|
lineTo(this.__path, x, y);
|
|
2956
|
+
this.paint();
|
|
2921
2957
|
return this;
|
|
2922
2958
|
}
|
|
2923
2959
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2924
2960
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2961
|
+
this.paint();
|
|
2925
2962
|
return this;
|
|
2926
2963
|
}
|
|
2927
2964
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2928
2965
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2966
|
+
this.paint();
|
|
2929
2967
|
return this;
|
|
2930
2968
|
}
|
|
2931
2969
|
closePath() {
|
|
2932
2970
|
closePath(this.__path);
|
|
2971
|
+
this.paint();
|
|
2933
2972
|
return this;
|
|
2934
2973
|
}
|
|
2935
2974
|
rect(x, y, width, height) {
|
|
2936
2975
|
rect(this.__path, x, y, width, height);
|
|
2976
|
+
this.paint();
|
|
2937
2977
|
return this;
|
|
2938
2978
|
}
|
|
2939
2979
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2940
2980
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2981
|
+
this.paint();
|
|
2941
2982
|
return this;
|
|
2942
2983
|
}
|
|
2943
2984
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2944
2985
|
ellipse$1(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2986
|
+
this.paint();
|
|
2945
2987
|
return this;
|
|
2946
2988
|
}
|
|
2947
2989
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2948
2990
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2991
|
+
this.paint();
|
|
2949
2992
|
return this;
|
|
2950
2993
|
}
|
|
2951
2994
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2952
2995
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2996
|
+
this.paint();
|
|
2953
2997
|
return this;
|
|
2954
2998
|
}
|
|
2955
2999
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2956
3000
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
3001
|
+
this.paint();
|
|
2957
3002
|
return this;
|
|
2958
3003
|
}
|
|
2959
3004
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2960
3005
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
3006
|
+
this.paint();
|
|
2961
3007
|
return this;
|
|
2962
3008
|
}
|
|
2963
3009
|
drawPoints(points, curve, close) {
|
|
2964
3010
|
drawPoints(this.__path, points, curve, close);
|
|
3011
|
+
this.paint();
|
|
2965
3012
|
return this;
|
|
2966
3013
|
}
|
|
3014
|
+
paint() { }
|
|
2967
3015
|
}
|
|
2968
3016
|
|
|
2969
3017
|
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
@@ -3053,8 +3101,7 @@ const PathBounds = {
|
|
|
3053
3101
|
toTwoPointBounds(data, setPointBounds) {
|
|
3054
3102
|
if (!data || !data.length)
|
|
3055
3103
|
return setPoint(setPointBounds, 0, 0);
|
|
3056
|
-
let command;
|
|
3057
|
-
let i = 0, x = 0, y = 0, x1, y1, toX, toY;
|
|
3104
|
+
let i = 0, x = 0, y = 0, x1, y1, toX, toY, command;
|
|
3058
3105
|
const len = data.length;
|
|
3059
3106
|
while (i < len) {
|
|
3060
3107
|
command = data[i];
|
|
@@ -3710,7 +3757,7 @@ function autoLayoutType(defaultValue) {
|
|
|
3710
3757
|
set(value) {
|
|
3711
3758
|
if (this.__setAttr(key, value)) {
|
|
3712
3759
|
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3713
|
-
this.__hasAutoLayout = !!
|
|
3760
|
+
this.__hasAutoLayout = !!(this.origin || this.around || this.flow);
|
|
3714
3761
|
if (!this.__local)
|
|
3715
3762
|
this.__layout.createLocal();
|
|
3716
3763
|
}
|
|
@@ -3803,14 +3850,25 @@ function visibleType(defaultValue) {
|
|
|
3803
3850
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3804
3851
|
set(value) {
|
|
3805
3852
|
const oldValue = this.visible;
|
|
3806
|
-
if (
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3853
|
+
if (oldValue === true && value === 0) {
|
|
3854
|
+
if (this.animationOut)
|
|
3855
|
+
return this.__runAnimation('out', () => doVisible(this, key, value, oldValue));
|
|
3856
|
+
}
|
|
3857
|
+
else if (oldValue === 0 && value === true) {
|
|
3858
|
+
if (this.animation)
|
|
3859
|
+
this.__runAnimation('in');
|
|
3810
3860
|
}
|
|
3861
|
+
doVisible(this, key, value, oldValue);
|
|
3811
3862
|
}
|
|
3812
3863
|
}));
|
|
3813
3864
|
}
|
|
3865
|
+
function doVisible(leaf, key, value, oldValue) {
|
|
3866
|
+
if (leaf.__setAttr(key, value)) {
|
|
3867
|
+
leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
|
|
3868
|
+
if (oldValue === 0 || value === 0)
|
|
3869
|
+
doBoundsType(leaf);
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3814
3872
|
function sortType(defaultValue) {
|
|
3815
3873
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3816
3874
|
set(value) {
|
|
@@ -3894,7 +3952,16 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
3894
3952
|
if (defaultValue === undefined) {
|
|
3895
3953
|
property.get = function () { return this[computedKey]; };
|
|
3896
3954
|
}
|
|
3897
|
-
else if (
|
|
3955
|
+
else if (typeof defaultValue === 'object') {
|
|
3956
|
+
const { clone } = DataHelper;
|
|
3957
|
+
property.get = function () {
|
|
3958
|
+
let v = this[computedKey];
|
|
3959
|
+
if (v === undefined)
|
|
3960
|
+
this[computedKey] = v = clone(defaultValue);
|
|
3961
|
+
return v;
|
|
3962
|
+
};
|
|
3963
|
+
}
|
|
3964
|
+
if (key === 'width') {
|
|
3898
3965
|
property.get = function () {
|
|
3899
3966
|
const v = this[computedKey];
|
|
3900
3967
|
if (v === undefined) {
|
|
@@ -3985,7 +4052,7 @@ function registerUIEvent() {
|
|
|
3985
4052
|
};
|
|
3986
4053
|
}
|
|
3987
4054
|
|
|
3988
|
-
const { copy: copy$3, toInnerPoint: toInnerPoint$1, scaleOfOuter, rotateOfOuter, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4055
|
+
const { copy: copy$3, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter, rotateOfOuter, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3989
4056
|
const matrix = {};
|
|
3990
4057
|
const LeafHelper = {
|
|
3991
4058
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4050,10 +4117,9 @@ const LeafHelper = {
|
|
|
4050
4117
|
}
|
|
4051
4118
|
return true;
|
|
4052
4119
|
},
|
|
4053
|
-
moveWorld(t, x, y = 0) {
|
|
4120
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4054
4121
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4055
|
-
|
|
4056
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4122
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4057
4123
|
L.moveLocal(t, local.x, local.y);
|
|
4058
4124
|
},
|
|
4059
4125
|
moveLocal(t, x, y = 0) {
|
|
@@ -4562,144 +4628,6 @@ class LeafLayout {
|
|
|
4562
4628
|
destroy() { }
|
|
4563
4629
|
}
|
|
4564
4630
|
|
|
4565
|
-
const empty = {};
|
|
4566
|
-
const LeafEventer = {
|
|
4567
|
-
on(type, listener, options) {
|
|
4568
|
-
let capture, once;
|
|
4569
|
-
if (options) {
|
|
4570
|
-
if (options === 'once') {
|
|
4571
|
-
once = true;
|
|
4572
|
-
}
|
|
4573
|
-
else if (typeof options === 'boolean') {
|
|
4574
|
-
capture = options;
|
|
4575
|
-
}
|
|
4576
|
-
else {
|
|
4577
|
-
capture = options.capture;
|
|
4578
|
-
once = options.once;
|
|
4579
|
-
}
|
|
4580
|
-
}
|
|
4581
|
-
let events;
|
|
4582
|
-
const map = __getListenerMap(this, capture, true);
|
|
4583
|
-
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4584
|
-
const item = once ? { listener, once } : { listener };
|
|
4585
|
-
typeList.forEach(type => {
|
|
4586
|
-
if (type) {
|
|
4587
|
-
events = map[type];
|
|
4588
|
-
if (events) {
|
|
4589
|
-
if (events.findIndex(item => item.listener === listener) === -1)
|
|
4590
|
-
events.push(item);
|
|
4591
|
-
}
|
|
4592
|
-
else {
|
|
4593
|
-
map[type] = [item];
|
|
4594
|
-
}
|
|
4595
|
-
}
|
|
4596
|
-
});
|
|
4597
|
-
},
|
|
4598
|
-
off(type, listener, options) {
|
|
4599
|
-
if (type) {
|
|
4600
|
-
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4601
|
-
if (listener) {
|
|
4602
|
-
let capture;
|
|
4603
|
-
if (options)
|
|
4604
|
-
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4605
|
-
let events, index;
|
|
4606
|
-
const map = __getListenerMap(this, capture);
|
|
4607
|
-
typeList.forEach(type => {
|
|
4608
|
-
if (type) {
|
|
4609
|
-
events = map[type];
|
|
4610
|
-
if (events) {
|
|
4611
|
-
index = events.findIndex(item => item.listener === listener);
|
|
4612
|
-
if (index > -1)
|
|
4613
|
-
events.splice(index, 1);
|
|
4614
|
-
if (!events.length)
|
|
4615
|
-
delete map[type];
|
|
4616
|
-
}
|
|
4617
|
-
}
|
|
4618
|
-
});
|
|
4619
|
-
}
|
|
4620
|
-
else {
|
|
4621
|
-
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4622
|
-
typeList.forEach(type => {
|
|
4623
|
-
if (b)
|
|
4624
|
-
delete b[type];
|
|
4625
|
-
if (c)
|
|
4626
|
-
delete c[type];
|
|
4627
|
-
});
|
|
4628
|
-
}
|
|
4629
|
-
}
|
|
4630
|
-
else {
|
|
4631
|
-
this.__bubbleMap = this.__captureMap = undefined;
|
|
4632
|
-
}
|
|
4633
|
-
},
|
|
4634
|
-
on_(type, listener, bind, options) {
|
|
4635
|
-
if (bind)
|
|
4636
|
-
listener = listener.bind(bind);
|
|
4637
|
-
this.on(type, listener, options);
|
|
4638
|
-
return { type, current: this, listener, options };
|
|
4639
|
-
},
|
|
4640
|
-
off_(id) {
|
|
4641
|
-
if (!id)
|
|
4642
|
-
return;
|
|
4643
|
-
const list = id instanceof Array ? id : [id];
|
|
4644
|
-
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
4645
|
-
list.length = 0;
|
|
4646
|
-
},
|
|
4647
|
-
once(type, listener, capture) {
|
|
4648
|
-
this.on(type, listener, { once: true, capture });
|
|
4649
|
-
},
|
|
4650
|
-
emit(type, event, capture) {
|
|
4651
|
-
if (!event && EventCreator.has(type))
|
|
4652
|
-
event = EventCreator.get(type, { type, target: this, current: this });
|
|
4653
|
-
const map = __getListenerMap(this, capture);
|
|
4654
|
-
const list = map[type];
|
|
4655
|
-
if (list) {
|
|
4656
|
-
let item;
|
|
4657
|
-
for (let i = 0, len = list.length; i < len; i++) {
|
|
4658
|
-
item = list[i];
|
|
4659
|
-
item.listener(event);
|
|
4660
|
-
if (item.once) {
|
|
4661
|
-
this.off(type, item.listener, capture);
|
|
4662
|
-
i--, len--;
|
|
4663
|
-
}
|
|
4664
|
-
if (event && event.isStopNow)
|
|
4665
|
-
break;
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4668
|
-
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4669
|
-
},
|
|
4670
|
-
emitEvent(event, capture) {
|
|
4671
|
-
event.current = this;
|
|
4672
|
-
this.emit(event.type, event, capture);
|
|
4673
|
-
},
|
|
4674
|
-
hasEvent(type, capture) {
|
|
4675
|
-
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4676
|
-
return true;
|
|
4677
|
-
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4678
|
-
const hasB = b && b[type], hasC = c && c[type];
|
|
4679
|
-
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
4680
|
-
},
|
|
4681
|
-
};
|
|
4682
|
-
function __getListenerMap(eventer, capture, create) {
|
|
4683
|
-
if (capture) {
|
|
4684
|
-
const { __captureMap: c } = eventer;
|
|
4685
|
-
if (c) {
|
|
4686
|
-
return c;
|
|
4687
|
-
}
|
|
4688
|
-
else {
|
|
4689
|
-
return create ? eventer.__captureMap = {} : empty;
|
|
4690
|
-
}
|
|
4691
|
-
}
|
|
4692
|
-
else {
|
|
4693
|
-
const { __bubbleMap: b } = eventer;
|
|
4694
|
-
if (b) {
|
|
4695
|
-
return b;
|
|
4696
|
-
}
|
|
4697
|
-
else {
|
|
4698
|
-
return create ? eventer.__bubbleMap = {} : empty;
|
|
4699
|
-
}
|
|
4700
|
-
}
|
|
4701
|
-
}
|
|
4702
|
-
|
|
4703
4631
|
class Event {
|
|
4704
4632
|
constructor(type, target) {
|
|
4705
4633
|
this.bubbles = false;
|
|
@@ -4734,7 +4662,10 @@ class ChildEvent extends Event {
|
|
|
4734
4662
|
}
|
|
4735
4663
|
ChildEvent.ADD = 'child.add';
|
|
4736
4664
|
ChildEvent.REMOVE = 'child.remove';
|
|
4737
|
-
ChildEvent.
|
|
4665
|
+
ChildEvent.CREATED = 'created';
|
|
4666
|
+
ChildEvent.MOUNTED = 'mounted';
|
|
4667
|
+
ChildEvent.UNMOUNTED = 'unmounted';
|
|
4668
|
+
ChildEvent.DESTROY = 'destroy';
|
|
4738
4669
|
|
|
4739
4670
|
class PropertyEvent extends Event {
|
|
4740
4671
|
constructor(type, target, attrName, oldValue, newValue) {
|
|
@@ -4812,10 +4743,6 @@ LayoutEvent.AFTER = 'layout.after';
|
|
|
4812
4743
|
LayoutEvent.AGAIN = 'layout.again';
|
|
4813
4744
|
LayoutEvent.END = 'layout.end';
|
|
4814
4745
|
|
|
4815
|
-
class AnimateEvent extends Event {
|
|
4816
|
-
}
|
|
4817
|
-
AnimateEvent.FRAME = 'animate.frame';
|
|
4818
|
-
|
|
4819
4746
|
class RenderEvent extends Event {
|
|
4820
4747
|
constructor(type, times, bounds, options) {
|
|
4821
4748
|
super(type);
|
|
@@ -4848,6 +4775,157 @@ LeaferEvent.STOP = 'leafer.stop';
|
|
|
4848
4775
|
LeaferEvent.RESTART = 'leafer.restart';
|
|
4849
4776
|
LeaferEvent.END = 'leafer.end';
|
|
4850
4777
|
|
|
4778
|
+
const empty = {};
|
|
4779
|
+
class Eventer {
|
|
4780
|
+
set event(map) { this.on(map); }
|
|
4781
|
+
on(type, listener, options) {
|
|
4782
|
+
if (!listener) {
|
|
4783
|
+
let event, map = type;
|
|
4784
|
+
for (let key in map)
|
|
4785
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
|
|
4786
|
+
return;
|
|
4787
|
+
}
|
|
4788
|
+
let capture, once;
|
|
4789
|
+
if (options) {
|
|
4790
|
+
if (options === 'once') {
|
|
4791
|
+
once = true;
|
|
4792
|
+
}
|
|
4793
|
+
else if (typeof options === 'boolean') {
|
|
4794
|
+
capture = options;
|
|
4795
|
+
}
|
|
4796
|
+
else {
|
|
4797
|
+
capture = options.capture;
|
|
4798
|
+
once = options.once;
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4801
|
+
let events;
|
|
4802
|
+
const map = __getListenerMap(this, capture, true);
|
|
4803
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4804
|
+
const item = once ? { listener, once } : { listener };
|
|
4805
|
+
typeList.forEach(type => {
|
|
4806
|
+
if (type) {
|
|
4807
|
+
events = map[type];
|
|
4808
|
+
if (events) {
|
|
4809
|
+
if (events.findIndex(item => item.listener === listener) === -1)
|
|
4810
|
+
events.push(item);
|
|
4811
|
+
}
|
|
4812
|
+
else {
|
|
4813
|
+
map[type] = [item];
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
});
|
|
4817
|
+
}
|
|
4818
|
+
off(type, listener, options) {
|
|
4819
|
+
if (type) {
|
|
4820
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4821
|
+
if (listener) {
|
|
4822
|
+
let capture;
|
|
4823
|
+
if (options)
|
|
4824
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4825
|
+
let events, index;
|
|
4826
|
+
const map = __getListenerMap(this, capture);
|
|
4827
|
+
typeList.forEach(type => {
|
|
4828
|
+
if (type) {
|
|
4829
|
+
events = map[type];
|
|
4830
|
+
if (events) {
|
|
4831
|
+
index = events.findIndex(item => item.listener === listener);
|
|
4832
|
+
if (index > -1)
|
|
4833
|
+
events.splice(index, 1);
|
|
4834
|
+
if (!events.length)
|
|
4835
|
+
delete map[type];
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
});
|
|
4839
|
+
}
|
|
4840
|
+
else {
|
|
4841
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4842
|
+
typeList.forEach(type => {
|
|
4843
|
+
if (b)
|
|
4844
|
+
delete b[type];
|
|
4845
|
+
if (c)
|
|
4846
|
+
delete c[type];
|
|
4847
|
+
});
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
else {
|
|
4851
|
+
this.__bubbleMap = this.__captureMap = undefined;
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
on_(type, listener, bind, options) {
|
|
4855
|
+
if (bind)
|
|
4856
|
+
listener = listener.bind(bind);
|
|
4857
|
+
this.on(type, listener, options);
|
|
4858
|
+
return { type, current: this, listener, options };
|
|
4859
|
+
}
|
|
4860
|
+
off_(id) {
|
|
4861
|
+
if (!id)
|
|
4862
|
+
return;
|
|
4863
|
+
const list = id instanceof Array ? id : [id];
|
|
4864
|
+
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
4865
|
+
list.length = 0;
|
|
4866
|
+
}
|
|
4867
|
+
once(type, listener, capture) {
|
|
4868
|
+
this.on(type, listener, { once: true, capture });
|
|
4869
|
+
}
|
|
4870
|
+
emit(type, event, capture) {
|
|
4871
|
+
if (!event && EventCreator.has(type))
|
|
4872
|
+
event = EventCreator.get(type, { type, target: this, current: this });
|
|
4873
|
+
const map = __getListenerMap(this, capture);
|
|
4874
|
+
const list = map[type];
|
|
4875
|
+
if (list) {
|
|
4876
|
+
let item;
|
|
4877
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
4878
|
+
item = list[i];
|
|
4879
|
+
item.listener(event);
|
|
4880
|
+
if (item.once) {
|
|
4881
|
+
this.off(type, item.listener, capture);
|
|
4882
|
+
i--, len--;
|
|
4883
|
+
}
|
|
4884
|
+
if (event && event.isStopNow)
|
|
4885
|
+
break;
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4889
|
+
}
|
|
4890
|
+
emitEvent(event, capture) {
|
|
4891
|
+
event.current = this;
|
|
4892
|
+
this.emit(event.type, event, capture);
|
|
4893
|
+
}
|
|
4894
|
+
hasEvent(type, capture) {
|
|
4895
|
+
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4896
|
+
return true;
|
|
4897
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4898
|
+
const hasB = b && b[type], hasC = c && c[type];
|
|
4899
|
+
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
4900
|
+
}
|
|
4901
|
+
destroy() {
|
|
4902
|
+
this.__captureMap = this.__bubbleMap = this.syncEventer = null;
|
|
4903
|
+
}
|
|
4904
|
+
}
|
|
4905
|
+
function __getListenerMap(eventer, capture, create) {
|
|
4906
|
+
if (capture) {
|
|
4907
|
+
const { __captureMap: c } = eventer;
|
|
4908
|
+
if (c) {
|
|
4909
|
+
return c;
|
|
4910
|
+
}
|
|
4911
|
+
else {
|
|
4912
|
+
return create ? eventer.__captureMap = {} : empty;
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
else {
|
|
4916
|
+
const { __bubbleMap: b } = eventer;
|
|
4917
|
+
if (b) {
|
|
4918
|
+
return b;
|
|
4919
|
+
}
|
|
4920
|
+
else {
|
|
4921
|
+
return create ? eventer.__bubbleMap = {} : empty;
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
|
|
4926
|
+
const { on, on_, off, off_, once, emit, emitEvent, hasEvent, destroy } = Eventer.prototype;
|
|
4927
|
+
const LeafEventer = { on, on_, off, off_, once, emit, emitEvent, hasEvent, destroyEventer: destroy };
|
|
4928
|
+
|
|
4851
4929
|
const { isFinite } = Number;
|
|
4852
4930
|
const debug = Debug.get('setAttr');
|
|
4853
4931
|
const LeafDataProxy = {
|
|
@@ -4859,9 +4937,7 @@ const LeafDataProxy = {
|
|
|
4859
4937
|
newValue = undefined;
|
|
4860
4938
|
}
|
|
4861
4939
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
4862
|
-
this.
|
|
4863
|
-
if (this.__proxyData)
|
|
4864
|
-
this.setProxyAttr(name, newValue);
|
|
4940
|
+
this.__realSetAttr(name, newValue);
|
|
4865
4941
|
const { CHANGE } = PropertyEvent;
|
|
4866
4942
|
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
|
|
4867
4943
|
if (this.isLeafer) {
|
|
@@ -4879,12 +4955,18 @@ const LeafDataProxy = {
|
|
|
4879
4955
|
}
|
|
4880
4956
|
}
|
|
4881
4957
|
else {
|
|
4882
|
-
this.
|
|
4883
|
-
if (this.__proxyData)
|
|
4884
|
-
this.setProxyAttr(name, newValue);
|
|
4958
|
+
this.__realSetAttr(name, newValue);
|
|
4885
4959
|
return true;
|
|
4886
4960
|
}
|
|
4887
4961
|
},
|
|
4962
|
+
__realSetAttr(name, newValue) {
|
|
4963
|
+
const data = this.__;
|
|
4964
|
+
data[name] = newValue;
|
|
4965
|
+
if (this.__proxyData)
|
|
4966
|
+
this.setProxyAttr(name, newValue);
|
|
4967
|
+
if (data.normalStyle)
|
|
4968
|
+
this.lockNormalStyle || data.normalStyle[name] === undefined || (data.normalStyle[name] = newValue);
|
|
4969
|
+
},
|
|
4888
4970
|
__getAttr(name) {
|
|
4889
4971
|
if (this.__proxyData)
|
|
4890
4972
|
return this.getProxyAttr(name);
|
|
@@ -4987,6 +5069,8 @@ const LeafBounds = {
|
|
|
4987
5069
|
layout.boundsChanged = false;
|
|
4988
5070
|
},
|
|
4989
5071
|
__updateLocalBoxBounds() {
|
|
5072
|
+
if (this.__hasMotionPath)
|
|
5073
|
+
this.__updateMotionPath();
|
|
4990
5074
|
if (this.__hasAutoLayout)
|
|
4991
5075
|
this.__updateAutoLayout();
|
|
4992
5076
|
toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
|
|
@@ -5021,7 +5105,7 @@ const LeafBounds = {
|
|
|
5021
5105
|
updateAllMatrix(this);
|
|
5022
5106
|
updateBounds(this, this);
|
|
5023
5107
|
if (this.__.__autoSide)
|
|
5024
|
-
this.__updateBoxBounds();
|
|
5108
|
+
this.__updateBoxBounds(true);
|
|
5025
5109
|
}
|
|
5026
5110
|
else {
|
|
5027
5111
|
updateAllMatrix(this);
|
|
@@ -5139,7 +5223,7 @@ const BranchRender = {
|
|
|
5139
5223
|
const { LEAF, create } = IncrementId;
|
|
5140
5224
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5141
5225
|
const { toOuterOf } = BoundsHelper;
|
|
5142
|
-
const { copy } = PointHelper;
|
|
5226
|
+
const { copy, move } = PointHelper;
|
|
5143
5227
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5144
5228
|
exports.Leaf = class Leaf {
|
|
5145
5229
|
get tag() { return this.__tag; }
|
|
@@ -5166,13 +5250,16 @@ exports.Leaf = class Leaf {
|
|
|
5166
5250
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5167
5251
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5168
5252
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5169
|
-
set event(map) {
|
|
5170
|
-
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
|
|
5253
|
+
set event(map) { this.on(map); }
|
|
5171
5254
|
constructor(data) {
|
|
5172
5255
|
this.innerId = create(LEAF);
|
|
5173
5256
|
this.reset(data);
|
|
5257
|
+
if (this.__bubbleMap)
|
|
5258
|
+
this.__emitLifeEvent(ChildEvent.CREATED);
|
|
5174
5259
|
}
|
|
5175
5260
|
reset(data) {
|
|
5261
|
+
if (this.leafer)
|
|
5262
|
+
this.leafer.forceRender(this.__world);
|
|
5176
5263
|
this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1 };
|
|
5177
5264
|
if (data !== null)
|
|
5178
5265
|
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -5194,12 +5281,12 @@ exports.Leaf = class Leaf {
|
|
|
5194
5281
|
waitParent(item, bind) {
|
|
5195
5282
|
if (bind)
|
|
5196
5283
|
item = item.bind(bind);
|
|
5197
|
-
this.parent ? item() :
|
|
5284
|
+
this.parent ? item() : this.on(ChildEvent.ADD, item, 'once');
|
|
5198
5285
|
}
|
|
5199
5286
|
waitLeafer(item, bind) {
|
|
5200
5287
|
if (bind)
|
|
5201
5288
|
item = item.bind(bind);
|
|
5202
|
-
this.leafer ? item() :
|
|
5289
|
+
this.leafer ? item() : this.on(ChildEvent.MOUNTED, item, 'once');
|
|
5203
5290
|
}
|
|
5204
5291
|
nextRender(item, bind, off) {
|
|
5205
5292
|
this.leafer ? this.leafer.nextRender(item, bind, off) : this.waitLeafer(() => this.leafer.nextRender(item, bind, off));
|
|
@@ -5208,18 +5295,21 @@ exports.Leaf = class Leaf {
|
|
|
5208
5295
|
this.nextRender(item, null, 'off');
|
|
5209
5296
|
}
|
|
5210
5297
|
__bindLeafer(leafer) {
|
|
5211
|
-
if (this.isLeafer)
|
|
5212
|
-
|
|
5213
|
-
leafer = this;
|
|
5214
|
-
}
|
|
5298
|
+
if (this.isLeafer && leafer !== null)
|
|
5299
|
+
leafer = this;
|
|
5215
5300
|
if (this.leafer && !leafer)
|
|
5216
5301
|
this.leafer.leafs--;
|
|
5217
5302
|
this.leafer = leafer;
|
|
5218
5303
|
if (leafer) {
|
|
5219
5304
|
leafer.leafs++;
|
|
5220
5305
|
this.__level = this.parent ? this.parent.__level + 1 : 1;
|
|
5221
|
-
if (this.
|
|
5222
|
-
|
|
5306
|
+
if (this.animation)
|
|
5307
|
+
this.__runAnimation('in');
|
|
5308
|
+
if (this.__bubbleMap)
|
|
5309
|
+
this.__emitLifeEvent(ChildEvent.MOUNTED);
|
|
5310
|
+
}
|
|
5311
|
+
else {
|
|
5312
|
+
this.__emitLifeEvent(ChildEvent.UNMOUNTED);
|
|
5223
5313
|
}
|
|
5224
5314
|
if (this.isBranch) {
|
|
5225
5315
|
const { children } = this;
|
|
@@ -5228,7 +5318,7 @@ exports.Leaf = class Leaf {
|
|
|
5228
5318
|
}
|
|
5229
5319
|
}
|
|
5230
5320
|
}
|
|
5231
|
-
set(_data) { }
|
|
5321
|
+
set(_data, _isTemp) { }
|
|
5232
5322
|
get(_name) { return undefined; }
|
|
5233
5323
|
setAttr(name, value) { this[name] = value; }
|
|
5234
5324
|
getAttr(name) { return this[name]; }
|
|
@@ -5253,6 +5343,7 @@ exports.Leaf = class Leaf {
|
|
|
5253
5343
|
findOne(_condition, _options) { return undefined; }
|
|
5254
5344
|
findId(_id) { return undefined; }
|
|
5255
5345
|
focus(_value) { }
|
|
5346
|
+
updateState() { }
|
|
5256
5347
|
updateLayout() {
|
|
5257
5348
|
this.__layout.update();
|
|
5258
5349
|
}
|
|
@@ -5360,11 +5451,24 @@ exports.Leaf = class Leaf {
|
|
|
5360
5451
|
if (relative)
|
|
5361
5452
|
relative.worldToInner(to ? to : inner, null, distance);
|
|
5362
5453
|
}
|
|
5454
|
+
getBoxPoint(world, relative, distance, change) {
|
|
5455
|
+
return this.getBoxPointByInner(this.getInnerPoint(world, relative, distance, change), null, null, true);
|
|
5456
|
+
}
|
|
5457
|
+
getBoxPointByInner(inner, _relative, _distance, change) {
|
|
5458
|
+
const point = change ? inner : Object.assign({}, inner), { x, y } = this.boxBounds;
|
|
5459
|
+
move(point, -x, -y);
|
|
5460
|
+
return point;
|
|
5461
|
+
}
|
|
5363
5462
|
getInnerPoint(world, relative, distance, change) {
|
|
5364
5463
|
const point = change ? world : {};
|
|
5365
5464
|
this.worldToInner(world, point, distance, relative);
|
|
5366
5465
|
return point;
|
|
5367
5466
|
}
|
|
5467
|
+
getInnerPointByBox(box, _relative, _distance, change) {
|
|
5468
|
+
const point = change ? box : Object.assign({}, box), { x, y } = this.boxBounds;
|
|
5469
|
+
move(point, x, y);
|
|
5470
|
+
return point;
|
|
5471
|
+
}
|
|
5368
5472
|
getInnerPointByLocal(local, _relative, distance, change) {
|
|
5369
5473
|
return this.getInnerPoint(local, this.parent, distance, change);
|
|
5370
5474
|
}
|
|
@@ -5376,20 +5480,23 @@ exports.Leaf = class Leaf {
|
|
|
5376
5480
|
getLocalPointByInner(inner, _relative, distance, change) {
|
|
5377
5481
|
return this.getWorldPoint(inner, this.parent, distance, change);
|
|
5378
5482
|
}
|
|
5483
|
+
getPagePoint(world, relative, distance, change) {
|
|
5484
|
+
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5485
|
+
return layer.getInnerPoint(world, relative, distance, change);
|
|
5486
|
+
}
|
|
5379
5487
|
getWorldPoint(inner, relative, distance, change) {
|
|
5380
5488
|
const point = change ? inner : {};
|
|
5381
5489
|
this.innerToWorld(inner, point, distance, relative);
|
|
5382
5490
|
return point;
|
|
5383
5491
|
}
|
|
5492
|
+
getWorldPointByBox(box, relative, distance, change) {
|
|
5493
|
+
return this.getWorldPoint(this.getInnerPointByBox(box, null, null, change), relative, distance, true);
|
|
5494
|
+
}
|
|
5384
5495
|
getWorldPointByLocal(local, relative, distance, change) {
|
|
5385
5496
|
const point = change ? local : {};
|
|
5386
5497
|
this.localToWorld(local, point, distance, relative);
|
|
5387
5498
|
return point;
|
|
5388
5499
|
}
|
|
5389
|
-
getPagePoint(world, relative, distance, change) {
|
|
5390
|
-
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5391
|
-
return layer.getInnerPoint(world, relative, distance, change);
|
|
5392
|
-
}
|
|
5393
5500
|
getWorldPointByPage(page, relative, distance, change) {
|
|
5394
5501
|
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5395
5502
|
return layer.getWorldPoint(page, relative, distance, change);
|
|
@@ -5403,6 +5510,9 @@ exports.Leaf = class Leaf {
|
|
|
5403
5510
|
move(x, y) {
|
|
5404
5511
|
moveLocal(this, x, y);
|
|
5405
5512
|
}
|
|
5513
|
+
moveInner(x, y) {
|
|
5514
|
+
moveWorld(this, x, y, true);
|
|
5515
|
+
}
|
|
5406
5516
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5407
5517
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5408
5518
|
}
|
|
@@ -5455,6 +5565,17 @@ exports.Leaf = class Leaf {
|
|
|
5455
5565
|
__drawRenderPath(_canvas) { }
|
|
5456
5566
|
__updatePath() { }
|
|
5457
5567
|
__updateRenderPath() { }
|
|
5568
|
+
getMotionPathData() {
|
|
5569
|
+
return needPlugin('path');
|
|
5570
|
+
}
|
|
5571
|
+
getMotionPoint(_motionDistance) {
|
|
5572
|
+
return needPlugin('path');
|
|
5573
|
+
}
|
|
5574
|
+
getMotionTotal() {
|
|
5575
|
+
return 0;
|
|
5576
|
+
}
|
|
5577
|
+
__updateMotionPath() { }
|
|
5578
|
+
__runAnimation(_type, _complete) { }
|
|
5458
5579
|
__updateSortChildren() { }
|
|
5459
5580
|
add(_child, _index) { }
|
|
5460
5581
|
remove(_child, destroy) {
|
|
@@ -5480,6 +5601,10 @@ exports.Leaf = class Leaf {
|
|
|
5480
5601
|
fn = boundsType;
|
|
5481
5602
|
fn(defaultValue)(this.prototype, attrName);
|
|
5482
5603
|
}
|
|
5604
|
+
__emitLifeEvent(type) {
|
|
5605
|
+
if (this.hasEvent(type))
|
|
5606
|
+
this.emitEvent(new ChildEvent(type, this, this.parent));
|
|
5607
|
+
}
|
|
5483
5608
|
destroy() {
|
|
5484
5609
|
if (!this.destroyed) {
|
|
5485
5610
|
const { parent } = this;
|
|
@@ -5487,11 +5612,10 @@ exports.Leaf = class Leaf {
|
|
|
5487
5612
|
this.remove();
|
|
5488
5613
|
if (this.children)
|
|
5489
5614
|
this.removeAll(true);
|
|
5490
|
-
|
|
5491
|
-
this.emitEvent(new ChildEvent(ChildEvent.DESTROY, this, parent));
|
|
5615
|
+
this.__emitLifeEvent(ChildEvent.DESTROY);
|
|
5492
5616
|
this.__.destroy();
|
|
5493
5617
|
this.__layout.destroy();
|
|
5494
|
-
this.
|
|
5618
|
+
this.destroyEventer();
|
|
5495
5619
|
this.destroyed = true;
|
|
5496
5620
|
}
|
|
5497
5621
|
}
|
|
@@ -5557,8 +5681,8 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5557
5681
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5558
5682
|
child.__layout.boxChanged || child.__layout.boxChange();
|
|
5559
5683
|
child.__layout.matrixChanged || child.__layout.matrixChange();
|
|
5560
|
-
if (child.
|
|
5561
|
-
|
|
5684
|
+
if (child.__bubbleMap)
|
|
5685
|
+
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5562
5686
|
if (this.leafer) {
|
|
5563
5687
|
child.__bindLeafer(this.leafer);
|
|
5564
5688
|
if (this.leafer.created)
|
|
@@ -5571,16 +5695,10 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5571
5695
|
}
|
|
5572
5696
|
remove(child, destroy) {
|
|
5573
5697
|
if (child) {
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1;
|
|
5579
|
-
this.__preRemove();
|
|
5580
|
-
this.__realRemoveChild(child);
|
|
5581
|
-
if (destroy)
|
|
5582
|
-
child.destroy();
|
|
5583
|
-
}
|
|
5698
|
+
if (child.animationOut)
|
|
5699
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5700
|
+
else
|
|
5701
|
+
this.__remove(child, destroy);
|
|
5584
5702
|
}
|
|
5585
5703
|
else if (child === undefined) {
|
|
5586
5704
|
super.remove(null, destroy);
|
|
@@ -5602,6 +5720,18 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5602
5720
|
clear() {
|
|
5603
5721
|
this.removeAll(true);
|
|
5604
5722
|
}
|
|
5723
|
+
__remove(child, destroy) {
|
|
5724
|
+
const index = this.children.indexOf(child);
|
|
5725
|
+
if (index > -1) {
|
|
5726
|
+
this.children.splice(index, 1);
|
|
5727
|
+
if (child.isBranch)
|
|
5728
|
+
this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1;
|
|
5729
|
+
this.__preRemove();
|
|
5730
|
+
this.__realRemoveChild(child);
|
|
5731
|
+
if (destroy)
|
|
5732
|
+
child.destroy();
|
|
5733
|
+
}
|
|
5734
|
+
}
|
|
5605
5735
|
__preRemove() {
|
|
5606
5736
|
if (this.__hasMask)
|
|
5607
5737
|
this.__updateMask();
|
|
@@ -5611,6 +5741,7 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5611
5741
|
this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
|
|
5612
5742
|
}
|
|
5613
5743
|
__realRemoveChild(child) {
|
|
5744
|
+
child.__emitLifeEvent(ChildEvent.REMOVE);
|
|
5614
5745
|
child.parent = null;
|
|
5615
5746
|
if (this.leafer) {
|
|
5616
5747
|
child.__bindLeafer(null);
|
|
@@ -5623,8 +5754,6 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5623
5754
|
}
|
|
5624
5755
|
__emitChildEvent(type, child) {
|
|
5625
5756
|
const event = new ChildEvent(type, child, this);
|
|
5626
|
-
if (child.hasEvent(type))
|
|
5627
|
-
child.emitEvent(event);
|
|
5628
5757
|
if (this.hasEvent(type) && !this.isLeafer)
|
|
5629
5758
|
this.emitEvent(event);
|
|
5630
5759
|
this.leafer.emitEvent(event);
|
|
@@ -5787,11 +5916,9 @@ class LeafLevelList {
|
|
|
5787
5916
|
}
|
|
5788
5917
|
}
|
|
5789
5918
|
|
|
5790
|
-
const version = "1.0.
|
|
5791
|
-
const inviteCode = {};
|
|
5919
|
+
const version = "1.0.3";
|
|
5792
5920
|
|
|
5793
5921
|
exports.AlignHelper = AlignHelper;
|
|
5794
|
-
exports.AnimateEvent = AnimateEvent;
|
|
5795
5922
|
exports.AroundHelper = AroundHelper;
|
|
5796
5923
|
exports.AutoBounds = AutoBounds;
|
|
5797
5924
|
exports.BezierHelper = BezierHelper;
|
|
@@ -5807,6 +5934,7 @@ exports.Debug = Debug;
|
|
|
5807
5934
|
exports.EllipseHelper = EllipseHelper;
|
|
5808
5935
|
exports.Event = Event;
|
|
5809
5936
|
exports.EventCreator = EventCreator;
|
|
5937
|
+
exports.Eventer = Eventer;
|
|
5810
5938
|
exports.FileHelper = FileHelper;
|
|
5811
5939
|
exports.ImageEvent = ImageEvent;
|
|
5812
5940
|
exports.ImageManager = ImageManager;
|
|
@@ -5881,10 +6009,11 @@ exports.getDescriptor = getDescriptor;
|
|
|
5881
6009
|
exports.getMatrixData = getMatrixData;
|
|
5882
6010
|
exports.getPointData = getPointData;
|
|
5883
6011
|
exports.hitType = hitType;
|
|
5884
|
-
exports.
|
|
6012
|
+
exports.isNull = isNull;
|
|
5885
6013
|
exports.layoutProcessor = layoutProcessor;
|
|
5886
6014
|
exports.maskType = maskType;
|
|
5887
6015
|
exports.naturalBoundsType = naturalBoundsType;
|
|
6016
|
+
exports.needPlugin = needPlugin;
|
|
5888
6017
|
exports.opacityType = opacityType;
|
|
5889
6018
|
exports.pathInputType = pathInputType;
|
|
5890
6019
|
exports.pathType = pathType;
|