@leafer-draw/worker 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/dist/worker.cjs +2402 -0
- package/dist/worker.esm.js +61 -51
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +522 -418
- package/dist/worker.min.cjs +1 -0
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +518 -415
- package/dist/worker.module.min.js +1 -1
- package/package.json +13 -7
package/dist/worker.js
CHANGED
|
@@ -114,6 +114,26 @@ var LeaferUI = (function (exports) {
|
|
|
114
114
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
115
115
|
num = round(num * a) / a;
|
|
116
116
|
return num === -0 ? 0 : num;
|
|
117
|
+
},
|
|
118
|
+
getScaleData(scale, size, originSize, scaleData) {
|
|
119
|
+
if (!scaleData)
|
|
120
|
+
scaleData = {};
|
|
121
|
+
if (size) {
|
|
122
|
+
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
123
|
+
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
124
|
+
}
|
|
125
|
+
else if (scale)
|
|
126
|
+
MathHelper.assignScale(scaleData, scale);
|
|
127
|
+
return scaleData;
|
|
128
|
+
},
|
|
129
|
+
assignScale(scaleData, scale) {
|
|
130
|
+
if (typeof scale === 'number') {
|
|
131
|
+
scaleData.scaleX = scaleData.scaleY = scale;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
scaleData.scaleX = scale.x;
|
|
135
|
+
scaleData.scaleY = scale.y;
|
|
136
|
+
}
|
|
117
137
|
}
|
|
118
138
|
};
|
|
119
139
|
const OneRadian = PI$4 / 180;
|
|
@@ -412,7 +432,7 @@ var LeaferUI = (function (exports) {
|
|
|
412
432
|
};
|
|
413
433
|
const M$6 = MatrixHelper;
|
|
414
434
|
|
|
415
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
435
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
416
436
|
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
417
437
|
const PointHelper = {
|
|
418
438
|
defaultPoint: getPointData(),
|
|
@@ -468,7 +488,7 @@ var LeaferUI = (function (exports) {
|
|
|
468
488
|
tempToOuterOf(t, matrix) {
|
|
469
489
|
const { tempPoint: temp } = P$5;
|
|
470
490
|
copy$a(temp, t);
|
|
471
|
-
toOuterPoint$
|
|
491
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
472
492
|
return temp;
|
|
473
493
|
},
|
|
474
494
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -487,7 +507,7 @@ var LeaferUI = (function (exports) {
|
|
|
487
507
|
toInnerPoint$2(matrix, t, to);
|
|
488
508
|
},
|
|
489
509
|
toOuterOf(t, matrix, to) {
|
|
490
|
-
toOuterPoint$
|
|
510
|
+
toOuterPoint$3(matrix, t, to);
|
|
491
511
|
},
|
|
492
512
|
getCenter(t, to) {
|
|
493
513
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -767,7 +787,7 @@ var LeaferUI = (function (exports) {
|
|
|
767
787
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
768
788
|
|
|
769
789
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
770
|
-
const { toOuterPoint: toOuterPoint$
|
|
790
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
771
791
|
const { float, fourNumber } = MathHelper;
|
|
772
792
|
const { floor, ceil: ceil$2 } = Math;
|
|
773
793
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
@@ -787,17 +807,24 @@ var LeaferUI = (function (exports) {
|
|
|
787
807
|
t.width = bounds.width;
|
|
788
808
|
t.height = bounds.height;
|
|
789
809
|
},
|
|
790
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
810
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
811
|
+
const { x, y, width, height } = bounds;
|
|
791
812
|
if (spread instanceof Array) {
|
|
792
813
|
const four = fourNumber(spread);
|
|
793
814
|
isShrink
|
|
794
|
-
? B.set(t,
|
|
795
|
-
: B.set(t,
|
|
815
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
816
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
796
817
|
}
|
|
797
818
|
else {
|
|
798
819
|
if (isShrink)
|
|
799
820
|
spread = -spread;
|
|
800
|
-
B.set(t,
|
|
821
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
822
|
+
}
|
|
823
|
+
if (side) {
|
|
824
|
+
if (side === 'width')
|
|
825
|
+
t.y = y, t.height = height;
|
|
826
|
+
else
|
|
827
|
+
t.x = x, t.width = width;
|
|
801
828
|
}
|
|
802
829
|
},
|
|
803
830
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -874,16 +901,16 @@ var LeaferUI = (function (exports) {
|
|
|
874
901
|
else {
|
|
875
902
|
point.x = t.x;
|
|
876
903
|
point.y = t.y;
|
|
877
|
-
toOuterPoint$
|
|
904
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
878
905
|
setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
879
906
|
point.x = t.x + t.width;
|
|
880
|
-
toOuterPoint$
|
|
907
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
881
908
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
882
909
|
point.y = t.y + t.height;
|
|
883
|
-
toOuterPoint$
|
|
910
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
884
911
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
885
912
|
point.x = t.x;
|
|
886
|
-
toOuterPoint$
|
|
913
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
887
914
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
888
915
|
toBounds$4(tempPointBounds$1, to);
|
|
889
916
|
}
|
|
@@ -897,16 +924,16 @@ var LeaferUI = (function (exports) {
|
|
|
897
924
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
898
925
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
899
926
|
},
|
|
900
|
-
getSpread(t, spread) {
|
|
927
|
+
getSpread(t, spread, side) {
|
|
901
928
|
const n = {};
|
|
902
|
-
B.copyAndSpread(n, t, spread);
|
|
929
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
903
930
|
return n;
|
|
904
931
|
},
|
|
905
|
-
spread(t, spread) {
|
|
906
|
-
B.copyAndSpread(t, t, spread);
|
|
932
|
+
spread(t, spread, side) {
|
|
933
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
907
934
|
},
|
|
908
|
-
shrink(t, shrink) {
|
|
909
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
935
|
+
shrink(t, shrink, side) {
|
|
936
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
910
937
|
},
|
|
911
938
|
ceil(t) {
|
|
912
939
|
const { x, y } = t;
|
|
@@ -1089,12 +1116,12 @@ var LeaferUI = (function (exports) {
|
|
|
1089
1116
|
getFitMatrix(put, baseScale) {
|
|
1090
1117
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1091
1118
|
}
|
|
1092
|
-
spread(fourNumber) {
|
|
1093
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1119
|
+
spread(fourNumber, side) {
|
|
1120
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1094
1121
|
return this;
|
|
1095
1122
|
}
|
|
1096
|
-
shrink(fourNumber) {
|
|
1097
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1123
|
+
shrink(fourNumber, side) {
|
|
1124
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1098
1125
|
return this;
|
|
1099
1126
|
}
|
|
1100
1127
|
ceil() {
|
|
@@ -1238,7 +1265,6 @@ var LeaferUI = (function (exports) {
|
|
|
1238
1265
|
tempPoint: {},
|
|
1239
1266
|
get: get$4,
|
|
1240
1267
|
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1241
|
-
to || (to = {});
|
|
1242
1268
|
const point = get$4(around);
|
|
1243
1269
|
to.x = point.x;
|
|
1244
1270
|
to.y = point.y;
|
|
@@ -1373,6 +1399,10 @@ var LeaferUI = (function (exports) {
|
|
|
1373
1399
|
};
|
|
1374
1400
|
const R = Run;
|
|
1375
1401
|
|
|
1402
|
+
function needPlugin(name) {
|
|
1403
|
+
console.error('need plugin: @leafer-in/' + name);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1376
1406
|
const debug$c = Debug.get('UICreator');
|
|
1377
1407
|
const UICreator = {
|
|
1378
1408
|
list: {},
|
|
@@ -1635,6 +1665,9 @@ var LeaferUI = (function (exports) {
|
|
|
1635
1665
|
Answer[Answer["YesAndSkip"] = 3] = "YesAndSkip";
|
|
1636
1666
|
})(exports.Answer || (exports.Answer = {}));
|
|
1637
1667
|
const emptyData = {};
|
|
1668
|
+
function isNull(value) {
|
|
1669
|
+
return value === undefined || value === null;
|
|
1670
|
+
}
|
|
1638
1671
|
|
|
1639
1672
|
/******************************************************************************
|
|
1640
1673
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2400,7 +2433,7 @@ var LeaferUI = (function (exports) {
|
|
|
2400
2433
|
let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
|
|
2401
2434
|
let fromX = cx + x, fromY = cy + y;
|
|
2402
2435
|
if (data)
|
|
2403
|
-
data.push(L$6, fromX, fromY);
|
|
2436
|
+
data.push(data.length ? L$6 : M$5, fromX, fromY);
|
|
2404
2437
|
if (setPointBounds)
|
|
2405
2438
|
setPoint$2(setPointBounds, fromX, fromY);
|
|
2406
2439
|
if (setStartPoint)
|
|
@@ -2911,60 +2944,75 @@ var LeaferUI = (function (exports) {
|
|
|
2911
2944
|
}
|
|
2912
2945
|
beginPath() {
|
|
2913
2946
|
beginPath(this.__path);
|
|
2947
|
+
this.paint();
|
|
2914
2948
|
return this;
|
|
2915
2949
|
}
|
|
2916
2950
|
moveTo(x, y) {
|
|
2917
2951
|
moveTo$4(this.__path, x, y);
|
|
2952
|
+
this.paint();
|
|
2918
2953
|
return this;
|
|
2919
2954
|
}
|
|
2920
2955
|
lineTo(x, y) {
|
|
2921
2956
|
lineTo$3(this.__path, x, y);
|
|
2957
|
+
this.paint();
|
|
2922
2958
|
return this;
|
|
2923
2959
|
}
|
|
2924
2960
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2925
2961
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2962
|
+
this.paint();
|
|
2926
2963
|
return this;
|
|
2927
2964
|
}
|
|
2928
2965
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2929
2966
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2967
|
+
this.paint();
|
|
2930
2968
|
return this;
|
|
2931
2969
|
}
|
|
2932
2970
|
closePath() {
|
|
2933
2971
|
closePath$3(this.__path);
|
|
2972
|
+
this.paint();
|
|
2934
2973
|
return this;
|
|
2935
2974
|
}
|
|
2936
2975
|
rect(x, y, width, height) {
|
|
2937
2976
|
rect$1(this.__path, x, y, width, height);
|
|
2977
|
+
this.paint();
|
|
2938
2978
|
return this;
|
|
2939
2979
|
}
|
|
2940
2980
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2941
2981
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2982
|
+
this.paint();
|
|
2942
2983
|
return this;
|
|
2943
2984
|
}
|
|
2944
2985
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2945
2986
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2987
|
+
this.paint();
|
|
2946
2988
|
return this;
|
|
2947
2989
|
}
|
|
2948
2990
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2949
2991
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2992
|
+
this.paint();
|
|
2950
2993
|
return this;
|
|
2951
2994
|
}
|
|
2952
2995
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2953
2996
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2997
|
+
this.paint();
|
|
2954
2998
|
return this;
|
|
2955
2999
|
}
|
|
2956
3000
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2957
3001
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
3002
|
+
this.paint();
|
|
2958
3003
|
return this;
|
|
2959
3004
|
}
|
|
2960
3005
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2961
3006
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
3007
|
+
this.paint();
|
|
2962
3008
|
return this;
|
|
2963
3009
|
}
|
|
2964
3010
|
drawPoints(points, curve, close) {
|
|
2965
3011
|
drawPoints$2(this.__path, points, curve, close);
|
|
3012
|
+
this.paint();
|
|
2966
3013
|
return this;
|
|
2967
3014
|
}
|
|
3015
|
+
paint() { }
|
|
2968
3016
|
}
|
|
2969
3017
|
|
|
2970
3018
|
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;
|
|
@@ -3054,8 +3102,7 @@ var LeaferUI = (function (exports) {
|
|
|
3054
3102
|
toTwoPointBounds(data, setPointBounds) {
|
|
3055
3103
|
if (!data || !data.length)
|
|
3056
3104
|
return setPoint$1(setPointBounds, 0, 0);
|
|
3057
|
-
let command;
|
|
3058
|
-
let i = 0, x = 0, y = 0, x1, y1, toX, toY;
|
|
3105
|
+
let i = 0, x = 0, y = 0, x1, y1, toX, toY, command;
|
|
3059
3106
|
const len = data.length;
|
|
3060
3107
|
while (i < len) {
|
|
3061
3108
|
command = data[i];
|
|
@@ -3711,7 +3758,7 @@ var LeaferUI = (function (exports) {
|
|
|
3711
3758
|
set(value) {
|
|
3712
3759
|
if (this.__setAttr(key, value)) {
|
|
3713
3760
|
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3714
|
-
this.__hasAutoLayout = !!
|
|
3761
|
+
this.__hasAutoLayout = !!(this.origin || this.around || this.flow);
|
|
3715
3762
|
if (!this.__local)
|
|
3716
3763
|
this.__layout.createLocal();
|
|
3717
3764
|
}
|
|
@@ -3804,14 +3851,25 @@ var LeaferUI = (function (exports) {
|
|
|
3804
3851
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3805
3852
|
set(value) {
|
|
3806
3853
|
const oldValue = this.visible;
|
|
3807
|
-
if (
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
doBoundsType(this);
|
|
3854
|
+
if (oldValue === true && value === 0) {
|
|
3855
|
+
if (this.animationOut)
|
|
3856
|
+
return this.__runAnimation('out', () => doVisible(this, key, value, oldValue));
|
|
3811
3857
|
}
|
|
3858
|
+
else if (oldValue === 0 && value === true) {
|
|
3859
|
+
if (this.animation)
|
|
3860
|
+
this.__runAnimation('in');
|
|
3861
|
+
}
|
|
3862
|
+
doVisible(this, key, value, oldValue);
|
|
3812
3863
|
}
|
|
3813
3864
|
}));
|
|
3814
3865
|
}
|
|
3866
|
+
function doVisible(leaf, key, value, oldValue) {
|
|
3867
|
+
if (leaf.__setAttr(key, value)) {
|
|
3868
|
+
leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
|
|
3869
|
+
if (oldValue === 0 || value === 0)
|
|
3870
|
+
doBoundsType(leaf);
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3815
3873
|
function sortType(defaultValue) {
|
|
3816
3874
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3817
3875
|
set(value) {
|
|
@@ -3895,7 +3953,16 @@ var LeaferUI = (function (exports) {
|
|
|
3895
3953
|
if (defaultValue === undefined) {
|
|
3896
3954
|
property.get = function () { return this[computedKey]; };
|
|
3897
3955
|
}
|
|
3898
|
-
else if (
|
|
3956
|
+
else if (typeof defaultValue === 'object') {
|
|
3957
|
+
const { clone } = DataHelper;
|
|
3958
|
+
property.get = function () {
|
|
3959
|
+
let v = this[computedKey];
|
|
3960
|
+
if (v === undefined)
|
|
3961
|
+
this[computedKey] = v = clone(defaultValue);
|
|
3962
|
+
return v;
|
|
3963
|
+
};
|
|
3964
|
+
}
|
|
3965
|
+
if (key === 'width') {
|
|
3899
3966
|
property.get = function () {
|
|
3900
3967
|
const v = this[computedKey];
|
|
3901
3968
|
if (v === undefined) {
|
|
@@ -3986,7 +4053,7 @@ var LeaferUI = (function (exports) {
|
|
|
3986
4053
|
};
|
|
3987
4054
|
}
|
|
3988
4055
|
|
|
3989
|
-
const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4056
|
+
const { copy: copy$6, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3990
4057
|
const matrix = {};
|
|
3991
4058
|
const LeafHelper = {
|
|
3992
4059
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4051,10 +4118,9 @@ var LeaferUI = (function (exports) {
|
|
|
4051
4118
|
}
|
|
4052
4119
|
return true;
|
|
4053
4120
|
},
|
|
4054
|
-
moveWorld(t, x, y = 0) {
|
|
4121
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4055
4122
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4056
|
-
|
|
4057
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4123
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4058
4124
|
L.moveLocal(t, local.x, local.y);
|
|
4059
4125
|
},
|
|
4060
4126
|
moveLocal(t, x, y = 0) {
|
|
@@ -4563,144 +4629,6 @@ var LeaferUI = (function (exports) {
|
|
|
4563
4629
|
destroy() { }
|
|
4564
4630
|
}
|
|
4565
4631
|
|
|
4566
|
-
const empty = {};
|
|
4567
|
-
const LeafEventer = {
|
|
4568
|
-
on(type, listener, options) {
|
|
4569
|
-
let capture, once;
|
|
4570
|
-
if (options) {
|
|
4571
|
-
if (options === 'once') {
|
|
4572
|
-
once = true;
|
|
4573
|
-
}
|
|
4574
|
-
else if (typeof options === 'boolean') {
|
|
4575
|
-
capture = options;
|
|
4576
|
-
}
|
|
4577
|
-
else {
|
|
4578
|
-
capture = options.capture;
|
|
4579
|
-
once = options.once;
|
|
4580
|
-
}
|
|
4581
|
-
}
|
|
4582
|
-
let events;
|
|
4583
|
-
const map = __getListenerMap(this, capture, true);
|
|
4584
|
-
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4585
|
-
const item = once ? { listener, once } : { listener };
|
|
4586
|
-
typeList.forEach(type => {
|
|
4587
|
-
if (type) {
|
|
4588
|
-
events = map[type];
|
|
4589
|
-
if (events) {
|
|
4590
|
-
if (events.findIndex(item => item.listener === listener) === -1)
|
|
4591
|
-
events.push(item);
|
|
4592
|
-
}
|
|
4593
|
-
else {
|
|
4594
|
-
map[type] = [item];
|
|
4595
|
-
}
|
|
4596
|
-
}
|
|
4597
|
-
});
|
|
4598
|
-
},
|
|
4599
|
-
off(type, listener, options) {
|
|
4600
|
-
if (type) {
|
|
4601
|
-
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4602
|
-
if (listener) {
|
|
4603
|
-
let capture;
|
|
4604
|
-
if (options)
|
|
4605
|
-
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4606
|
-
let events, index;
|
|
4607
|
-
const map = __getListenerMap(this, capture);
|
|
4608
|
-
typeList.forEach(type => {
|
|
4609
|
-
if (type) {
|
|
4610
|
-
events = map[type];
|
|
4611
|
-
if (events) {
|
|
4612
|
-
index = events.findIndex(item => item.listener === listener);
|
|
4613
|
-
if (index > -1)
|
|
4614
|
-
events.splice(index, 1);
|
|
4615
|
-
if (!events.length)
|
|
4616
|
-
delete map[type];
|
|
4617
|
-
}
|
|
4618
|
-
}
|
|
4619
|
-
});
|
|
4620
|
-
}
|
|
4621
|
-
else {
|
|
4622
|
-
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4623
|
-
typeList.forEach(type => {
|
|
4624
|
-
if (b)
|
|
4625
|
-
delete b[type];
|
|
4626
|
-
if (c)
|
|
4627
|
-
delete c[type];
|
|
4628
|
-
});
|
|
4629
|
-
}
|
|
4630
|
-
}
|
|
4631
|
-
else {
|
|
4632
|
-
this.__bubbleMap = this.__captureMap = undefined;
|
|
4633
|
-
}
|
|
4634
|
-
},
|
|
4635
|
-
on_(type, listener, bind, options) {
|
|
4636
|
-
if (bind)
|
|
4637
|
-
listener = listener.bind(bind);
|
|
4638
|
-
this.on(type, listener, options);
|
|
4639
|
-
return { type, current: this, listener, options };
|
|
4640
|
-
},
|
|
4641
|
-
off_(id) {
|
|
4642
|
-
if (!id)
|
|
4643
|
-
return;
|
|
4644
|
-
const list = id instanceof Array ? id : [id];
|
|
4645
|
-
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
4646
|
-
list.length = 0;
|
|
4647
|
-
},
|
|
4648
|
-
once(type, listener, capture) {
|
|
4649
|
-
this.on(type, listener, { once: true, capture });
|
|
4650
|
-
},
|
|
4651
|
-
emit(type, event, capture) {
|
|
4652
|
-
if (!event && EventCreator.has(type))
|
|
4653
|
-
event = EventCreator.get(type, { type, target: this, current: this });
|
|
4654
|
-
const map = __getListenerMap(this, capture);
|
|
4655
|
-
const list = map[type];
|
|
4656
|
-
if (list) {
|
|
4657
|
-
let item;
|
|
4658
|
-
for (let i = 0, len = list.length; i < len; i++) {
|
|
4659
|
-
item = list[i];
|
|
4660
|
-
item.listener(event);
|
|
4661
|
-
if (item.once) {
|
|
4662
|
-
this.off(type, item.listener, capture);
|
|
4663
|
-
i--, len--;
|
|
4664
|
-
}
|
|
4665
|
-
if (event && event.isStopNow)
|
|
4666
|
-
break;
|
|
4667
|
-
}
|
|
4668
|
-
}
|
|
4669
|
-
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4670
|
-
},
|
|
4671
|
-
emitEvent(event, capture) {
|
|
4672
|
-
event.current = this;
|
|
4673
|
-
this.emit(event.type, event, capture);
|
|
4674
|
-
},
|
|
4675
|
-
hasEvent(type, capture) {
|
|
4676
|
-
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4677
|
-
return true;
|
|
4678
|
-
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4679
|
-
const hasB = b && b[type], hasC = c && c[type];
|
|
4680
|
-
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
4681
|
-
},
|
|
4682
|
-
};
|
|
4683
|
-
function __getListenerMap(eventer, capture, create) {
|
|
4684
|
-
if (capture) {
|
|
4685
|
-
const { __captureMap: c } = eventer;
|
|
4686
|
-
if (c) {
|
|
4687
|
-
return c;
|
|
4688
|
-
}
|
|
4689
|
-
else {
|
|
4690
|
-
return create ? eventer.__captureMap = {} : empty;
|
|
4691
|
-
}
|
|
4692
|
-
}
|
|
4693
|
-
else {
|
|
4694
|
-
const { __bubbleMap: b } = eventer;
|
|
4695
|
-
if (b) {
|
|
4696
|
-
return b;
|
|
4697
|
-
}
|
|
4698
|
-
else {
|
|
4699
|
-
return create ? eventer.__bubbleMap = {} : empty;
|
|
4700
|
-
}
|
|
4701
|
-
}
|
|
4702
|
-
}
|
|
4703
|
-
|
|
4704
4632
|
class Event {
|
|
4705
4633
|
constructor(type, target) {
|
|
4706
4634
|
this.bubbles = false;
|
|
@@ -4735,7 +4663,10 @@ var LeaferUI = (function (exports) {
|
|
|
4735
4663
|
}
|
|
4736
4664
|
ChildEvent.ADD = 'child.add';
|
|
4737
4665
|
ChildEvent.REMOVE = 'child.remove';
|
|
4738
|
-
ChildEvent.
|
|
4666
|
+
ChildEvent.CREATED = 'created';
|
|
4667
|
+
ChildEvent.MOUNTED = 'mounted';
|
|
4668
|
+
ChildEvent.UNMOUNTED = 'unmounted';
|
|
4669
|
+
ChildEvent.DESTROY = 'destroy';
|
|
4739
4670
|
|
|
4740
4671
|
class PropertyEvent extends Event {
|
|
4741
4672
|
constructor(type, target, attrName, oldValue, newValue) {
|
|
@@ -4813,10 +4744,6 @@ var LeaferUI = (function (exports) {
|
|
|
4813
4744
|
LayoutEvent.AGAIN = 'layout.again';
|
|
4814
4745
|
LayoutEvent.END = 'layout.end';
|
|
4815
4746
|
|
|
4816
|
-
class AnimateEvent extends Event {
|
|
4817
|
-
}
|
|
4818
|
-
AnimateEvent.FRAME = 'animate.frame';
|
|
4819
|
-
|
|
4820
4747
|
class RenderEvent extends Event {
|
|
4821
4748
|
constructor(type, times, bounds, options) {
|
|
4822
4749
|
super(type);
|
|
@@ -4849,6 +4776,157 @@ var LeaferUI = (function (exports) {
|
|
|
4849
4776
|
LeaferEvent.RESTART = 'leafer.restart';
|
|
4850
4777
|
LeaferEvent.END = 'leafer.end';
|
|
4851
4778
|
|
|
4779
|
+
const empty = {};
|
|
4780
|
+
class Eventer {
|
|
4781
|
+
set event(map) { this.on(map); }
|
|
4782
|
+
on(type, listener, options) {
|
|
4783
|
+
if (!listener) {
|
|
4784
|
+
let event, map = type;
|
|
4785
|
+
for (let key in map)
|
|
4786
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
|
|
4787
|
+
return;
|
|
4788
|
+
}
|
|
4789
|
+
let capture, once;
|
|
4790
|
+
if (options) {
|
|
4791
|
+
if (options === 'once') {
|
|
4792
|
+
once = true;
|
|
4793
|
+
}
|
|
4794
|
+
else if (typeof options === 'boolean') {
|
|
4795
|
+
capture = options;
|
|
4796
|
+
}
|
|
4797
|
+
else {
|
|
4798
|
+
capture = options.capture;
|
|
4799
|
+
once = options.once;
|
|
4800
|
+
}
|
|
4801
|
+
}
|
|
4802
|
+
let events;
|
|
4803
|
+
const map = __getListenerMap(this, capture, true);
|
|
4804
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4805
|
+
const item = once ? { listener, once } : { listener };
|
|
4806
|
+
typeList.forEach(type => {
|
|
4807
|
+
if (type) {
|
|
4808
|
+
events = map[type];
|
|
4809
|
+
if (events) {
|
|
4810
|
+
if (events.findIndex(item => item.listener === listener) === -1)
|
|
4811
|
+
events.push(item);
|
|
4812
|
+
}
|
|
4813
|
+
else {
|
|
4814
|
+
map[type] = [item];
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
});
|
|
4818
|
+
}
|
|
4819
|
+
off(type, listener, options) {
|
|
4820
|
+
if (type) {
|
|
4821
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4822
|
+
if (listener) {
|
|
4823
|
+
let capture;
|
|
4824
|
+
if (options)
|
|
4825
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4826
|
+
let events, index;
|
|
4827
|
+
const map = __getListenerMap(this, capture);
|
|
4828
|
+
typeList.forEach(type => {
|
|
4829
|
+
if (type) {
|
|
4830
|
+
events = map[type];
|
|
4831
|
+
if (events) {
|
|
4832
|
+
index = events.findIndex(item => item.listener === listener);
|
|
4833
|
+
if (index > -1)
|
|
4834
|
+
events.splice(index, 1);
|
|
4835
|
+
if (!events.length)
|
|
4836
|
+
delete map[type];
|
|
4837
|
+
}
|
|
4838
|
+
}
|
|
4839
|
+
});
|
|
4840
|
+
}
|
|
4841
|
+
else {
|
|
4842
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4843
|
+
typeList.forEach(type => {
|
|
4844
|
+
if (b)
|
|
4845
|
+
delete b[type];
|
|
4846
|
+
if (c)
|
|
4847
|
+
delete c[type];
|
|
4848
|
+
});
|
|
4849
|
+
}
|
|
4850
|
+
}
|
|
4851
|
+
else {
|
|
4852
|
+
this.__bubbleMap = this.__captureMap = undefined;
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
on_(type, listener, bind, options) {
|
|
4856
|
+
if (bind)
|
|
4857
|
+
listener = listener.bind(bind);
|
|
4858
|
+
this.on(type, listener, options);
|
|
4859
|
+
return { type, current: this, listener, options };
|
|
4860
|
+
}
|
|
4861
|
+
off_(id) {
|
|
4862
|
+
if (!id)
|
|
4863
|
+
return;
|
|
4864
|
+
const list = id instanceof Array ? id : [id];
|
|
4865
|
+
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
4866
|
+
list.length = 0;
|
|
4867
|
+
}
|
|
4868
|
+
once(type, listener, capture) {
|
|
4869
|
+
this.on(type, listener, { once: true, capture });
|
|
4870
|
+
}
|
|
4871
|
+
emit(type, event, capture) {
|
|
4872
|
+
if (!event && EventCreator.has(type))
|
|
4873
|
+
event = EventCreator.get(type, { type, target: this, current: this });
|
|
4874
|
+
const map = __getListenerMap(this, capture);
|
|
4875
|
+
const list = map[type];
|
|
4876
|
+
if (list) {
|
|
4877
|
+
let item;
|
|
4878
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
4879
|
+
item = list[i];
|
|
4880
|
+
item.listener(event);
|
|
4881
|
+
if (item.once) {
|
|
4882
|
+
this.off(type, item.listener, capture);
|
|
4883
|
+
i--, len--;
|
|
4884
|
+
}
|
|
4885
|
+
if (event && event.isStopNow)
|
|
4886
|
+
break;
|
|
4887
|
+
}
|
|
4888
|
+
}
|
|
4889
|
+
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4890
|
+
}
|
|
4891
|
+
emitEvent(event, capture) {
|
|
4892
|
+
event.current = this;
|
|
4893
|
+
this.emit(event.type, event, capture);
|
|
4894
|
+
}
|
|
4895
|
+
hasEvent(type, capture) {
|
|
4896
|
+
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4897
|
+
return true;
|
|
4898
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4899
|
+
const hasB = b && b[type], hasC = c && c[type];
|
|
4900
|
+
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
4901
|
+
}
|
|
4902
|
+
destroy() {
|
|
4903
|
+
this.__captureMap = this.__bubbleMap = this.syncEventer = null;
|
|
4904
|
+
}
|
|
4905
|
+
}
|
|
4906
|
+
function __getListenerMap(eventer, capture, create) {
|
|
4907
|
+
if (capture) {
|
|
4908
|
+
const { __captureMap: c } = eventer;
|
|
4909
|
+
if (c) {
|
|
4910
|
+
return c;
|
|
4911
|
+
}
|
|
4912
|
+
else {
|
|
4913
|
+
return create ? eventer.__captureMap = {} : empty;
|
|
4914
|
+
}
|
|
4915
|
+
}
|
|
4916
|
+
else {
|
|
4917
|
+
const { __bubbleMap: b } = eventer;
|
|
4918
|
+
if (b) {
|
|
4919
|
+
return b;
|
|
4920
|
+
}
|
|
4921
|
+
else {
|
|
4922
|
+
return create ? eventer.__bubbleMap = {} : empty;
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
}
|
|
4926
|
+
|
|
4927
|
+
const { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroy } = Eventer.prototype;
|
|
4928
|
+
const LeafEventer = { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroyEventer: destroy };
|
|
4929
|
+
|
|
4852
4930
|
const { isFinite } = Number;
|
|
4853
4931
|
const debug$5 = Debug.get('setAttr');
|
|
4854
4932
|
const LeafDataProxy = {
|
|
@@ -4860,9 +4938,7 @@ var LeaferUI = (function (exports) {
|
|
|
4860
4938
|
newValue = undefined;
|
|
4861
4939
|
}
|
|
4862
4940
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
4863
|
-
this.
|
|
4864
|
-
if (this.__proxyData)
|
|
4865
|
-
this.setProxyAttr(name, newValue);
|
|
4941
|
+
this.__realSetAttr(name, newValue);
|
|
4866
4942
|
const { CHANGE } = PropertyEvent;
|
|
4867
4943
|
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
|
|
4868
4944
|
if (this.isLeafer) {
|
|
@@ -4880,12 +4956,18 @@ var LeaferUI = (function (exports) {
|
|
|
4880
4956
|
}
|
|
4881
4957
|
}
|
|
4882
4958
|
else {
|
|
4883
|
-
this.
|
|
4884
|
-
if (this.__proxyData)
|
|
4885
|
-
this.setProxyAttr(name, newValue);
|
|
4959
|
+
this.__realSetAttr(name, newValue);
|
|
4886
4960
|
return true;
|
|
4887
4961
|
}
|
|
4888
4962
|
},
|
|
4963
|
+
__realSetAttr(name, newValue) {
|
|
4964
|
+
const data = this.__;
|
|
4965
|
+
data[name] = newValue;
|
|
4966
|
+
if (this.__proxyData)
|
|
4967
|
+
this.setProxyAttr(name, newValue);
|
|
4968
|
+
if (data.normalStyle)
|
|
4969
|
+
this.lockNormalStyle || data.normalStyle[name] === undefined || (data.normalStyle[name] = newValue);
|
|
4970
|
+
},
|
|
4889
4971
|
__getAttr(name) {
|
|
4890
4972
|
if (this.__proxyData)
|
|
4891
4973
|
return this.getProxyAttr(name);
|
|
@@ -4921,7 +5003,7 @@ var LeaferUI = (function (exports) {
|
|
|
4921
5003
|
|
|
4922
5004
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4923
5005
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4924
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
5006
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$4 } = BoundsHelper;
|
|
4925
5007
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4926
5008
|
const LeafBounds = {
|
|
4927
5009
|
__updateWorldBounds() {
|
|
@@ -4988,6 +5070,8 @@ var LeaferUI = (function (exports) {
|
|
|
4988
5070
|
layout.boundsChanged = false;
|
|
4989
5071
|
},
|
|
4990
5072
|
__updateLocalBoxBounds() {
|
|
5073
|
+
if (this.__hasMotionPath)
|
|
5074
|
+
this.__updateMotionPath();
|
|
4991
5075
|
if (this.__hasAutoLayout)
|
|
4992
5076
|
this.__updateAutoLayout();
|
|
4993
5077
|
toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
|
|
@@ -5022,7 +5106,7 @@ var LeaferUI = (function (exports) {
|
|
|
5022
5106
|
updateAllMatrix$2(this);
|
|
5023
5107
|
updateBounds$1(this, this);
|
|
5024
5108
|
if (this.__.__autoSide)
|
|
5025
|
-
this.__updateBoxBounds();
|
|
5109
|
+
this.__updateBoxBounds(true);
|
|
5026
5110
|
}
|
|
5027
5111
|
else {
|
|
5028
5112
|
updateAllMatrix$2(this);
|
|
@@ -5040,11 +5124,11 @@ var LeaferUI = (function (exports) {
|
|
|
5040
5124
|
},
|
|
5041
5125
|
__updateStrokeBounds() {
|
|
5042
5126
|
const layout = this.__layout;
|
|
5043
|
-
copyAndSpread$
|
|
5127
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5044
5128
|
},
|
|
5045
5129
|
__updateRenderBounds() {
|
|
5046
5130
|
const layout = this.__layout;
|
|
5047
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5131
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$4(layout.renderBounds, layout.strokeBounds);
|
|
5048
5132
|
}
|
|
5049
5133
|
};
|
|
5050
5134
|
|
|
@@ -5140,7 +5224,7 @@ var LeaferUI = (function (exports) {
|
|
|
5140
5224
|
const { LEAF, create } = IncrementId;
|
|
5141
5225
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5142
5226
|
const { toOuterOf } = BoundsHelper;
|
|
5143
|
-
const { copy: copy$3 } = PointHelper;
|
|
5227
|
+
const { copy: copy$3, move } = PointHelper;
|
|
5144
5228
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5145
5229
|
exports.Leaf = class Leaf {
|
|
5146
5230
|
get tag() { return this.__tag; }
|
|
@@ -5167,13 +5251,16 @@ var LeaferUI = (function (exports) {
|
|
|
5167
5251
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5168
5252
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5169
5253
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5170
|
-
set event(map) {
|
|
5171
|
-
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
|
|
5254
|
+
set event(map) { this.on(map); }
|
|
5172
5255
|
constructor(data) {
|
|
5173
5256
|
this.innerId = create(LEAF);
|
|
5174
5257
|
this.reset(data);
|
|
5258
|
+
if (this.__bubbleMap)
|
|
5259
|
+
this.__emitLifeEvent(ChildEvent.CREATED);
|
|
5175
5260
|
}
|
|
5176
5261
|
reset(data) {
|
|
5262
|
+
if (this.leafer)
|
|
5263
|
+
this.leafer.forceRender(this.__world);
|
|
5177
5264
|
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 };
|
|
5178
5265
|
if (data !== null)
|
|
5179
5266
|
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -5195,12 +5282,12 @@ var LeaferUI = (function (exports) {
|
|
|
5195
5282
|
waitParent(item, bind) {
|
|
5196
5283
|
if (bind)
|
|
5197
5284
|
item = item.bind(bind);
|
|
5198
|
-
this.parent ? item() :
|
|
5285
|
+
this.parent ? item() : this.on(ChildEvent.ADD, item, 'once');
|
|
5199
5286
|
}
|
|
5200
5287
|
waitLeafer(item, bind) {
|
|
5201
5288
|
if (bind)
|
|
5202
5289
|
item = item.bind(bind);
|
|
5203
|
-
this.leafer ? item() :
|
|
5290
|
+
this.leafer ? item() : this.on(ChildEvent.MOUNTED, item, 'once');
|
|
5204
5291
|
}
|
|
5205
5292
|
nextRender(item, bind, off) {
|
|
5206
5293
|
this.leafer ? this.leafer.nextRender(item, bind, off) : this.waitLeafer(() => this.leafer.nextRender(item, bind, off));
|
|
@@ -5209,18 +5296,21 @@ var LeaferUI = (function (exports) {
|
|
|
5209
5296
|
this.nextRender(item, null, 'off');
|
|
5210
5297
|
}
|
|
5211
5298
|
__bindLeafer(leafer) {
|
|
5212
|
-
if (this.isLeafer)
|
|
5213
|
-
|
|
5214
|
-
leafer = this;
|
|
5215
|
-
}
|
|
5299
|
+
if (this.isLeafer && leafer !== null)
|
|
5300
|
+
leafer = this;
|
|
5216
5301
|
if (this.leafer && !leafer)
|
|
5217
5302
|
this.leafer.leafs--;
|
|
5218
5303
|
this.leafer = leafer;
|
|
5219
5304
|
if (leafer) {
|
|
5220
5305
|
leafer.leafs++;
|
|
5221
5306
|
this.__level = this.parent ? this.parent.__level + 1 : 1;
|
|
5222
|
-
if (this.
|
|
5223
|
-
|
|
5307
|
+
if (this.animation)
|
|
5308
|
+
this.__runAnimation('in');
|
|
5309
|
+
if (this.__bubbleMap)
|
|
5310
|
+
this.__emitLifeEvent(ChildEvent.MOUNTED);
|
|
5311
|
+
}
|
|
5312
|
+
else {
|
|
5313
|
+
this.__emitLifeEvent(ChildEvent.UNMOUNTED);
|
|
5224
5314
|
}
|
|
5225
5315
|
if (this.isBranch) {
|
|
5226
5316
|
const { children } = this;
|
|
@@ -5229,7 +5319,7 @@ var LeaferUI = (function (exports) {
|
|
|
5229
5319
|
}
|
|
5230
5320
|
}
|
|
5231
5321
|
}
|
|
5232
|
-
set(_data) { }
|
|
5322
|
+
set(_data, _isTemp) { }
|
|
5233
5323
|
get(_name) { return undefined; }
|
|
5234
5324
|
setAttr(name, value) { this[name] = value; }
|
|
5235
5325
|
getAttr(name) { return this[name]; }
|
|
@@ -5254,6 +5344,7 @@ var LeaferUI = (function (exports) {
|
|
|
5254
5344
|
findOne(_condition, _options) { return undefined; }
|
|
5255
5345
|
findId(_id) { return undefined; }
|
|
5256
5346
|
focus(_value) { }
|
|
5347
|
+
updateState() { }
|
|
5257
5348
|
updateLayout() {
|
|
5258
5349
|
this.__layout.update();
|
|
5259
5350
|
}
|
|
@@ -5361,11 +5452,24 @@ var LeaferUI = (function (exports) {
|
|
|
5361
5452
|
if (relative)
|
|
5362
5453
|
relative.worldToInner(to ? to : inner, null, distance);
|
|
5363
5454
|
}
|
|
5455
|
+
getBoxPoint(world, relative, distance, change) {
|
|
5456
|
+
return this.getBoxPointByInner(this.getInnerPoint(world, relative, distance, change), null, null, true);
|
|
5457
|
+
}
|
|
5458
|
+
getBoxPointByInner(inner, _relative, _distance, change) {
|
|
5459
|
+
const point = change ? inner : Object.assign({}, inner), { x, y } = this.boxBounds;
|
|
5460
|
+
move(point, -x, -y);
|
|
5461
|
+
return point;
|
|
5462
|
+
}
|
|
5364
5463
|
getInnerPoint(world, relative, distance, change) {
|
|
5365
5464
|
const point = change ? world : {};
|
|
5366
5465
|
this.worldToInner(world, point, distance, relative);
|
|
5367
5466
|
return point;
|
|
5368
5467
|
}
|
|
5468
|
+
getInnerPointByBox(box, _relative, _distance, change) {
|
|
5469
|
+
const point = change ? box : Object.assign({}, box), { x, y } = this.boxBounds;
|
|
5470
|
+
move(point, x, y);
|
|
5471
|
+
return point;
|
|
5472
|
+
}
|
|
5369
5473
|
getInnerPointByLocal(local, _relative, distance, change) {
|
|
5370
5474
|
return this.getInnerPoint(local, this.parent, distance, change);
|
|
5371
5475
|
}
|
|
@@ -5377,20 +5481,23 @@ var LeaferUI = (function (exports) {
|
|
|
5377
5481
|
getLocalPointByInner(inner, _relative, distance, change) {
|
|
5378
5482
|
return this.getWorldPoint(inner, this.parent, distance, change);
|
|
5379
5483
|
}
|
|
5484
|
+
getPagePoint(world, relative, distance, change) {
|
|
5485
|
+
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5486
|
+
return layer.getInnerPoint(world, relative, distance, change);
|
|
5487
|
+
}
|
|
5380
5488
|
getWorldPoint(inner, relative, distance, change) {
|
|
5381
5489
|
const point = change ? inner : {};
|
|
5382
5490
|
this.innerToWorld(inner, point, distance, relative);
|
|
5383
5491
|
return point;
|
|
5384
5492
|
}
|
|
5493
|
+
getWorldPointByBox(box, relative, distance, change) {
|
|
5494
|
+
return this.getWorldPoint(this.getInnerPointByBox(box, null, null, change), relative, distance, true);
|
|
5495
|
+
}
|
|
5385
5496
|
getWorldPointByLocal(local, relative, distance, change) {
|
|
5386
5497
|
const point = change ? local : {};
|
|
5387
5498
|
this.localToWorld(local, point, distance, relative);
|
|
5388
5499
|
return point;
|
|
5389
5500
|
}
|
|
5390
|
-
getPagePoint(world, relative, distance, change) {
|
|
5391
|
-
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5392
|
-
return layer.getInnerPoint(world, relative, distance, change);
|
|
5393
|
-
}
|
|
5394
5501
|
getWorldPointByPage(page, relative, distance, change) {
|
|
5395
5502
|
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5396
5503
|
return layer.getWorldPoint(page, relative, distance, change);
|
|
@@ -5404,6 +5511,9 @@ var LeaferUI = (function (exports) {
|
|
|
5404
5511
|
move(x, y) {
|
|
5405
5512
|
moveLocal(this, x, y);
|
|
5406
5513
|
}
|
|
5514
|
+
moveInner(x, y) {
|
|
5515
|
+
moveWorld(this, x, y, true);
|
|
5516
|
+
}
|
|
5407
5517
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5408
5518
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5409
5519
|
}
|
|
@@ -5456,6 +5566,17 @@ var LeaferUI = (function (exports) {
|
|
|
5456
5566
|
__drawRenderPath(_canvas) { }
|
|
5457
5567
|
__updatePath() { }
|
|
5458
5568
|
__updateRenderPath() { }
|
|
5569
|
+
getMotionPathData() {
|
|
5570
|
+
return needPlugin('path');
|
|
5571
|
+
}
|
|
5572
|
+
getMotionPoint(_motionDistance) {
|
|
5573
|
+
return needPlugin('path');
|
|
5574
|
+
}
|
|
5575
|
+
getMotionTotal() {
|
|
5576
|
+
return 0;
|
|
5577
|
+
}
|
|
5578
|
+
__updateMotionPath() { }
|
|
5579
|
+
__runAnimation(_type, _complete) { }
|
|
5459
5580
|
__updateSortChildren() { }
|
|
5460
5581
|
add(_child, _index) { }
|
|
5461
5582
|
remove(_child, destroy) {
|
|
@@ -5481,6 +5602,10 @@ var LeaferUI = (function (exports) {
|
|
|
5481
5602
|
fn = boundsType;
|
|
5482
5603
|
fn(defaultValue)(this.prototype, attrName);
|
|
5483
5604
|
}
|
|
5605
|
+
__emitLifeEvent(type) {
|
|
5606
|
+
if (this.hasEvent(type))
|
|
5607
|
+
this.emitEvent(new ChildEvent(type, this, this.parent));
|
|
5608
|
+
}
|
|
5484
5609
|
destroy() {
|
|
5485
5610
|
if (!this.destroyed) {
|
|
5486
5611
|
const { parent } = this;
|
|
@@ -5488,11 +5613,10 @@ var LeaferUI = (function (exports) {
|
|
|
5488
5613
|
this.remove();
|
|
5489
5614
|
if (this.children)
|
|
5490
5615
|
this.removeAll(true);
|
|
5491
|
-
|
|
5492
|
-
this.emitEvent(new ChildEvent(ChildEvent.DESTROY, this, parent));
|
|
5616
|
+
this.__emitLifeEvent(ChildEvent.DESTROY);
|
|
5493
5617
|
this.__.destroy();
|
|
5494
5618
|
this.__layout.destroy();
|
|
5495
|
-
this.
|
|
5619
|
+
this.destroyEventer();
|
|
5496
5620
|
this.destroyed = true;
|
|
5497
5621
|
}
|
|
5498
5622
|
}
|
|
@@ -5558,8 +5682,8 @@ var LeaferUI = (function (exports) {
|
|
|
5558
5682
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5559
5683
|
child.__layout.boxChanged || child.__layout.boxChange();
|
|
5560
5684
|
child.__layout.matrixChanged || child.__layout.matrixChange();
|
|
5561
|
-
if (child.
|
|
5562
|
-
|
|
5685
|
+
if (child.__bubbleMap)
|
|
5686
|
+
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5563
5687
|
if (this.leafer) {
|
|
5564
5688
|
child.__bindLeafer(this.leafer);
|
|
5565
5689
|
if (this.leafer.created)
|
|
@@ -5572,16 +5696,10 @@ var LeaferUI = (function (exports) {
|
|
|
5572
5696
|
}
|
|
5573
5697
|
remove(child, destroy) {
|
|
5574
5698
|
if (child) {
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1;
|
|
5580
|
-
this.__preRemove();
|
|
5581
|
-
this.__realRemoveChild(child);
|
|
5582
|
-
if (destroy)
|
|
5583
|
-
child.destroy();
|
|
5584
|
-
}
|
|
5699
|
+
if (child.animationOut)
|
|
5700
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5701
|
+
else
|
|
5702
|
+
this.__remove(child, destroy);
|
|
5585
5703
|
}
|
|
5586
5704
|
else if (child === undefined) {
|
|
5587
5705
|
super.remove(null, destroy);
|
|
@@ -5603,6 +5721,18 @@ var LeaferUI = (function (exports) {
|
|
|
5603
5721
|
clear() {
|
|
5604
5722
|
this.removeAll(true);
|
|
5605
5723
|
}
|
|
5724
|
+
__remove(child, destroy) {
|
|
5725
|
+
const index = this.children.indexOf(child);
|
|
5726
|
+
if (index > -1) {
|
|
5727
|
+
this.children.splice(index, 1);
|
|
5728
|
+
if (child.isBranch)
|
|
5729
|
+
this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1;
|
|
5730
|
+
this.__preRemove();
|
|
5731
|
+
this.__realRemoveChild(child);
|
|
5732
|
+
if (destroy)
|
|
5733
|
+
child.destroy();
|
|
5734
|
+
}
|
|
5735
|
+
}
|
|
5606
5736
|
__preRemove() {
|
|
5607
5737
|
if (this.__hasMask)
|
|
5608
5738
|
this.__updateMask();
|
|
@@ -5612,6 +5742,7 @@ var LeaferUI = (function (exports) {
|
|
|
5612
5742
|
this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
|
|
5613
5743
|
}
|
|
5614
5744
|
__realRemoveChild(child) {
|
|
5745
|
+
child.__emitLifeEvent(ChildEvent.REMOVE);
|
|
5615
5746
|
child.parent = null;
|
|
5616
5747
|
if (this.leafer) {
|
|
5617
5748
|
child.__bindLeafer(null);
|
|
@@ -5624,8 +5755,6 @@ var LeaferUI = (function (exports) {
|
|
|
5624
5755
|
}
|
|
5625
5756
|
__emitChildEvent(type, child) {
|
|
5626
5757
|
const event = new ChildEvent(type, child, this);
|
|
5627
|
-
if (child.hasEvent(type))
|
|
5628
|
-
child.emitEvent(event);
|
|
5629
5758
|
if (this.hasEvent(type) && !this.isLeafer)
|
|
5630
5759
|
this.emitEvent(event);
|
|
5631
5760
|
this.leafer.emitEvent(event);
|
|
@@ -5788,8 +5917,7 @@ var LeaferUI = (function (exports) {
|
|
|
5788
5917
|
}
|
|
5789
5918
|
}
|
|
5790
5919
|
|
|
5791
|
-
const version = "1.0.
|
|
5792
|
-
const inviteCode = {};
|
|
5920
|
+
const version = "1.0.3";
|
|
5793
5921
|
|
|
5794
5922
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5795
5923
|
get allowBackgroundColor() { return true; }
|
|
@@ -6016,9 +6144,13 @@ var LeaferUI = (function (exports) {
|
|
|
6016
6144
|
});
|
|
6017
6145
|
}
|
|
6018
6146
|
function updateChange(updateList) {
|
|
6147
|
+
let layout;
|
|
6019
6148
|
updateList.list.forEach(leaf => {
|
|
6020
|
-
|
|
6149
|
+
layout = leaf.__layout;
|
|
6150
|
+
if (layout.opacityChanged)
|
|
6021
6151
|
updateAllWorldOpacity(leaf);
|
|
6152
|
+
if (layout.stateStyleChanged)
|
|
6153
|
+
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
6022
6154
|
leaf.__updateChange();
|
|
6023
6155
|
});
|
|
6024
6156
|
}
|
|
@@ -6384,7 +6516,6 @@ var LeaferUI = (function (exports) {
|
|
|
6384
6516
|
Platform.requestRender(() => {
|
|
6385
6517
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
|
|
6386
6518
|
if (this.running) {
|
|
6387
|
-
this.target.emit(AnimateEvent.FRAME);
|
|
6388
6519
|
if (this.changed && this.canvas.view)
|
|
6389
6520
|
this.render();
|
|
6390
6521
|
this.target.emit(RenderEvent.NEXT);
|
|
@@ -6458,36 +6589,6 @@ var LeaferUI = (function (exports) {
|
|
|
6458
6589
|
});
|
|
6459
6590
|
Platform.layout = Layouter.fullLayout;
|
|
6460
6591
|
|
|
6461
|
-
const TextConvert = {};
|
|
6462
|
-
const ColorConvert = {};
|
|
6463
|
-
const PathArrow = {};
|
|
6464
|
-
const Paint = {};
|
|
6465
|
-
const PaintImage = {};
|
|
6466
|
-
const PaintGradient = {};
|
|
6467
|
-
const Effect = {};
|
|
6468
|
-
const Export = {};
|
|
6469
|
-
const State = {};
|
|
6470
|
-
|
|
6471
|
-
function stateType(defaultValue) {
|
|
6472
|
-
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6473
|
-
set(value) {
|
|
6474
|
-
this.__setAttr(key, value);
|
|
6475
|
-
this.waitLeafer(() => { if (State.setStyle)
|
|
6476
|
-
State.setStyle(this, key + 'Style', value); });
|
|
6477
|
-
}
|
|
6478
|
-
}));
|
|
6479
|
-
}
|
|
6480
|
-
function arrowType(defaultValue) {
|
|
6481
|
-
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6482
|
-
set(value) {
|
|
6483
|
-
if (this.__setAttr(key, value)) {
|
|
6484
|
-
const data = this.__;
|
|
6485
|
-
data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
|
|
6486
|
-
doStrokeType(this);
|
|
6487
|
-
}
|
|
6488
|
-
}
|
|
6489
|
-
}));
|
|
6490
|
-
}
|
|
6491
6592
|
function effectType(defaultValue) {
|
|
6492
6593
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6493
6594
|
set(value) {
|
|
@@ -6522,10 +6623,33 @@ var LeaferUI = (function (exports) {
|
|
|
6522
6623
|
};
|
|
6523
6624
|
}
|
|
6524
6625
|
|
|
6626
|
+
const TextConvert = {};
|
|
6627
|
+
const ColorConvert = {};
|
|
6628
|
+
const PathArrow = {};
|
|
6629
|
+
const Paint = {};
|
|
6630
|
+
const PaintImage = {};
|
|
6631
|
+
const PaintGradient = {};
|
|
6632
|
+
const Effect = {};
|
|
6633
|
+
const Export = {};
|
|
6634
|
+
const State = {
|
|
6635
|
+
setStyleName(_leaf, _styleName, _value) { return needPlugin('state'); },
|
|
6636
|
+
set(_leaf, _stateName) { return needPlugin('state'); }
|
|
6637
|
+
};
|
|
6638
|
+
const Transition = {
|
|
6639
|
+
list: {},
|
|
6640
|
+
register(attrName, fn) {
|
|
6641
|
+
Transition.list[attrName] = fn;
|
|
6642
|
+
},
|
|
6643
|
+
get(attrName) {
|
|
6644
|
+
return Transition.list[attrName];
|
|
6645
|
+
}
|
|
6646
|
+
};
|
|
6647
|
+
|
|
6525
6648
|
const { parse } = PathConvert;
|
|
6526
6649
|
const emptyPaint = {};
|
|
6527
6650
|
const debug$2 = Debug.get('UIData');
|
|
6528
6651
|
class UIData extends LeafData {
|
|
6652
|
+
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
6529
6653
|
get __strokeWidth() {
|
|
6530
6654
|
const { strokeWidth, strokeWidthFixed } = this;
|
|
6531
6655
|
if (strokeWidthFixed) {
|
|
@@ -6544,9 +6668,10 @@ var LeaferUI = (function (exports) {
|
|
|
6544
6668
|
get __autoSide() { return !this._width || !this._height; }
|
|
6545
6669
|
get __autoSize() { return !this._width && !this._height; }
|
|
6546
6670
|
setVisible(value) {
|
|
6547
|
-
if (this.__leaf.leafer)
|
|
6548
|
-
this.__leaf.leafer.watcher.hasVisible = true;
|
|
6549
6671
|
this._visible = value;
|
|
6672
|
+
const { leafer } = this.__leaf;
|
|
6673
|
+
if (leafer)
|
|
6674
|
+
leafer.watcher.hasVisible = true;
|
|
6550
6675
|
}
|
|
6551
6676
|
setWidth(value) {
|
|
6552
6677
|
if (value < 0) {
|
|
@@ -6670,6 +6795,11 @@ var LeaferUI = (function (exports) {
|
|
|
6670
6795
|
}
|
|
6671
6796
|
|
|
6672
6797
|
class LeaferData extends GroupData {
|
|
6798
|
+
__getInputData() {
|
|
6799
|
+
const data = super.__getInputData();
|
|
6800
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
6801
|
+
return data;
|
|
6802
|
+
}
|
|
6673
6803
|
}
|
|
6674
6804
|
|
|
6675
6805
|
class FrameData extends BoxData {
|
|
@@ -6732,7 +6862,7 @@ var LeaferUI = (function (exports) {
|
|
|
6732
6862
|
__setImageFill(value) {
|
|
6733
6863
|
if (this.__leaf.image)
|
|
6734
6864
|
this.__leaf.image = null;
|
|
6735
|
-
this.fill = value ? { type: 'image', mode: '
|
|
6865
|
+
this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
|
|
6736
6866
|
}
|
|
6737
6867
|
__getData() {
|
|
6738
6868
|
const data = super.__getData();
|
|
@@ -6747,6 +6877,11 @@ var LeaferUI = (function (exports) {
|
|
|
6747
6877
|
}
|
|
6748
6878
|
|
|
6749
6879
|
class CanvasData extends RectData {
|
|
6880
|
+
__getInputData() {
|
|
6881
|
+
const data = super.__getInputData();
|
|
6882
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
6883
|
+
return data;
|
|
6884
|
+
}
|
|
6750
6885
|
}
|
|
6751
6886
|
|
|
6752
6887
|
const UIBounds = {
|
|
@@ -6917,19 +7052,8 @@ var LeaferUI = (function (exports) {
|
|
|
6917
7052
|
exports.UI = UI_1 = class UI extends exports.Leaf {
|
|
6918
7053
|
get app() { return this.leafer && this.leafer.app; }
|
|
6919
7054
|
get isFrame() { return false; }
|
|
6920
|
-
set scale(value) {
|
|
6921
|
-
|
|
6922
|
-
this.scaleX = this.scaleY = value;
|
|
6923
|
-
}
|
|
6924
|
-
else {
|
|
6925
|
-
this.scaleX = value.x;
|
|
6926
|
-
this.scaleY = value.y;
|
|
6927
|
-
}
|
|
6928
|
-
}
|
|
6929
|
-
get scale() {
|
|
6930
|
-
const { scaleX, scaleY } = this;
|
|
6931
|
-
return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
|
|
6932
|
-
}
|
|
7055
|
+
set scale(value) { MathHelper.assignScale(this, value); }
|
|
7056
|
+
get scale() { return this.__.scale; }
|
|
6933
7057
|
get pen() {
|
|
6934
7058
|
const { path } = this.__;
|
|
6935
7059
|
pen.set(this.path = path || []);
|
|
@@ -6944,8 +7068,15 @@ var LeaferUI = (function (exports) {
|
|
|
6944
7068
|
super(data);
|
|
6945
7069
|
}
|
|
6946
7070
|
reset(_data) { }
|
|
6947
|
-
set(data) {
|
|
6948
|
-
|
|
7071
|
+
set(data, isTemp) {
|
|
7072
|
+
if (isTemp) {
|
|
7073
|
+
this.lockNormalStyle = true;
|
|
7074
|
+
Object.assign(this, data);
|
|
7075
|
+
this.lockNormalStyle = false;
|
|
7076
|
+
}
|
|
7077
|
+
else {
|
|
7078
|
+
Object.assign(this, data);
|
|
7079
|
+
}
|
|
6949
7080
|
}
|
|
6950
7081
|
get(name) {
|
|
6951
7082
|
return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
@@ -7008,11 +7139,18 @@ var LeaferUI = (function (exports) {
|
|
|
7008
7139
|
drawer.rect(x, y, width, height);
|
|
7009
7140
|
}
|
|
7010
7141
|
}
|
|
7142
|
+
animate(_keyframe, _options, _type, _isTemp) {
|
|
7143
|
+
return needPlugin('animate');
|
|
7144
|
+
}
|
|
7145
|
+
killAnimate(_type) { }
|
|
7011
7146
|
export(filename, options) {
|
|
7012
7147
|
return Export.export(this, filename, options);
|
|
7013
7148
|
}
|
|
7014
|
-
clone() {
|
|
7015
|
-
|
|
7149
|
+
clone(newData) {
|
|
7150
|
+
const json = this.toJSON();
|
|
7151
|
+
if (newData)
|
|
7152
|
+
Object.assign(json, newData);
|
|
7153
|
+
return UI_1.one(json);
|
|
7016
7154
|
}
|
|
7017
7155
|
static one(data, x, y, width, height) {
|
|
7018
7156
|
return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
|
|
@@ -7028,6 +7166,8 @@ var LeaferUI = (function (exports) {
|
|
|
7028
7166
|
static setEditInner(_editorName) { }
|
|
7029
7167
|
destroy() {
|
|
7030
7168
|
this.fill = this.stroke = null;
|
|
7169
|
+
if (this.__animate)
|
|
7170
|
+
this.killAnimate();
|
|
7031
7171
|
super.destroy();
|
|
7032
7172
|
}
|
|
7033
7173
|
};
|
|
@@ -7055,12 +7195,6 @@ var LeaferUI = (function (exports) {
|
|
|
7055
7195
|
__decorate([
|
|
7056
7196
|
visibleType(true)
|
|
7057
7197
|
], exports.UI.prototype, "visible", void 0);
|
|
7058
|
-
__decorate([
|
|
7059
|
-
stateType(false)
|
|
7060
|
-
], exports.UI.prototype, "selected", void 0);
|
|
7061
|
-
__decorate([
|
|
7062
|
-
stateType(false)
|
|
7063
|
-
], exports.UI.prototype, "disabled", void 0);
|
|
7064
7198
|
__decorate([
|
|
7065
7199
|
surfaceType(false)
|
|
7066
7200
|
], exports.UI.prototype, "locked", void 0);
|
|
@@ -7133,45 +7267,9 @@ var LeaferUI = (function (exports) {
|
|
|
7133
7267
|
__decorate([
|
|
7134
7268
|
pathType(true)
|
|
7135
7269
|
], exports.UI.prototype, "closed", void 0);
|
|
7136
|
-
__decorate([
|
|
7137
|
-
autoLayoutType(false)
|
|
7138
|
-
], exports.UI.prototype, "flow", void 0);
|
|
7139
7270
|
__decorate([
|
|
7140
7271
|
boundsType(0)
|
|
7141
7272
|
], exports.UI.prototype, "padding", void 0);
|
|
7142
|
-
__decorate([
|
|
7143
|
-
boundsType(0)
|
|
7144
|
-
], exports.UI.prototype, "gap", void 0);
|
|
7145
|
-
__decorate([
|
|
7146
|
-
boundsType('top-left')
|
|
7147
|
-
], exports.UI.prototype, "flowAlign", void 0);
|
|
7148
|
-
__decorate([
|
|
7149
|
-
boundsType(false)
|
|
7150
|
-
], exports.UI.prototype, "flowWrap", void 0);
|
|
7151
|
-
__decorate([
|
|
7152
|
-
boundsType('box')
|
|
7153
|
-
], exports.UI.prototype, "itemBox", void 0);
|
|
7154
|
-
__decorate([
|
|
7155
|
-
boundsType(true)
|
|
7156
|
-
], exports.UI.prototype, "inFlow", void 0);
|
|
7157
|
-
__decorate([
|
|
7158
|
-
boundsType()
|
|
7159
|
-
], exports.UI.prototype, "autoWidth", void 0);
|
|
7160
|
-
__decorate([
|
|
7161
|
-
boundsType()
|
|
7162
|
-
], exports.UI.prototype, "autoHeight", void 0);
|
|
7163
|
-
__decorate([
|
|
7164
|
-
boundsType()
|
|
7165
|
-
], exports.UI.prototype, "lockRatio", void 0);
|
|
7166
|
-
__decorate([
|
|
7167
|
-
boundsType()
|
|
7168
|
-
], exports.UI.prototype, "autoBox", void 0);
|
|
7169
|
-
__decorate([
|
|
7170
|
-
boundsType()
|
|
7171
|
-
], exports.UI.prototype, "widthRange", void 0);
|
|
7172
|
-
__decorate([
|
|
7173
|
-
boundsType()
|
|
7174
|
-
], exports.UI.prototype, "heightRange", void 0);
|
|
7175
7273
|
__decorate([
|
|
7176
7274
|
dataType(false)
|
|
7177
7275
|
], exports.UI.prototype, "draggable", void 0);
|
|
@@ -7235,12 +7333,6 @@ var LeaferUI = (function (exports) {
|
|
|
7235
7333
|
__decorate([
|
|
7236
7334
|
strokeType(10)
|
|
7237
7335
|
], exports.UI.prototype, "miterLimit", void 0);
|
|
7238
|
-
__decorate([
|
|
7239
|
-
arrowType('none')
|
|
7240
|
-
], exports.UI.prototype, "startArrow", void 0);
|
|
7241
|
-
__decorate([
|
|
7242
|
-
arrowType('none')
|
|
7243
|
-
], exports.UI.prototype, "endArrow", void 0);
|
|
7244
7336
|
__decorate([
|
|
7245
7337
|
pathType(0)
|
|
7246
7338
|
], exports.UI.prototype, "cornerRadius", void 0);
|
|
@@ -7262,24 +7354,6 @@ var LeaferUI = (function (exports) {
|
|
|
7262
7354
|
__decorate([
|
|
7263
7355
|
effectType()
|
|
7264
7356
|
], exports.UI.prototype, "grayscale", void 0);
|
|
7265
|
-
__decorate([
|
|
7266
|
-
dataType()
|
|
7267
|
-
], exports.UI.prototype, "normalStyle", void 0);
|
|
7268
|
-
__decorate([
|
|
7269
|
-
dataType()
|
|
7270
|
-
], exports.UI.prototype, "hoverStyle", void 0);
|
|
7271
|
-
__decorate([
|
|
7272
|
-
dataType()
|
|
7273
|
-
], exports.UI.prototype, "pressStyle", void 0);
|
|
7274
|
-
__decorate([
|
|
7275
|
-
dataType()
|
|
7276
|
-
], exports.UI.prototype, "focusStyle", void 0);
|
|
7277
|
-
__decorate([
|
|
7278
|
-
dataType()
|
|
7279
|
-
], exports.UI.prototype, "selectedStyle", void 0);
|
|
7280
|
-
__decorate([
|
|
7281
|
-
dataType()
|
|
7282
|
-
], exports.UI.prototype, "disabledStyle", void 0);
|
|
7283
7357
|
__decorate([
|
|
7284
7358
|
dataType({})
|
|
7285
7359
|
], exports.UI.prototype, "data", void 0);
|
|
@@ -7306,7 +7380,7 @@ var LeaferUI = (function (exports) {
|
|
|
7306
7380
|
if (!this.children)
|
|
7307
7381
|
this.children = [];
|
|
7308
7382
|
}
|
|
7309
|
-
set(data) {
|
|
7383
|
+
set(data, isTemp) {
|
|
7310
7384
|
if (data.children) {
|
|
7311
7385
|
const { children } = data;
|
|
7312
7386
|
delete data.children;
|
|
@@ -7316,7 +7390,7 @@ var LeaferUI = (function (exports) {
|
|
|
7316
7390
|
else {
|
|
7317
7391
|
this.clear();
|
|
7318
7392
|
}
|
|
7319
|
-
super.set(data);
|
|
7393
|
+
super.set(data, isTemp);
|
|
7320
7394
|
let child;
|
|
7321
7395
|
children.forEach(childData => {
|
|
7322
7396
|
child = childData.__ ? childData : UICreator.get(childData.tag, childData);
|
|
@@ -7325,7 +7399,7 @@ var LeaferUI = (function (exports) {
|
|
|
7325
7399
|
data.children = children;
|
|
7326
7400
|
}
|
|
7327
7401
|
else {
|
|
7328
|
-
super.set(data);
|
|
7402
|
+
super.set(data, isTemp);
|
|
7329
7403
|
}
|
|
7330
7404
|
}
|
|
7331
7405
|
toJSON(options) {
|
|
@@ -7652,13 +7726,20 @@ var LeaferUI = (function (exports) {
|
|
|
7652
7726
|
}
|
|
7653
7727
|
}
|
|
7654
7728
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
7655
|
-
return
|
|
7729
|
+
return needPlugin('view');
|
|
7656
7730
|
}
|
|
7657
7731
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
7658
7732
|
getValidScale(changeScale) { return changeScale; }
|
|
7659
7733
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
7660
7734
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
7661
7735
|
}
|
|
7736
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
7737
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
7738
|
+
}
|
|
7739
|
+
updateClientBounds() {
|
|
7740
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
7741
|
+
}
|
|
7742
|
+
receiveEvent(_event) { }
|
|
7662
7743
|
__checkUpdateLayout() {
|
|
7663
7744
|
this.__layout.update();
|
|
7664
7745
|
}
|
|
@@ -7742,7 +7823,7 @@ var LeaferUI = (function (exports) {
|
|
|
7742
7823
|
const rect = exports.Rect.prototype;
|
|
7743
7824
|
const group = exports.Group.prototype;
|
|
7744
7825
|
const childrenRenderBounds = {};
|
|
7745
|
-
const { copy: copy$2, add, includes: includes$1 } = BoundsHelper;
|
|
7826
|
+
const { copy: copy$2, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
7746
7827
|
exports.Box = class Box extends exports.Group {
|
|
7747
7828
|
get __tag() { return 'Box'; }
|
|
7748
7829
|
get isBranchLeaf() { return true; }
|
|
@@ -7756,20 +7837,23 @@ var LeaferUI = (function (exports) {
|
|
|
7756
7837
|
return this.__updateRectRenderSpread() || -1;
|
|
7757
7838
|
}
|
|
7758
7839
|
__updateRectBoxBounds() { }
|
|
7759
|
-
__updateBoxBounds() {
|
|
7840
|
+
__updateBoxBounds(secondLayout) {
|
|
7760
7841
|
const data = this.__;
|
|
7761
7842
|
if (this.children.length) {
|
|
7762
7843
|
if (data.__autoSide) {
|
|
7763
7844
|
if (this.leafer && this.leafer.ready)
|
|
7764
7845
|
this.leafer.layouter.addExtra(this);
|
|
7765
7846
|
super.__updateBoxBounds();
|
|
7847
|
+
const { boxBounds } = this.__layout;
|
|
7766
7848
|
if (!data.__autoSize) {
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
7849
|
+
if (data.__autoWidth)
|
|
7850
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
7851
|
+
else
|
|
7852
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
7772
7853
|
}
|
|
7854
|
+
if (secondLayout && data.flow && data.padding)
|
|
7855
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
7856
|
+
this.__updateNaturalSize();
|
|
7773
7857
|
}
|
|
7774
7858
|
else {
|
|
7775
7859
|
this.__updateRectBoxBounds();
|
|
@@ -7789,13 +7873,13 @@ var LeaferUI = (function (exports) {
|
|
|
7789
7873
|
super.__updateRenderBounds();
|
|
7790
7874
|
copy$2(childrenRenderBounds, renderBounds);
|
|
7791
7875
|
this.__updateRectRenderBounds();
|
|
7792
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
7876
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
7793
7877
|
}
|
|
7794
7878
|
else {
|
|
7795
7879
|
this.__updateRectRenderBounds();
|
|
7796
7880
|
}
|
|
7797
7881
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
7798
|
-
if (
|
|
7882
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
7799
7883
|
add(renderBounds, childrenRenderBounds);
|
|
7800
7884
|
}
|
|
7801
7885
|
__updateRectRenderBounds() { }
|
|
@@ -8129,14 +8213,26 @@ var LeaferUI = (function (exports) {
|
|
|
8129
8213
|
exports.Image = __decorate([
|
|
8130
8214
|
registerUI()
|
|
8131
8215
|
], exports.Image);
|
|
8216
|
+
const MyImage = exports.Image;
|
|
8132
8217
|
|
|
8133
8218
|
exports.Canvas = class Canvas extends exports.Rect {
|
|
8134
8219
|
get __tag() { return 'Canvas'; }
|
|
8220
|
+
get ready() { return !this.url; }
|
|
8135
8221
|
constructor(data) {
|
|
8136
8222
|
super(data);
|
|
8137
8223
|
this.canvas = Creator.canvas(this.__);
|
|
8138
8224
|
this.context = this.canvas.context;
|
|
8139
8225
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8226
|
+
if (data && data.url)
|
|
8227
|
+
this.drawImage(data.url);
|
|
8228
|
+
}
|
|
8229
|
+
drawImage(url) {
|
|
8230
|
+
new LeaferImage({ url }).load((image) => {
|
|
8231
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8232
|
+
this.url = undefined;
|
|
8233
|
+
this.paint();
|
|
8234
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8235
|
+
});
|
|
8140
8236
|
}
|
|
8141
8237
|
draw(ui, offset, scale, rotation) {
|
|
8142
8238
|
ui.__layout.update();
|
|
@@ -8153,19 +8249,18 @@ var LeaferUI = (function (exports) {
|
|
|
8153
8249
|
this.paint();
|
|
8154
8250
|
}
|
|
8155
8251
|
paint() {
|
|
8156
|
-
this.
|
|
8252
|
+
this.forceRender();
|
|
8157
8253
|
}
|
|
8158
8254
|
__drawAfterFill(canvas, _options) {
|
|
8159
|
-
const
|
|
8160
|
-
|
|
8161
|
-
if (this.__.cornerRadius || this.pathInputed) {
|
|
8255
|
+
const { width, height, cornerRadius } = this.__, { view } = this.canvas;
|
|
8256
|
+
if (cornerRadius || this.pathInputed) {
|
|
8162
8257
|
canvas.save();
|
|
8163
8258
|
canvas.clip();
|
|
8164
|
-
canvas.drawImage(
|
|
8259
|
+
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
8165
8260
|
canvas.restore();
|
|
8166
8261
|
}
|
|
8167
8262
|
else {
|
|
8168
|
-
canvas.drawImage(
|
|
8263
|
+
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
8169
8264
|
}
|
|
8170
8265
|
}
|
|
8171
8266
|
__updateSize() {
|
|
@@ -8195,7 +8290,7 @@ var LeaferUI = (function (exports) {
|
|
|
8195
8290
|
resizeType(100)
|
|
8196
8291
|
], exports.Canvas.prototype, "height", void 0);
|
|
8197
8292
|
__decorate([
|
|
8198
|
-
resizeType(
|
|
8293
|
+
resizeType(1)
|
|
8199
8294
|
], exports.Canvas.prototype, "pixelRatio", void 0);
|
|
8200
8295
|
__decorate([
|
|
8201
8296
|
resizeType(true)
|
|
@@ -8219,13 +8314,13 @@ var LeaferUI = (function (exports) {
|
|
|
8219
8314
|
super(data);
|
|
8220
8315
|
}
|
|
8221
8316
|
__drawHitPath(canvas) {
|
|
8222
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8317
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8223
8318
|
canvas.beginPath();
|
|
8224
8319
|
if (this.__.__letterSpacing < 0) {
|
|
8225
8320
|
this.__drawPathByData(canvas);
|
|
8226
8321
|
}
|
|
8227
8322
|
else {
|
|
8228
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8323
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8229
8324
|
}
|
|
8230
8325
|
}
|
|
8231
8326
|
__drawPathByData(drawer, _data) {
|
|
@@ -8418,7 +8513,8 @@ var LeaferUI = (function (exports) {
|
|
|
8418
8513
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8419
8514
|
clearPath() { return this; }
|
|
8420
8515
|
paint() {
|
|
8421
|
-
this.pathElement.
|
|
8516
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8517
|
+
this.pathElement.forceUpdate('path');
|
|
8422
8518
|
}
|
|
8423
8519
|
};
|
|
8424
8520
|
__decorate([
|
|
@@ -8428,7 +8524,7 @@ var LeaferUI = (function (exports) {
|
|
|
8428
8524
|
penPathType()
|
|
8429
8525
|
], exports.Pen.prototype, "path", void 0);
|
|
8430
8526
|
exports.Pen = __decorate([
|
|
8431
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8527
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8432
8528
|
registerUI()
|
|
8433
8529
|
], exports.Pen);
|
|
8434
8530
|
function penPathType() {
|
|
@@ -8790,16 +8886,21 @@ var LeaferUI = (function (exports) {
|
|
|
8790
8886
|
const { get: get$2, translate } = MatrixHelper;
|
|
8791
8887
|
const tempBox = new Bounds();
|
|
8792
8888
|
const tempPoint = {};
|
|
8889
|
+
const tempScaleData = {};
|
|
8793
8890
|
function createData(leafPaint, image, paint, box) {
|
|
8794
|
-
const { blendMode } = paint;
|
|
8891
|
+
const { blendMode, sync } = paint;
|
|
8795
8892
|
if (blendMode)
|
|
8796
8893
|
leafPaint.blendMode = blendMode;
|
|
8894
|
+
if (sync)
|
|
8895
|
+
leafPaint.sync = sync;
|
|
8797
8896
|
leafPaint.data = getPatternData(paint, box, image);
|
|
8798
8897
|
}
|
|
8799
8898
|
function getPatternData(paint, box, image) {
|
|
8800
8899
|
let { width, height } = image;
|
|
8801
8900
|
if (paint.padding)
|
|
8802
8901
|
box = tempBox.set(box).shrink(paint.padding);
|
|
8902
|
+
if (paint.mode === 'strench')
|
|
8903
|
+
paint.mode = 'stretch';
|
|
8803
8904
|
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
8804
8905
|
const sameBox = box.width === width && box.height === height;
|
|
8805
8906
|
const data = { mode };
|
|
@@ -8813,13 +8914,10 @@ var LeaferUI = (function (exports) {
|
|
|
8813
8914
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
8814
8915
|
}
|
|
8815
8916
|
}
|
|
8816
|
-
else if (size) {
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
else if (scale) {
|
|
8821
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
8822
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
8917
|
+
else if (scale || size) {
|
|
8918
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
8919
|
+
scaleX = tempScaleData.scaleX;
|
|
8920
|
+
scaleY = tempScaleData.scaleY;
|
|
8823
8921
|
}
|
|
8824
8922
|
if (align) {
|
|
8825
8923
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -8831,7 +8929,7 @@ var LeaferUI = (function (exports) {
|
|
|
8831
8929
|
if (offset)
|
|
8832
8930
|
x += offset.x, y += offset.y;
|
|
8833
8931
|
switch (mode) {
|
|
8834
|
-
case '
|
|
8932
|
+
case 'stretch':
|
|
8835
8933
|
if (!sameBox)
|
|
8836
8934
|
width = box.width, height = box.height;
|
|
8837
8935
|
break;
|
|
@@ -8858,7 +8956,7 @@ var LeaferUI = (function (exports) {
|
|
|
8858
8956
|
translate(data.transform, box.x, box.y);
|
|
8859
8957
|
}
|
|
8860
8958
|
}
|
|
8861
|
-
if (scaleX && mode !== '
|
|
8959
|
+
if (scaleX && mode !== 'stretch') {
|
|
8862
8960
|
data.scaleX = scaleX;
|
|
8863
8961
|
data.scaleY = scaleY;
|
|
8864
8962
|
}
|
|
@@ -8962,7 +9060,7 @@ var LeaferUI = (function (exports) {
|
|
|
8962
9060
|
const { ceil, abs: abs$1 } = Math;
|
|
8963
9061
|
function createPattern(ui, paint, pixelRatio) {
|
|
8964
9062
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
8965
|
-
const id = scaleX + '-' + scaleY;
|
|
9063
|
+
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
8966
9064
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
8967
9065
|
scaleX = abs$1(scaleX);
|
|
8968
9066
|
scaleY = abs$1(scaleY);
|
|
@@ -9024,7 +9122,8 @@ var LeaferUI = (function (exports) {
|
|
|
9024
9122
|
const { abs } = Math;
|
|
9025
9123
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
9026
9124
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
9027
|
-
|
|
9125
|
+
const { pixelRatio } = canvas;
|
|
9126
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
9028
9127
|
return false;
|
|
9029
9128
|
}
|
|
9030
9129
|
else {
|
|
@@ -9032,8 +9131,8 @@ var LeaferUI = (function (exports) {
|
|
|
9032
9131
|
if (allowPaint) {
|
|
9033
9132
|
if (!data.repeat) {
|
|
9034
9133
|
let { width, height } = data;
|
|
9035
|
-
width *= abs(scaleX) *
|
|
9036
|
-
height *= abs(scaleY) *
|
|
9134
|
+
width *= abs(scaleX) * pixelRatio;
|
|
9135
|
+
height *= abs(scaleY) * pixelRatio;
|
|
9037
9136
|
if (data.scaleX) {
|
|
9038
9137
|
width *= data.scaleX;
|
|
9039
9138
|
height *= data.scaleY;
|
|
@@ -9058,15 +9157,15 @@ var LeaferUI = (function (exports) {
|
|
|
9058
9157
|
return true;
|
|
9059
9158
|
}
|
|
9060
9159
|
else {
|
|
9061
|
-
if (!paint.style || Export.running) {
|
|
9062
|
-
createPattern(ui, paint,
|
|
9160
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
9161
|
+
createPattern(ui, paint, pixelRatio);
|
|
9063
9162
|
}
|
|
9064
9163
|
else {
|
|
9065
9164
|
if (!paint.patternTask) {
|
|
9066
9165
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
9067
9166
|
paint.patternTask = null;
|
|
9068
9167
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
9069
|
-
createPattern(ui, paint,
|
|
9168
|
+
createPattern(ui, paint, pixelRatio);
|
|
9070
9169
|
ui.forceUpdate('surface');
|
|
9071
9170
|
}), 300);
|
|
9072
9171
|
}
|
|
@@ -9130,14 +9229,16 @@ var LeaferUI = (function (exports) {
|
|
|
9130
9229
|
return data;
|
|
9131
9230
|
}
|
|
9132
9231
|
function applyStops(gradient, stops, opacity) {
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
9232
|
+
if (stops) {
|
|
9233
|
+
let stop;
|
|
9234
|
+
for (let i = 0, len = stops.length; i < len; i++) {
|
|
9235
|
+
stop = stops[i];
|
|
9236
|
+
if (typeof stop === 'string') {
|
|
9237
|
+
gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
|
|
9238
|
+
}
|
|
9239
|
+
else {
|
|
9240
|
+
gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
|
|
9241
|
+
}
|
|
9141
9242
|
}
|
|
9142
9243
|
}
|
|
9143
9244
|
}
|
|
@@ -9893,10 +9994,15 @@ var LeaferUI = (function (exports) {
|
|
|
9893
9994
|
};
|
|
9894
9995
|
|
|
9895
9996
|
function string(color, opacity) {
|
|
9896
|
-
|
|
9897
|
-
|
|
9997
|
+
const doOpacity = typeof opacity === 'number' && opacity !== 1;
|
|
9998
|
+
if (typeof color === 'string') {
|
|
9999
|
+
if (doOpacity && ColorConvert.object)
|
|
10000
|
+
color = ColorConvert.object(color);
|
|
10001
|
+
else
|
|
10002
|
+
return color;
|
|
10003
|
+
}
|
|
9898
10004
|
let a = color.a === undefined ? 1 : color.a;
|
|
9899
|
-
if (
|
|
10005
|
+
if (doOpacity)
|
|
9900
10006
|
a *= opacity;
|
|
9901
10007
|
const rgb = color.r + ',' + color.g + ',' + color.b;
|
|
9902
10008
|
return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
|
|
@@ -9928,6 +10034,7 @@ var LeaferUI = (function (exports) {
|
|
|
9928
10034
|
export(leaf, filename, options) {
|
|
9929
10035
|
this.running = true;
|
|
9930
10036
|
const fileType = FileHelper.fileType(filename);
|
|
10037
|
+
const isDownload = filename.includes('.');
|
|
9931
10038
|
options = FileHelper.getExportOptions(options);
|
|
9932
10039
|
return addTask((success) => new Promise((resolve) => {
|
|
9933
10040
|
const over = (result) => {
|
|
@@ -9937,19 +10044,13 @@ var LeaferUI = (function (exports) {
|
|
|
9937
10044
|
};
|
|
9938
10045
|
const { toURL } = Platform;
|
|
9939
10046
|
const { download } = Platform.origin;
|
|
9940
|
-
if (
|
|
9941
|
-
|
|
10047
|
+
if (fileType === 'json') {
|
|
10048
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
10049
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
9942
10050
|
}
|
|
9943
|
-
|
|
9944
|
-
download(toURL(
|
|
9945
|
-
return over({ data: true });
|
|
9946
|
-
}
|
|
9947
|
-
if (filename === 'svg') {
|
|
9948
|
-
return over({ data: leaf.toSVG() });
|
|
9949
|
-
}
|
|
9950
|
-
else if (fileType === 'svg') {
|
|
9951
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
9952
|
-
return over({ data: true });
|
|
10051
|
+
if (fileType === 'svg') {
|
|
10052
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
10053
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
9953
10054
|
}
|
|
9954
10055
|
const { leafer } = leaf;
|
|
9955
10056
|
if (leafer) {
|
|
@@ -9958,14 +10059,8 @@ var LeaferUI = (function (exports) {
|
|
|
9958
10059
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
9959
10060
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
9960
10061
|
const { slice, trim, onCanvas } = options;
|
|
9961
|
-
let scale = options.scale || 1;
|
|
9962
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
9963
10062
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
9964
10063
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
9965
|
-
if (leaf.isApp) {
|
|
9966
|
-
scale *= pixelRatio;
|
|
9967
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
9968
|
-
}
|
|
9969
10064
|
const screenshot = options.screenshot || leaf.isApp;
|
|
9970
10065
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
9971
10066
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -9999,9 +10094,17 @@ var LeaferUI = (function (exports) {
|
|
|
9999
10094
|
}
|
|
10000
10095
|
renderBounds = leaf.getBounds('render', relative);
|
|
10001
10096
|
}
|
|
10002
|
-
const {
|
|
10097
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
10098
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
10099
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
10100
|
+
if (leaf.isApp) {
|
|
10101
|
+
scaleData.scaleX *= pixelRatio;
|
|
10102
|
+
scaleData.scaleY *= pixelRatio;
|
|
10103
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
10104
|
+
}
|
|
10105
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
10106
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
10003
10107
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
10004
|
-
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
10005
10108
|
let sliceLeaf;
|
|
10006
10109
|
if (slice) {
|
|
10007
10110
|
sliceLeaf = leaf;
|
|
@@ -10107,7 +10210,6 @@ var LeaferUI = (function (exports) {
|
|
|
10107
10210
|
useCanvas();
|
|
10108
10211
|
|
|
10109
10212
|
exports.AlignHelper = AlignHelper;
|
|
10110
|
-
exports.AnimateEvent = AnimateEvent;
|
|
10111
10213
|
exports.AroundHelper = AroundHelper;
|
|
10112
10214
|
exports.AutoBounds = AutoBounds;
|
|
10113
10215
|
exports.BezierHelper = BezierHelper;
|
|
@@ -10128,6 +10230,7 @@ var LeaferUI = (function (exports) {
|
|
|
10128
10230
|
exports.EllipseHelper = EllipseHelper;
|
|
10129
10231
|
exports.Event = Event;
|
|
10130
10232
|
exports.EventCreator = EventCreator;
|
|
10233
|
+
exports.Eventer = Eventer;
|
|
10131
10234
|
exports.Export = Export;
|
|
10132
10235
|
exports.FileHelper = FileHelper;
|
|
10133
10236
|
exports.FrameData = FrameData;
|
|
@@ -10158,6 +10261,7 @@ var LeaferUI = (function (exports) {
|
|
|
10158
10261
|
exports.MathHelper = MathHelper;
|
|
10159
10262
|
exports.Matrix = Matrix;
|
|
10160
10263
|
exports.MatrixHelper = MatrixHelper;
|
|
10264
|
+
exports.MyImage = MyImage;
|
|
10161
10265
|
exports.NeedConvertToCanvasCommandMap = NeedConvertToCanvasCommandMap;
|
|
10162
10266
|
exports.OneRadian = OneRadian;
|
|
10163
10267
|
exports.PI2 = PI2;
|
|
@@ -10197,6 +10301,7 @@ var LeaferUI = (function (exports) {
|
|
|
10197
10301
|
exports.TaskProcessor = TaskProcessor;
|
|
10198
10302
|
exports.TextConvert = TextConvert;
|
|
10199
10303
|
exports.TextData = TextData;
|
|
10304
|
+
exports.Transition = Transition;
|
|
10200
10305
|
exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
|
|
10201
10306
|
exports.UIBounds = UIBounds;
|
|
10202
10307
|
exports.UICreator = UICreator;
|
|
@@ -10208,7 +10313,6 @@ var LeaferUI = (function (exports) {
|
|
|
10208
10313
|
exports.Watcher = Watcher;
|
|
10209
10314
|
exports.affectRenderBoundsType = affectRenderBoundsType;
|
|
10210
10315
|
exports.affectStrokeBoundsType = affectStrokeBoundsType;
|
|
10211
|
-
exports.arrowType = arrowType;
|
|
10212
10316
|
exports.attr = attr;
|
|
10213
10317
|
exports.autoLayoutType = autoLayoutType;
|
|
10214
10318
|
exports.boundsType = boundsType;
|
|
@@ -10231,10 +10335,11 @@ var LeaferUI = (function (exports) {
|
|
|
10231
10335
|
exports.getMatrixData = getMatrixData;
|
|
10232
10336
|
exports.getPointData = getPointData;
|
|
10233
10337
|
exports.hitType = hitType;
|
|
10234
|
-
exports.
|
|
10338
|
+
exports.isNull = isNull;
|
|
10235
10339
|
exports.layoutProcessor = layoutProcessor;
|
|
10236
10340
|
exports.maskType = maskType;
|
|
10237
10341
|
exports.naturalBoundsType = naturalBoundsType;
|
|
10342
|
+
exports.needPlugin = needPlugin;
|
|
10238
10343
|
exports.opacityType = opacityType;
|
|
10239
10344
|
exports.pathInputType = pathInputType;
|
|
10240
10345
|
exports.pathType = pathType;
|
|
@@ -10248,7 +10353,6 @@ var LeaferUI = (function (exports) {
|
|
|
10248
10353
|
exports.rotationType = rotationType;
|
|
10249
10354
|
exports.scaleType = scaleType;
|
|
10250
10355
|
exports.sortType = sortType;
|
|
10251
|
-
exports.stateType = stateType;
|
|
10252
10356
|
exports.strokeType = strokeType;
|
|
10253
10357
|
exports.surfaceType = surfaceType;
|
|
10254
10358
|
exports.tempBounds = tempBounds$1;
|