leafer-draw 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/web.cjs +2575 -0
- package/dist/web.esm.js +61 -51
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +522 -418
- package/dist/web.min.cjs +1 -0
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +518 -415
- package/dist/web.module.min.js +1 -1
- package/package.json +9 -3
package/dist/web.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$d = 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
|
-
|
|
3854
|
+
if (oldValue === true && value === 0) {
|
|
3855
|
+
if (this.animationOut)
|
|
3856
|
+
return this.__runAnimation('out', () => doVisible(this, key, value, oldValue));
|
|
3857
|
+
}
|
|
3858
|
+
else if (oldValue === 0 && value === true) {
|
|
3859
|
+
if (this.animation)
|
|
3860
|
+
this.__runAnimation('in');
|
|
3811
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$6 = 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
|
const debug$5 = Debug.get('LeaferCanvas');
|
|
5795
5923
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6189,9 +6317,13 @@ var LeaferUI = (function (exports) {
|
|
|
6189
6317
|
});
|
|
6190
6318
|
}
|
|
6191
6319
|
function updateChange(updateList) {
|
|
6320
|
+
let layout;
|
|
6192
6321
|
updateList.list.forEach(leaf => {
|
|
6193
|
-
|
|
6322
|
+
layout = leaf.__layout;
|
|
6323
|
+
if (layout.opacityChanged)
|
|
6194
6324
|
updateAllWorldOpacity(leaf);
|
|
6325
|
+
if (layout.stateStyleChanged)
|
|
6326
|
+
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
6195
6327
|
leaf.__updateChange();
|
|
6196
6328
|
});
|
|
6197
6329
|
}
|
|
@@ -6557,7 +6689,6 @@ var LeaferUI = (function (exports) {
|
|
|
6557
6689
|
Platform.requestRender(() => {
|
|
6558
6690
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
|
|
6559
6691
|
if (this.running) {
|
|
6560
|
-
this.target.emit(AnimateEvent.FRAME);
|
|
6561
6692
|
if (this.changed && this.canvas.view)
|
|
6562
6693
|
this.render();
|
|
6563
6694
|
this.target.emit(RenderEvent.NEXT);
|
|
@@ -6631,36 +6762,6 @@ var LeaferUI = (function (exports) {
|
|
|
6631
6762
|
});
|
|
6632
6763
|
Platform.layout = Layouter.fullLayout;
|
|
6633
6764
|
|
|
6634
|
-
const TextConvert = {};
|
|
6635
|
-
const ColorConvert = {};
|
|
6636
|
-
const PathArrow = {};
|
|
6637
|
-
const Paint = {};
|
|
6638
|
-
const PaintImage = {};
|
|
6639
|
-
const PaintGradient = {};
|
|
6640
|
-
const Effect = {};
|
|
6641
|
-
const Export = {};
|
|
6642
|
-
const State = {};
|
|
6643
|
-
|
|
6644
|
-
function stateType(defaultValue) {
|
|
6645
|
-
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6646
|
-
set(value) {
|
|
6647
|
-
this.__setAttr(key, value);
|
|
6648
|
-
this.waitLeafer(() => { if (State.setStyle)
|
|
6649
|
-
State.setStyle(this, key + 'Style', value); });
|
|
6650
|
-
}
|
|
6651
|
-
}));
|
|
6652
|
-
}
|
|
6653
|
-
function arrowType(defaultValue) {
|
|
6654
|
-
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6655
|
-
set(value) {
|
|
6656
|
-
if (this.__setAttr(key, value)) {
|
|
6657
|
-
const data = this.__;
|
|
6658
|
-
data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
|
|
6659
|
-
doStrokeType(this);
|
|
6660
|
-
}
|
|
6661
|
-
}
|
|
6662
|
-
}));
|
|
6663
|
-
}
|
|
6664
6765
|
function effectType(defaultValue) {
|
|
6665
6766
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6666
6767
|
set(value) {
|
|
@@ -6695,10 +6796,33 @@ var LeaferUI = (function (exports) {
|
|
|
6695
6796
|
};
|
|
6696
6797
|
}
|
|
6697
6798
|
|
|
6799
|
+
const TextConvert = {};
|
|
6800
|
+
const ColorConvert = {};
|
|
6801
|
+
const PathArrow = {};
|
|
6802
|
+
const Paint = {};
|
|
6803
|
+
const PaintImage = {};
|
|
6804
|
+
const PaintGradient = {};
|
|
6805
|
+
const Effect = {};
|
|
6806
|
+
const Export = {};
|
|
6807
|
+
const State = {
|
|
6808
|
+
setStyleName(_leaf, _styleName, _value) { return needPlugin('state'); },
|
|
6809
|
+
set(_leaf, _stateName) { return needPlugin('state'); }
|
|
6810
|
+
};
|
|
6811
|
+
const Transition = {
|
|
6812
|
+
list: {},
|
|
6813
|
+
register(attrName, fn) {
|
|
6814
|
+
Transition.list[attrName] = fn;
|
|
6815
|
+
},
|
|
6816
|
+
get(attrName) {
|
|
6817
|
+
return Transition.list[attrName];
|
|
6818
|
+
}
|
|
6819
|
+
};
|
|
6820
|
+
|
|
6698
6821
|
const { parse } = PathConvert;
|
|
6699
6822
|
const emptyPaint = {};
|
|
6700
6823
|
const debug$2 = Debug.get('UIData');
|
|
6701
6824
|
class UIData extends LeafData {
|
|
6825
|
+
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
6702
6826
|
get __strokeWidth() {
|
|
6703
6827
|
const { strokeWidth, strokeWidthFixed } = this;
|
|
6704
6828
|
if (strokeWidthFixed) {
|
|
@@ -6717,9 +6841,10 @@ var LeaferUI = (function (exports) {
|
|
|
6717
6841
|
get __autoSide() { return !this._width || !this._height; }
|
|
6718
6842
|
get __autoSize() { return !this._width && !this._height; }
|
|
6719
6843
|
setVisible(value) {
|
|
6720
|
-
if (this.__leaf.leafer)
|
|
6721
|
-
this.__leaf.leafer.watcher.hasVisible = true;
|
|
6722
6844
|
this._visible = value;
|
|
6845
|
+
const { leafer } = this.__leaf;
|
|
6846
|
+
if (leafer)
|
|
6847
|
+
leafer.watcher.hasVisible = true;
|
|
6723
6848
|
}
|
|
6724
6849
|
setWidth(value) {
|
|
6725
6850
|
if (value < 0) {
|
|
@@ -6843,6 +6968,11 @@ var LeaferUI = (function (exports) {
|
|
|
6843
6968
|
}
|
|
6844
6969
|
|
|
6845
6970
|
class LeaferData extends GroupData {
|
|
6971
|
+
__getInputData() {
|
|
6972
|
+
const data = super.__getInputData();
|
|
6973
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
6974
|
+
return data;
|
|
6975
|
+
}
|
|
6846
6976
|
}
|
|
6847
6977
|
|
|
6848
6978
|
class FrameData extends BoxData {
|
|
@@ -6905,7 +7035,7 @@ var LeaferUI = (function (exports) {
|
|
|
6905
7035
|
__setImageFill(value) {
|
|
6906
7036
|
if (this.__leaf.image)
|
|
6907
7037
|
this.__leaf.image = null;
|
|
6908
|
-
this.fill = value ? { type: 'image', mode: '
|
|
7038
|
+
this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
|
|
6909
7039
|
}
|
|
6910
7040
|
__getData() {
|
|
6911
7041
|
const data = super.__getData();
|
|
@@ -6920,6 +7050,11 @@ var LeaferUI = (function (exports) {
|
|
|
6920
7050
|
}
|
|
6921
7051
|
|
|
6922
7052
|
class CanvasData extends RectData {
|
|
7053
|
+
__getInputData() {
|
|
7054
|
+
const data = super.__getInputData();
|
|
7055
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
7056
|
+
return data;
|
|
7057
|
+
}
|
|
6923
7058
|
}
|
|
6924
7059
|
|
|
6925
7060
|
const UIBounds = {
|
|
@@ -7090,19 +7225,8 @@ var LeaferUI = (function (exports) {
|
|
|
7090
7225
|
exports.UI = UI_1 = class UI extends exports.Leaf {
|
|
7091
7226
|
get app() { return this.leafer && this.leafer.app; }
|
|
7092
7227
|
get isFrame() { return false; }
|
|
7093
|
-
set scale(value) {
|
|
7094
|
-
|
|
7095
|
-
this.scaleX = this.scaleY = value;
|
|
7096
|
-
}
|
|
7097
|
-
else {
|
|
7098
|
-
this.scaleX = value.x;
|
|
7099
|
-
this.scaleY = value.y;
|
|
7100
|
-
}
|
|
7101
|
-
}
|
|
7102
|
-
get scale() {
|
|
7103
|
-
const { scaleX, scaleY } = this;
|
|
7104
|
-
return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
|
|
7105
|
-
}
|
|
7228
|
+
set scale(value) { MathHelper.assignScale(this, value); }
|
|
7229
|
+
get scale() { return this.__.scale; }
|
|
7106
7230
|
get pen() {
|
|
7107
7231
|
const { path } = this.__;
|
|
7108
7232
|
pen.set(this.path = path || []);
|
|
@@ -7117,8 +7241,15 @@ var LeaferUI = (function (exports) {
|
|
|
7117
7241
|
super(data);
|
|
7118
7242
|
}
|
|
7119
7243
|
reset(_data) { }
|
|
7120
|
-
set(data) {
|
|
7121
|
-
|
|
7244
|
+
set(data, isTemp) {
|
|
7245
|
+
if (isTemp) {
|
|
7246
|
+
this.lockNormalStyle = true;
|
|
7247
|
+
Object.assign(this, data);
|
|
7248
|
+
this.lockNormalStyle = false;
|
|
7249
|
+
}
|
|
7250
|
+
else {
|
|
7251
|
+
Object.assign(this, data);
|
|
7252
|
+
}
|
|
7122
7253
|
}
|
|
7123
7254
|
get(name) {
|
|
7124
7255
|
return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
@@ -7181,11 +7312,18 @@ var LeaferUI = (function (exports) {
|
|
|
7181
7312
|
drawer.rect(x, y, width, height);
|
|
7182
7313
|
}
|
|
7183
7314
|
}
|
|
7315
|
+
animate(_keyframe, _options, _type, _isTemp) {
|
|
7316
|
+
return needPlugin('animate');
|
|
7317
|
+
}
|
|
7318
|
+
killAnimate(_type) { }
|
|
7184
7319
|
export(filename, options) {
|
|
7185
7320
|
return Export.export(this, filename, options);
|
|
7186
7321
|
}
|
|
7187
|
-
clone() {
|
|
7188
|
-
|
|
7322
|
+
clone(newData) {
|
|
7323
|
+
const json = this.toJSON();
|
|
7324
|
+
if (newData)
|
|
7325
|
+
Object.assign(json, newData);
|
|
7326
|
+
return UI_1.one(json);
|
|
7189
7327
|
}
|
|
7190
7328
|
static one(data, x, y, width, height) {
|
|
7191
7329
|
return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
|
|
@@ -7201,6 +7339,8 @@ var LeaferUI = (function (exports) {
|
|
|
7201
7339
|
static setEditInner(_editorName) { }
|
|
7202
7340
|
destroy() {
|
|
7203
7341
|
this.fill = this.stroke = null;
|
|
7342
|
+
if (this.__animate)
|
|
7343
|
+
this.killAnimate();
|
|
7204
7344
|
super.destroy();
|
|
7205
7345
|
}
|
|
7206
7346
|
};
|
|
@@ -7228,12 +7368,6 @@ var LeaferUI = (function (exports) {
|
|
|
7228
7368
|
__decorate([
|
|
7229
7369
|
visibleType(true)
|
|
7230
7370
|
], exports.UI.prototype, "visible", void 0);
|
|
7231
|
-
__decorate([
|
|
7232
|
-
stateType(false)
|
|
7233
|
-
], exports.UI.prototype, "selected", void 0);
|
|
7234
|
-
__decorate([
|
|
7235
|
-
stateType(false)
|
|
7236
|
-
], exports.UI.prototype, "disabled", void 0);
|
|
7237
7371
|
__decorate([
|
|
7238
7372
|
surfaceType(false)
|
|
7239
7373
|
], exports.UI.prototype, "locked", void 0);
|
|
@@ -7306,45 +7440,9 @@ var LeaferUI = (function (exports) {
|
|
|
7306
7440
|
__decorate([
|
|
7307
7441
|
pathType(true)
|
|
7308
7442
|
], exports.UI.prototype, "closed", void 0);
|
|
7309
|
-
__decorate([
|
|
7310
|
-
autoLayoutType(false)
|
|
7311
|
-
], exports.UI.prototype, "flow", void 0);
|
|
7312
7443
|
__decorate([
|
|
7313
7444
|
boundsType(0)
|
|
7314
7445
|
], exports.UI.prototype, "padding", void 0);
|
|
7315
|
-
__decorate([
|
|
7316
|
-
boundsType(0)
|
|
7317
|
-
], exports.UI.prototype, "gap", void 0);
|
|
7318
|
-
__decorate([
|
|
7319
|
-
boundsType('top-left')
|
|
7320
|
-
], exports.UI.prototype, "flowAlign", void 0);
|
|
7321
|
-
__decorate([
|
|
7322
|
-
boundsType(false)
|
|
7323
|
-
], exports.UI.prototype, "flowWrap", void 0);
|
|
7324
|
-
__decorate([
|
|
7325
|
-
boundsType('box')
|
|
7326
|
-
], exports.UI.prototype, "itemBox", void 0);
|
|
7327
|
-
__decorate([
|
|
7328
|
-
boundsType(true)
|
|
7329
|
-
], exports.UI.prototype, "inFlow", void 0);
|
|
7330
|
-
__decorate([
|
|
7331
|
-
boundsType()
|
|
7332
|
-
], exports.UI.prototype, "autoWidth", void 0);
|
|
7333
|
-
__decorate([
|
|
7334
|
-
boundsType()
|
|
7335
|
-
], exports.UI.prototype, "autoHeight", void 0);
|
|
7336
|
-
__decorate([
|
|
7337
|
-
boundsType()
|
|
7338
|
-
], exports.UI.prototype, "lockRatio", void 0);
|
|
7339
|
-
__decorate([
|
|
7340
|
-
boundsType()
|
|
7341
|
-
], exports.UI.prototype, "autoBox", void 0);
|
|
7342
|
-
__decorate([
|
|
7343
|
-
boundsType()
|
|
7344
|
-
], exports.UI.prototype, "widthRange", void 0);
|
|
7345
|
-
__decorate([
|
|
7346
|
-
boundsType()
|
|
7347
|
-
], exports.UI.prototype, "heightRange", void 0);
|
|
7348
7446
|
__decorate([
|
|
7349
7447
|
dataType(false)
|
|
7350
7448
|
], exports.UI.prototype, "draggable", void 0);
|
|
@@ -7408,12 +7506,6 @@ var LeaferUI = (function (exports) {
|
|
|
7408
7506
|
__decorate([
|
|
7409
7507
|
strokeType(10)
|
|
7410
7508
|
], exports.UI.prototype, "miterLimit", void 0);
|
|
7411
|
-
__decorate([
|
|
7412
|
-
arrowType('none')
|
|
7413
|
-
], exports.UI.prototype, "startArrow", void 0);
|
|
7414
|
-
__decorate([
|
|
7415
|
-
arrowType('none')
|
|
7416
|
-
], exports.UI.prototype, "endArrow", void 0);
|
|
7417
7509
|
__decorate([
|
|
7418
7510
|
pathType(0)
|
|
7419
7511
|
], exports.UI.prototype, "cornerRadius", void 0);
|
|
@@ -7435,24 +7527,6 @@ var LeaferUI = (function (exports) {
|
|
|
7435
7527
|
__decorate([
|
|
7436
7528
|
effectType()
|
|
7437
7529
|
], exports.UI.prototype, "grayscale", void 0);
|
|
7438
|
-
__decorate([
|
|
7439
|
-
dataType()
|
|
7440
|
-
], exports.UI.prototype, "normalStyle", void 0);
|
|
7441
|
-
__decorate([
|
|
7442
|
-
dataType()
|
|
7443
|
-
], exports.UI.prototype, "hoverStyle", void 0);
|
|
7444
|
-
__decorate([
|
|
7445
|
-
dataType()
|
|
7446
|
-
], exports.UI.prototype, "pressStyle", void 0);
|
|
7447
|
-
__decorate([
|
|
7448
|
-
dataType()
|
|
7449
|
-
], exports.UI.prototype, "focusStyle", void 0);
|
|
7450
|
-
__decorate([
|
|
7451
|
-
dataType()
|
|
7452
|
-
], exports.UI.prototype, "selectedStyle", void 0);
|
|
7453
|
-
__decorate([
|
|
7454
|
-
dataType()
|
|
7455
|
-
], exports.UI.prototype, "disabledStyle", void 0);
|
|
7456
7530
|
__decorate([
|
|
7457
7531
|
dataType({})
|
|
7458
7532
|
], exports.UI.prototype, "data", void 0);
|
|
@@ -7479,7 +7553,7 @@ var LeaferUI = (function (exports) {
|
|
|
7479
7553
|
if (!this.children)
|
|
7480
7554
|
this.children = [];
|
|
7481
7555
|
}
|
|
7482
|
-
set(data) {
|
|
7556
|
+
set(data, isTemp) {
|
|
7483
7557
|
if (data.children) {
|
|
7484
7558
|
const { children } = data;
|
|
7485
7559
|
delete data.children;
|
|
@@ -7489,7 +7563,7 @@ var LeaferUI = (function (exports) {
|
|
|
7489
7563
|
else {
|
|
7490
7564
|
this.clear();
|
|
7491
7565
|
}
|
|
7492
|
-
super.set(data);
|
|
7566
|
+
super.set(data, isTemp);
|
|
7493
7567
|
let child;
|
|
7494
7568
|
children.forEach(childData => {
|
|
7495
7569
|
child = childData.__ ? childData : UICreator.get(childData.tag, childData);
|
|
@@ -7498,7 +7572,7 @@ var LeaferUI = (function (exports) {
|
|
|
7498
7572
|
data.children = children;
|
|
7499
7573
|
}
|
|
7500
7574
|
else {
|
|
7501
|
-
super.set(data);
|
|
7575
|
+
super.set(data, isTemp);
|
|
7502
7576
|
}
|
|
7503
7577
|
}
|
|
7504
7578
|
toJSON(options) {
|
|
@@ -7825,13 +7899,20 @@ var LeaferUI = (function (exports) {
|
|
|
7825
7899
|
}
|
|
7826
7900
|
}
|
|
7827
7901
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
7828
|
-
return
|
|
7902
|
+
return needPlugin('view');
|
|
7829
7903
|
}
|
|
7830
7904
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
7831
7905
|
getValidScale(changeScale) { return changeScale; }
|
|
7832
7906
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
7833
7907
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
7834
7908
|
}
|
|
7909
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
7910
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
7911
|
+
}
|
|
7912
|
+
updateClientBounds() {
|
|
7913
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
7914
|
+
}
|
|
7915
|
+
receiveEvent(_event) { }
|
|
7835
7916
|
__checkUpdateLayout() {
|
|
7836
7917
|
this.__layout.update();
|
|
7837
7918
|
}
|
|
@@ -7915,7 +7996,7 @@ var LeaferUI = (function (exports) {
|
|
|
7915
7996
|
const rect = exports.Rect.prototype;
|
|
7916
7997
|
const group = exports.Group.prototype;
|
|
7917
7998
|
const childrenRenderBounds = {};
|
|
7918
|
-
const { copy: copy$2, add, includes: includes$1 } = BoundsHelper;
|
|
7999
|
+
const { copy: copy$2, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
7919
8000
|
exports.Box = class Box extends exports.Group {
|
|
7920
8001
|
get __tag() { return 'Box'; }
|
|
7921
8002
|
get isBranchLeaf() { return true; }
|
|
@@ -7929,20 +8010,23 @@ var LeaferUI = (function (exports) {
|
|
|
7929
8010
|
return this.__updateRectRenderSpread() || -1;
|
|
7930
8011
|
}
|
|
7931
8012
|
__updateRectBoxBounds() { }
|
|
7932
|
-
__updateBoxBounds() {
|
|
8013
|
+
__updateBoxBounds(secondLayout) {
|
|
7933
8014
|
const data = this.__;
|
|
7934
8015
|
if (this.children.length) {
|
|
7935
8016
|
if (data.__autoSide) {
|
|
7936
8017
|
if (this.leafer && this.leafer.ready)
|
|
7937
8018
|
this.leafer.layouter.addExtra(this);
|
|
7938
8019
|
super.__updateBoxBounds();
|
|
8020
|
+
const { boxBounds } = this.__layout;
|
|
7939
8021
|
if (!data.__autoSize) {
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
8022
|
+
if (data.__autoWidth)
|
|
8023
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
8024
|
+
else
|
|
8025
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
7945
8026
|
}
|
|
8027
|
+
if (secondLayout && data.flow && data.padding)
|
|
8028
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8029
|
+
this.__updateNaturalSize();
|
|
7946
8030
|
}
|
|
7947
8031
|
else {
|
|
7948
8032
|
this.__updateRectBoxBounds();
|
|
@@ -7962,13 +8046,13 @@ var LeaferUI = (function (exports) {
|
|
|
7962
8046
|
super.__updateRenderBounds();
|
|
7963
8047
|
copy$2(childrenRenderBounds, renderBounds);
|
|
7964
8048
|
this.__updateRectRenderBounds();
|
|
7965
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
8049
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
7966
8050
|
}
|
|
7967
8051
|
else {
|
|
7968
8052
|
this.__updateRectRenderBounds();
|
|
7969
8053
|
}
|
|
7970
8054
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
7971
|
-
if (
|
|
8055
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
7972
8056
|
add(renderBounds, childrenRenderBounds);
|
|
7973
8057
|
}
|
|
7974
8058
|
__updateRectRenderBounds() { }
|
|
@@ -8302,14 +8386,26 @@ var LeaferUI = (function (exports) {
|
|
|
8302
8386
|
exports.Image = __decorate([
|
|
8303
8387
|
registerUI()
|
|
8304
8388
|
], exports.Image);
|
|
8389
|
+
const MyImage = exports.Image;
|
|
8305
8390
|
|
|
8306
8391
|
exports.Canvas = class Canvas extends exports.Rect {
|
|
8307
8392
|
get __tag() { return 'Canvas'; }
|
|
8393
|
+
get ready() { return !this.url; }
|
|
8308
8394
|
constructor(data) {
|
|
8309
8395
|
super(data);
|
|
8310
8396
|
this.canvas = Creator.canvas(this.__);
|
|
8311
8397
|
this.context = this.canvas.context;
|
|
8312
8398
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8399
|
+
if (data && data.url)
|
|
8400
|
+
this.drawImage(data.url);
|
|
8401
|
+
}
|
|
8402
|
+
drawImage(url) {
|
|
8403
|
+
new LeaferImage({ url }).load((image) => {
|
|
8404
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8405
|
+
this.url = undefined;
|
|
8406
|
+
this.paint();
|
|
8407
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8408
|
+
});
|
|
8313
8409
|
}
|
|
8314
8410
|
draw(ui, offset, scale, rotation) {
|
|
8315
8411
|
ui.__layout.update();
|
|
@@ -8326,19 +8422,18 @@ var LeaferUI = (function (exports) {
|
|
|
8326
8422
|
this.paint();
|
|
8327
8423
|
}
|
|
8328
8424
|
paint() {
|
|
8329
|
-
this.
|
|
8425
|
+
this.forceRender();
|
|
8330
8426
|
}
|
|
8331
8427
|
__drawAfterFill(canvas, _options) {
|
|
8332
|
-
const
|
|
8333
|
-
|
|
8334
|
-
if (this.__.cornerRadius || this.pathInputed) {
|
|
8428
|
+
const { width, height, cornerRadius } = this.__, { view } = this.canvas;
|
|
8429
|
+
if (cornerRadius || this.pathInputed) {
|
|
8335
8430
|
canvas.save();
|
|
8336
8431
|
canvas.clip();
|
|
8337
|
-
canvas.drawImage(
|
|
8432
|
+
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
8338
8433
|
canvas.restore();
|
|
8339
8434
|
}
|
|
8340
8435
|
else {
|
|
8341
|
-
canvas.drawImage(
|
|
8436
|
+
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
8342
8437
|
}
|
|
8343
8438
|
}
|
|
8344
8439
|
__updateSize() {
|
|
@@ -8368,7 +8463,7 @@ var LeaferUI = (function (exports) {
|
|
|
8368
8463
|
resizeType(100)
|
|
8369
8464
|
], exports.Canvas.prototype, "height", void 0);
|
|
8370
8465
|
__decorate([
|
|
8371
|
-
resizeType(
|
|
8466
|
+
resizeType(1)
|
|
8372
8467
|
], exports.Canvas.prototype, "pixelRatio", void 0);
|
|
8373
8468
|
__decorate([
|
|
8374
8469
|
resizeType(true)
|
|
@@ -8392,13 +8487,13 @@ var LeaferUI = (function (exports) {
|
|
|
8392
8487
|
super(data);
|
|
8393
8488
|
}
|
|
8394
8489
|
__drawHitPath(canvas) {
|
|
8395
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8490
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8396
8491
|
canvas.beginPath();
|
|
8397
8492
|
if (this.__.__letterSpacing < 0) {
|
|
8398
8493
|
this.__drawPathByData(canvas);
|
|
8399
8494
|
}
|
|
8400
8495
|
else {
|
|
8401
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8496
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8402
8497
|
}
|
|
8403
8498
|
}
|
|
8404
8499
|
__drawPathByData(drawer, _data) {
|
|
@@ -8591,7 +8686,8 @@ var LeaferUI = (function (exports) {
|
|
|
8591
8686
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8592
8687
|
clearPath() { return this; }
|
|
8593
8688
|
paint() {
|
|
8594
|
-
this.pathElement.
|
|
8689
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8690
|
+
this.pathElement.forceUpdate('path');
|
|
8595
8691
|
}
|
|
8596
8692
|
};
|
|
8597
8693
|
__decorate([
|
|
@@ -8601,7 +8697,7 @@ var LeaferUI = (function (exports) {
|
|
|
8601
8697
|
penPathType()
|
|
8602
8698
|
], exports.Pen.prototype, "path", void 0);
|
|
8603
8699
|
exports.Pen = __decorate([
|
|
8604
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8700
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8605
8701
|
registerUI()
|
|
8606
8702
|
], exports.Pen);
|
|
8607
8703
|
function penPathType() {
|
|
@@ -8963,16 +9059,21 @@ var LeaferUI = (function (exports) {
|
|
|
8963
9059
|
const { get: get$2, translate } = MatrixHelper;
|
|
8964
9060
|
const tempBox = new Bounds();
|
|
8965
9061
|
const tempPoint = {};
|
|
9062
|
+
const tempScaleData = {};
|
|
8966
9063
|
function createData(leafPaint, image, paint, box) {
|
|
8967
|
-
const { blendMode } = paint;
|
|
9064
|
+
const { blendMode, sync } = paint;
|
|
8968
9065
|
if (blendMode)
|
|
8969
9066
|
leafPaint.blendMode = blendMode;
|
|
9067
|
+
if (sync)
|
|
9068
|
+
leafPaint.sync = sync;
|
|
8970
9069
|
leafPaint.data = getPatternData(paint, box, image);
|
|
8971
9070
|
}
|
|
8972
9071
|
function getPatternData(paint, box, image) {
|
|
8973
9072
|
let { width, height } = image;
|
|
8974
9073
|
if (paint.padding)
|
|
8975
9074
|
box = tempBox.set(box).shrink(paint.padding);
|
|
9075
|
+
if (paint.mode === 'strench')
|
|
9076
|
+
paint.mode = 'stretch';
|
|
8976
9077
|
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
8977
9078
|
const sameBox = box.width === width && box.height === height;
|
|
8978
9079
|
const data = { mode };
|
|
@@ -8986,13 +9087,10 @@ var LeaferUI = (function (exports) {
|
|
|
8986
9087
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
8987
9088
|
}
|
|
8988
9089
|
}
|
|
8989
|
-
else if (size) {
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
else if (scale) {
|
|
8994
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
8995
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
9090
|
+
else if (scale || size) {
|
|
9091
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
9092
|
+
scaleX = tempScaleData.scaleX;
|
|
9093
|
+
scaleY = tempScaleData.scaleY;
|
|
8996
9094
|
}
|
|
8997
9095
|
if (align) {
|
|
8998
9096
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -9004,7 +9102,7 @@ var LeaferUI = (function (exports) {
|
|
|
9004
9102
|
if (offset)
|
|
9005
9103
|
x += offset.x, y += offset.y;
|
|
9006
9104
|
switch (mode) {
|
|
9007
|
-
case '
|
|
9105
|
+
case 'stretch':
|
|
9008
9106
|
if (!sameBox)
|
|
9009
9107
|
width = box.width, height = box.height;
|
|
9010
9108
|
break;
|
|
@@ -9031,7 +9129,7 @@ var LeaferUI = (function (exports) {
|
|
|
9031
9129
|
translate(data.transform, box.x, box.y);
|
|
9032
9130
|
}
|
|
9033
9131
|
}
|
|
9034
|
-
if (scaleX && mode !== '
|
|
9132
|
+
if (scaleX && mode !== 'stretch') {
|
|
9035
9133
|
data.scaleX = scaleX;
|
|
9036
9134
|
data.scaleY = scaleY;
|
|
9037
9135
|
}
|
|
@@ -9135,7 +9233,7 @@ var LeaferUI = (function (exports) {
|
|
|
9135
9233
|
const { ceil, abs: abs$1 } = Math;
|
|
9136
9234
|
function createPattern(ui, paint, pixelRatio) {
|
|
9137
9235
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
9138
|
-
const id = scaleX + '-' + scaleY;
|
|
9236
|
+
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
9139
9237
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
9140
9238
|
scaleX = abs$1(scaleX);
|
|
9141
9239
|
scaleY = abs$1(scaleY);
|
|
@@ -9197,7 +9295,8 @@ var LeaferUI = (function (exports) {
|
|
|
9197
9295
|
const { abs } = Math;
|
|
9198
9296
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
9199
9297
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
9200
|
-
|
|
9298
|
+
const { pixelRatio } = canvas;
|
|
9299
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
9201
9300
|
return false;
|
|
9202
9301
|
}
|
|
9203
9302
|
else {
|
|
@@ -9205,8 +9304,8 @@ var LeaferUI = (function (exports) {
|
|
|
9205
9304
|
if (allowPaint) {
|
|
9206
9305
|
if (!data.repeat) {
|
|
9207
9306
|
let { width, height } = data;
|
|
9208
|
-
width *= abs(scaleX) *
|
|
9209
|
-
height *= abs(scaleY) *
|
|
9307
|
+
width *= abs(scaleX) * pixelRatio;
|
|
9308
|
+
height *= abs(scaleY) * pixelRatio;
|
|
9210
9309
|
if (data.scaleX) {
|
|
9211
9310
|
width *= data.scaleX;
|
|
9212
9311
|
height *= data.scaleY;
|
|
@@ -9231,15 +9330,15 @@ var LeaferUI = (function (exports) {
|
|
|
9231
9330
|
return true;
|
|
9232
9331
|
}
|
|
9233
9332
|
else {
|
|
9234
|
-
if (!paint.style || Export.running) {
|
|
9235
|
-
createPattern(ui, paint,
|
|
9333
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
9334
|
+
createPattern(ui, paint, pixelRatio);
|
|
9236
9335
|
}
|
|
9237
9336
|
else {
|
|
9238
9337
|
if (!paint.patternTask) {
|
|
9239
9338
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
9240
9339
|
paint.patternTask = null;
|
|
9241
9340
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
9242
|
-
createPattern(ui, paint,
|
|
9341
|
+
createPattern(ui, paint, pixelRatio);
|
|
9243
9342
|
ui.forceUpdate('surface');
|
|
9244
9343
|
}), 300);
|
|
9245
9344
|
}
|
|
@@ -9303,14 +9402,16 @@ var LeaferUI = (function (exports) {
|
|
|
9303
9402
|
return data;
|
|
9304
9403
|
}
|
|
9305
9404
|
function applyStops(gradient, stops, opacity) {
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9405
|
+
if (stops) {
|
|
9406
|
+
let stop;
|
|
9407
|
+
for (let i = 0, len = stops.length; i < len; i++) {
|
|
9408
|
+
stop = stops[i];
|
|
9409
|
+
if (typeof stop === 'string') {
|
|
9410
|
+
gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
|
|
9411
|
+
}
|
|
9412
|
+
else {
|
|
9413
|
+
gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
|
|
9414
|
+
}
|
|
9314
9415
|
}
|
|
9315
9416
|
}
|
|
9316
9417
|
}
|
|
@@ -10066,10 +10167,15 @@ var LeaferUI = (function (exports) {
|
|
|
10066
10167
|
};
|
|
10067
10168
|
|
|
10068
10169
|
function string(color, opacity) {
|
|
10069
|
-
|
|
10070
|
-
|
|
10170
|
+
const doOpacity = typeof opacity === 'number' && opacity !== 1;
|
|
10171
|
+
if (typeof color === 'string') {
|
|
10172
|
+
if (doOpacity && ColorConvert.object)
|
|
10173
|
+
color = ColorConvert.object(color);
|
|
10174
|
+
else
|
|
10175
|
+
return color;
|
|
10176
|
+
}
|
|
10071
10177
|
let a = color.a === undefined ? 1 : color.a;
|
|
10072
|
-
if (
|
|
10178
|
+
if (doOpacity)
|
|
10073
10179
|
a *= opacity;
|
|
10074
10180
|
const rgb = color.r + ',' + color.g + ',' + color.b;
|
|
10075
10181
|
return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
|
|
@@ -10101,6 +10207,7 @@ var LeaferUI = (function (exports) {
|
|
|
10101
10207
|
export(leaf, filename, options) {
|
|
10102
10208
|
this.running = true;
|
|
10103
10209
|
const fileType = FileHelper.fileType(filename);
|
|
10210
|
+
const isDownload = filename.includes('.');
|
|
10104
10211
|
options = FileHelper.getExportOptions(options);
|
|
10105
10212
|
return addTask((success) => new Promise((resolve) => {
|
|
10106
10213
|
const over = (result) => {
|
|
@@ -10110,19 +10217,13 @@ var LeaferUI = (function (exports) {
|
|
|
10110
10217
|
};
|
|
10111
10218
|
const { toURL } = Platform;
|
|
10112
10219
|
const { download } = Platform.origin;
|
|
10113
|
-
if (
|
|
10114
|
-
|
|
10220
|
+
if (fileType === 'json') {
|
|
10221
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
10222
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
10115
10223
|
}
|
|
10116
|
-
|
|
10117
|
-
download(toURL(
|
|
10118
|
-
return over({ data: true });
|
|
10119
|
-
}
|
|
10120
|
-
if (filename === 'svg') {
|
|
10121
|
-
return over({ data: leaf.toSVG() });
|
|
10122
|
-
}
|
|
10123
|
-
else if (fileType === 'svg') {
|
|
10124
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
10125
|
-
return over({ data: true });
|
|
10224
|
+
if (fileType === 'svg') {
|
|
10225
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
10226
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
10126
10227
|
}
|
|
10127
10228
|
const { leafer } = leaf;
|
|
10128
10229
|
if (leafer) {
|
|
@@ -10131,14 +10232,8 @@ var LeaferUI = (function (exports) {
|
|
|
10131
10232
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
10132
10233
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
10133
10234
|
const { slice, trim, onCanvas } = options;
|
|
10134
|
-
let scale = options.scale || 1;
|
|
10135
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
10136
10235
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
10137
10236
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
10138
|
-
if (leaf.isApp) {
|
|
10139
|
-
scale *= pixelRatio;
|
|
10140
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
10141
|
-
}
|
|
10142
10237
|
const screenshot = options.screenshot || leaf.isApp;
|
|
10143
10238
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
10144
10239
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -10172,9 +10267,17 @@ var LeaferUI = (function (exports) {
|
|
|
10172
10267
|
}
|
|
10173
10268
|
renderBounds = leaf.getBounds('render', relative);
|
|
10174
10269
|
}
|
|
10175
|
-
const {
|
|
10270
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
10271
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
10272
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
10273
|
+
if (leaf.isApp) {
|
|
10274
|
+
scaleData.scaleX *= pixelRatio;
|
|
10275
|
+
scaleData.scaleY *= pixelRatio;
|
|
10276
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
10277
|
+
}
|
|
10278
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
10279
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
10176
10280
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
10177
|
-
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
10178
10281
|
let sliceLeaf;
|
|
10179
10282
|
if (slice) {
|
|
10180
10283
|
sliceLeaf = leaf;
|
|
@@ -10280,7 +10383,6 @@ var LeaferUI = (function (exports) {
|
|
|
10280
10383
|
useCanvas();
|
|
10281
10384
|
|
|
10282
10385
|
exports.AlignHelper = AlignHelper;
|
|
10283
|
-
exports.AnimateEvent = AnimateEvent;
|
|
10284
10386
|
exports.AroundHelper = AroundHelper;
|
|
10285
10387
|
exports.AutoBounds = AutoBounds;
|
|
10286
10388
|
exports.BezierHelper = BezierHelper;
|
|
@@ -10301,6 +10403,7 @@ var LeaferUI = (function (exports) {
|
|
|
10301
10403
|
exports.EllipseHelper = EllipseHelper;
|
|
10302
10404
|
exports.Event = Event;
|
|
10303
10405
|
exports.EventCreator = EventCreator;
|
|
10406
|
+
exports.Eventer = Eventer;
|
|
10304
10407
|
exports.Export = Export;
|
|
10305
10408
|
exports.FileHelper = FileHelper;
|
|
10306
10409
|
exports.FrameData = FrameData;
|
|
@@ -10331,6 +10434,7 @@ var LeaferUI = (function (exports) {
|
|
|
10331
10434
|
exports.MathHelper = MathHelper;
|
|
10332
10435
|
exports.Matrix = Matrix;
|
|
10333
10436
|
exports.MatrixHelper = MatrixHelper;
|
|
10437
|
+
exports.MyImage = MyImage;
|
|
10334
10438
|
exports.NeedConvertToCanvasCommandMap = NeedConvertToCanvasCommandMap;
|
|
10335
10439
|
exports.OneRadian = OneRadian;
|
|
10336
10440
|
exports.PI2 = PI2;
|
|
@@ -10370,6 +10474,7 @@ var LeaferUI = (function (exports) {
|
|
|
10370
10474
|
exports.TaskProcessor = TaskProcessor;
|
|
10371
10475
|
exports.TextConvert = TextConvert;
|
|
10372
10476
|
exports.TextData = TextData;
|
|
10477
|
+
exports.Transition = Transition;
|
|
10373
10478
|
exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
|
|
10374
10479
|
exports.UIBounds = UIBounds;
|
|
10375
10480
|
exports.UICreator = UICreator;
|
|
@@ -10381,7 +10486,6 @@ var LeaferUI = (function (exports) {
|
|
|
10381
10486
|
exports.Watcher = Watcher;
|
|
10382
10487
|
exports.affectRenderBoundsType = affectRenderBoundsType;
|
|
10383
10488
|
exports.affectStrokeBoundsType = affectStrokeBoundsType;
|
|
10384
|
-
exports.arrowType = arrowType;
|
|
10385
10489
|
exports.attr = attr;
|
|
10386
10490
|
exports.autoLayoutType = autoLayoutType;
|
|
10387
10491
|
exports.boundsType = boundsType;
|
|
@@ -10404,10 +10508,11 @@ var LeaferUI = (function (exports) {
|
|
|
10404
10508
|
exports.getMatrixData = getMatrixData;
|
|
10405
10509
|
exports.getPointData = getPointData;
|
|
10406
10510
|
exports.hitType = hitType;
|
|
10407
|
-
exports.
|
|
10511
|
+
exports.isNull = isNull;
|
|
10408
10512
|
exports.layoutProcessor = layoutProcessor;
|
|
10409
10513
|
exports.maskType = maskType;
|
|
10410
10514
|
exports.naturalBoundsType = naturalBoundsType;
|
|
10515
|
+
exports.needPlugin = needPlugin;
|
|
10411
10516
|
exports.opacityType = opacityType;
|
|
10412
10517
|
exports.pathInputType = pathInputType;
|
|
10413
10518
|
exports.pathType = pathType;
|
|
@@ -10421,7 +10526,6 @@ var LeaferUI = (function (exports) {
|
|
|
10421
10526
|
exports.rotationType = rotationType;
|
|
10422
10527
|
exports.scaleType = scaleType;
|
|
10423
10528
|
exports.sortType = sortType;
|
|
10424
|
-
exports.stateType = stateType;
|
|
10425
10529
|
exports.strokeType = strokeType;
|
|
10426
10530
|
exports.surfaceType = surfaceType;
|
|
10427
10531
|
exports.tempBounds = tempBounds$1;
|