@leafer-draw/worker 1.6.2 → 1.6.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 +172 -172
- package/dist/worker.esm.js +175 -175
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +1101 -449
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +1100 -449
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/worker.js
CHANGED
|
@@ -26,8 +26,6 @@ var LeaferUI = (function (exports) {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const Creator = {};
|
|
30
|
-
|
|
31
29
|
const IncrementId = {
|
|
32
30
|
RUNTIME: 'runtime',
|
|
33
31
|
LEAF: 'leaf',
|
|
@@ -153,7 +151,7 @@ var LeaferUI = (function (exports) {
|
|
|
153
151
|
|
|
154
152
|
const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
|
|
155
153
|
const { float: float$1 } = MathHelper;
|
|
156
|
-
const tempPoint$
|
|
154
|
+
const tempPoint$3 = {};
|
|
157
155
|
function getWorld() {
|
|
158
156
|
return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
|
|
159
157
|
}
|
|
@@ -196,8 +194,8 @@ var LeaferUI = (function (exports) {
|
|
|
196
194
|
t.d *= scaleY;
|
|
197
195
|
},
|
|
198
196
|
scaleOfOuter(t, origin, scaleX, scaleY) {
|
|
199
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
200
|
-
M$6.scaleOfInner(t, tempPoint$
|
|
197
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
198
|
+
M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
|
|
201
199
|
},
|
|
202
200
|
scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
|
|
203
201
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -215,8 +213,8 @@ var LeaferUI = (function (exports) {
|
|
|
215
213
|
t.d = c * sinR + d * cosR;
|
|
216
214
|
},
|
|
217
215
|
rotateOfOuter(t, origin, rotation) {
|
|
218
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
219
|
-
M$6.rotateOfInner(t, tempPoint$
|
|
216
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
217
|
+
M$6.rotateOfInner(t, tempPoint$3, rotation);
|
|
220
218
|
},
|
|
221
219
|
rotateOfInner(t, origin, rotation) {
|
|
222
220
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -237,8 +235,8 @@ var LeaferUI = (function (exports) {
|
|
|
237
235
|
}
|
|
238
236
|
},
|
|
239
237
|
skewOfOuter(t, origin, skewX, skewY) {
|
|
240
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
241
|
-
M$6.skewOfInner(t, tempPoint$
|
|
238
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
239
|
+
M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
|
|
242
240
|
},
|
|
243
241
|
skewOfInner(t, origin, skewX, skewY = 0) {
|
|
244
242
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -467,8 +465,10 @@ var LeaferUI = (function (exports) {
|
|
|
467
465
|
t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
|
|
468
466
|
},
|
|
469
467
|
move(t, x, y) {
|
|
470
|
-
|
|
471
|
-
|
|
468
|
+
if (typeof x === 'object')
|
|
469
|
+
t.x += x.x, t.y += x.y;
|
|
470
|
+
else
|
|
471
|
+
t.x += x, t.y += y;
|
|
472
472
|
},
|
|
473
473
|
scale(t, scaleX, scaleY = scaleX) {
|
|
474
474
|
if (t.x)
|
|
@@ -493,19 +493,19 @@ var LeaferUI = (function (exports) {
|
|
|
493
493
|
},
|
|
494
494
|
tempToInnerOf(t, matrix) {
|
|
495
495
|
const { tempPoint: temp } = P$5;
|
|
496
|
-
copy$
|
|
496
|
+
copy$b(temp, t);
|
|
497
497
|
toInnerPoint$2(matrix, temp, temp);
|
|
498
498
|
return temp;
|
|
499
499
|
},
|
|
500
500
|
tempToOuterOf(t, matrix) {
|
|
501
501
|
const { tempPoint: temp } = P$5;
|
|
502
|
-
copy$
|
|
502
|
+
copy$b(temp, t);
|
|
503
503
|
toOuterPoint$3(matrix, temp, temp);
|
|
504
504
|
return temp;
|
|
505
505
|
},
|
|
506
506
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
507
507
|
const { tempRadiusPoint: temp } = P$5;
|
|
508
|
-
copy$
|
|
508
|
+
copy$b(temp, t);
|
|
509
509
|
P$5.toInnerRadiusPointOf(t, matrix, temp);
|
|
510
510
|
return temp;
|
|
511
511
|
},
|
|
@@ -578,7 +578,7 @@ var LeaferUI = (function (exports) {
|
|
|
578
578
|
}
|
|
579
579
|
};
|
|
580
580
|
const P$5 = PointHelper;
|
|
581
|
-
const { getDistanceFrom, copy: copy$
|
|
581
|
+
const { getDistanceFrom, copy: copy$b, getAtan2 } = P$5;
|
|
582
582
|
|
|
583
583
|
class Point {
|
|
584
584
|
constructor(x, y) {
|
|
@@ -646,7 +646,7 @@ var LeaferUI = (function (exports) {
|
|
|
646
646
|
return this;
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
const tempPoint$
|
|
649
|
+
const tempPoint$2 = new Point();
|
|
650
650
|
|
|
651
651
|
class Matrix {
|
|
652
652
|
constructor(a, b, c, d, e, f) {
|
|
@@ -804,15 +804,87 @@ var LeaferUI = (function (exports) {
|
|
|
804
804
|
};
|
|
805
805
|
const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
|
|
806
806
|
|
|
807
|
+
exports.Direction4 = void 0;
|
|
808
|
+
(function (Direction4) {
|
|
809
|
+
Direction4[Direction4["top"] = 0] = "top";
|
|
810
|
+
Direction4[Direction4["right"] = 1] = "right";
|
|
811
|
+
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
812
|
+
Direction4[Direction4["left"] = 3] = "left";
|
|
813
|
+
})(exports.Direction4 || (exports.Direction4 = {}));
|
|
814
|
+
exports.Direction9 = void 0;
|
|
815
|
+
(function (Direction9) {
|
|
816
|
+
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
817
|
+
Direction9[Direction9["top"] = 1] = "top";
|
|
818
|
+
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
819
|
+
Direction9[Direction9["right"] = 3] = "right";
|
|
820
|
+
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
821
|
+
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
822
|
+
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
823
|
+
Direction9[Direction9["left"] = 7] = "left";
|
|
824
|
+
Direction9[Direction9["center"] = 8] = "center";
|
|
825
|
+
Direction9[Direction9["top-left"] = 0] = "top-left";
|
|
826
|
+
Direction9[Direction9["top-right"] = 2] = "top-right";
|
|
827
|
+
Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
|
|
828
|
+
Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
|
|
829
|
+
})(exports.Direction9 || (exports.Direction9 = {}));
|
|
830
|
+
|
|
831
|
+
const directionData = [
|
|
832
|
+
{ x: 0, y: 0 },
|
|
833
|
+
{ x: 0.5, y: 0 },
|
|
834
|
+
{ x: 1, y: 0 },
|
|
835
|
+
{ x: 1, y: 0.5 },
|
|
836
|
+
{ x: 1, y: 1 },
|
|
837
|
+
{ x: 0.5, y: 1 },
|
|
838
|
+
{ x: 0, y: 1 },
|
|
839
|
+
{ x: 0, y: 0.5 },
|
|
840
|
+
{ x: 0.5, y: 0.5 }
|
|
841
|
+
];
|
|
842
|
+
directionData.forEach(item => item.type = 'percent');
|
|
843
|
+
const AroundHelper = {
|
|
844
|
+
directionData,
|
|
845
|
+
tempPoint: {},
|
|
846
|
+
get: get$4,
|
|
847
|
+
toPoint(around, box, to, onlyBoxSize, content, onlyContentSize) {
|
|
848
|
+
const point = get$4(around);
|
|
849
|
+
to.x = point.x;
|
|
850
|
+
to.y = point.y;
|
|
851
|
+
if (point.type === 'percent') {
|
|
852
|
+
to.x *= box.width;
|
|
853
|
+
to.y *= box.height;
|
|
854
|
+
if (content) {
|
|
855
|
+
if (!onlyContentSize)
|
|
856
|
+
to.x -= content.x, to.y -= content.y;
|
|
857
|
+
if (point.x)
|
|
858
|
+
to.x -= (point.x === 1) ? content.width : (point.x === 0.5 ? point.x * content.width : 0);
|
|
859
|
+
if (point.y)
|
|
860
|
+
to.y -= (point.y === 1) ? content.height : (point.y === 0.5 ? point.y * content.height : 0);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
if (!onlyBoxSize)
|
|
864
|
+
to.x += box.x, to.y += box.y;
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
function get$4(around) {
|
|
868
|
+
return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
const { toPoint: toPoint$5 } = AroundHelper;
|
|
872
|
+
const AlignHelper = {
|
|
873
|
+
toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
|
|
874
|
+
toPoint$5(align, box, to, onlyBoxSize, content, onlyContentSize);
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
|
|
807
878
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
808
879
|
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
809
880
|
const { float, fourNumber } = MathHelper;
|
|
810
881
|
const { floor, ceil: ceil$2 } = Math;
|
|
811
882
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
812
883
|
const point = {};
|
|
813
|
-
const toPoint$
|
|
884
|
+
const toPoint$4 = {};
|
|
885
|
+
const tempBounds$2 = {};
|
|
814
886
|
const BoundsHelper = {
|
|
815
|
-
tempBounds:
|
|
887
|
+
tempBounds: tempBounds$2,
|
|
816
888
|
set(t, x = 0, y = 0, width = 0, height = 0) {
|
|
817
889
|
t.x = x;
|
|
818
890
|
t.y = y;
|
|
@@ -863,7 +935,7 @@ var LeaferUI = (function (exports) {
|
|
|
863
935
|
to = t;
|
|
864
936
|
}
|
|
865
937
|
else {
|
|
866
|
-
copy$
|
|
938
|
+
copy$a(to, t);
|
|
867
939
|
}
|
|
868
940
|
if (parent) {
|
|
869
941
|
to.offsetX = -(B.maxX(parent) - t.x);
|
|
@@ -875,8 +947,8 @@ var LeaferUI = (function (exports) {
|
|
|
875
947
|
}
|
|
876
948
|
B.move(to, -to.offsetX, -to.offsetY);
|
|
877
949
|
},
|
|
878
|
-
scale(t, scaleX, scaleY = scaleX) {
|
|
879
|
-
PointHelper.scale(t, scaleX, scaleY);
|
|
950
|
+
scale(t, scaleX, scaleY = scaleX, onlySize) {
|
|
951
|
+
onlySize || PointHelper.scale(t, scaleX, scaleY);
|
|
880
952
|
t.width *= scaleX;
|
|
881
953
|
t.height *= scaleY;
|
|
882
954
|
},
|
|
@@ -886,9 +958,9 @@ var LeaferUI = (function (exports) {
|
|
|
886
958
|
t.height *= scaleY;
|
|
887
959
|
},
|
|
888
960
|
tempToOuterOf(t, matrix) {
|
|
889
|
-
B.copy(
|
|
890
|
-
B.toOuterOf(
|
|
891
|
-
return
|
|
961
|
+
B.copy(tempBounds$2, t);
|
|
962
|
+
B.toOuterOf(tempBounds$2, matrix);
|
|
963
|
+
return tempBounds$2;
|
|
892
964
|
},
|
|
893
965
|
getOuterOf(t, matrix) {
|
|
894
966
|
t = Object.assign({}, t);
|
|
@@ -919,17 +991,17 @@ var LeaferUI = (function (exports) {
|
|
|
919
991
|
else {
|
|
920
992
|
point.x = t.x;
|
|
921
993
|
point.y = t.y;
|
|
922
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
923
|
-
setPoint$2(tempPointBounds$1, toPoint$
|
|
994
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
995
|
+
setPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
924
996
|
point.x = t.x + t.width;
|
|
925
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
926
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
997
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
998
|
+
addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
927
999
|
point.y = t.y + t.height;
|
|
928
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
929
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
1000
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
1001
|
+
addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
930
1002
|
point.x = t.x;
|
|
931
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
932
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
1003
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
1004
|
+
addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
933
1005
|
toBounds$3(tempPointBounds$1, to);
|
|
934
1006
|
}
|
|
935
1007
|
},
|
|
@@ -939,9 +1011,21 @@ var LeaferUI = (function (exports) {
|
|
|
939
1011
|
B.scale(to, 1 / matrix.a, 1 / matrix.d);
|
|
940
1012
|
},
|
|
941
1013
|
getFitMatrix(t, put, baseScale = 1) {
|
|
942
|
-
const scale = Math.min(baseScale,
|
|
1014
|
+
const scale = Math.min(baseScale, B.getFitScale(t, put));
|
|
943
1015
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
944
1016
|
},
|
|
1017
|
+
getFitScale(t, put, isCoverMode) {
|
|
1018
|
+
const sw = t.width / put.width, sh = t.height / put.height;
|
|
1019
|
+
return isCoverMode ? Math.max(sw, sh) : Math.min(sw, sh);
|
|
1020
|
+
},
|
|
1021
|
+
put(t, put, align = 'center', putScale = 1, changeSize = true, to) {
|
|
1022
|
+
to || (to = put);
|
|
1023
|
+
if (typeof putScale === 'string')
|
|
1024
|
+
putScale = B.getFitScale(t, put, putScale === 'cover');
|
|
1025
|
+
tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
|
|
1026
|
+
tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
|
|
1027
|
+
AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
|
|
1028
|
+
},
|
|
945
1029
|
getSpread(t, spread, side) {
|
|
946
1030
|
const n = {};
|
|
947
1031
|
B.copyAndSpread(n, t, spread, false, side);
|
|
@@ -1009,7 +1093,7 @@ var LeaferUI = (function (exports) {
|
|
|
1009
1093
|
if (first) {
|
|
1010
1094
|
first = false;
|
|
1011
1095
|
if (!addMode)
|
|
1012
|
-
copy$
|
|
1096
|
+
copy$a(t, bounds);
|
|
1013
1097
|
}
|
|
1014
1098
|
else {
|
|
1015
1099
|
add$1(t, bounds);
|
|
@@ -1090,7 +1174,7 @@ var LeaferUI = (function (exports) {
|
|
|
1090
1174
|
}
|
|
1091
1175
|
};
|
|
1092
1176
|
const B = BoundsHelper;
|
|
1093
|
-
const { add: add$1, copy: copy$
|
|
1177
|
+
const { add: add$1, copy: copy$a } = B;
|
|
1094
1178
|
|
|
1095
1179
|
class Bounds {
|
|
1096
1180
|
get minX() { return BoundsHelper.minX(this); }
|
|
@@ -1115,8 +1199,8 @@ var LeaferUI = (function (exports) {
|
|
|
1115
1199
|
BoundsHelper.move(this, x, y);
|
|
1116
1200
|
return this;
|
|
1117
1201
|
}
|
|
1118
|
-
scale(scaleX, scaleY) {
|
|
1119
|
-
BoundsHelper.scale(this, scaleX, scaleY);
|
|
1202
|
+
scale(scaleX, scaleY, onlySize) {
|
|
1203
|
+
BoundsHelper.scale(this, scaleX, scaleY, onlySize);
|
|
1120
1204
|
return this;
|
|
1121
1205
|
}
|
|
1122
1206
|
scaleOf(origin, scaleX, scaleY) {
|
|
@@ -1134,6 +1218,9 @@ var LeaferUI = (function (exports) {
|
|
|
1134
1218
|
getFitMatrix(put, baseScale) {
|
|
1135
1219
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1136
1220
|
}
|
|
1221
|
+
put(put, align, putScale) {
|
|
1222
|
+
BoundsHelper.put(this, put, align, putScale);
|
|
1223
|
+
}
|
|
1137
1224
|
spread(fourNumber, side) {
|
|
1138
1225
|
BoundsHelper.spread(this, fourNumber, side);
|
|
1139
1226
|
return this;
|
|
@@ -1242,79 +1329,6 @@ var LeaferUI = (function (exports) {
|
|
|
1242
1329
|
}
|
|
1243
1330
|
}
|
|
1244
1331
|
|
|
1245
|
-
exports.Direction4 = void 0;
|
|
1246
|
-
(function (Direction4) {
|
|
1247
|
-
Direction4[Direction4["top"] = 0] = "top";
|
|
1248
|
-
Direction4[Direction4["right"] = 1] = "right";
|
|
1249
|
-
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
1250
|
-
Direction4[Direction4["left"] = 3] = "left";
|
|
1251
|
-
})(exports.Direction4 || (exports.Direction4 = {}));
|
|
1252
|
-
exports.Direction9 = void 0;
|
|
1253
|
-
(function (Direction9) {
|
|
1254
|
-
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
1255
|
-
Direction9[Direction9["top"] = 1] = "top";
|
|
1256
|
-
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
1257
|
-
Direction9[Direction9["right"] = 3] = "right";
|
|
1258
|
-
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
1259
|
-
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
1260
|
-
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
1261
|
-
Direction9[Direction9["left"] = 7] = "left";
|
|
1262
|
-
Direction9[Direction9["center"] = 8] = "center";
|
|
1263
|
-
Direction9[Direction9["top-left"] = 0] = "top-left";
|
|
1264
|
-
Direction9[Direction9["top-right"] = 2] = "top-right";
|
|
1265
|
-
Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
|
|
1266
|
-
Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
|
|
1267
|
-
})(exports.Direction9 || (exports.Direction9 = {}));
|
|
1268
|
-
|
|
1269
|
-
const directionData = [
|
|
1270
|
-
{ x: 0, y: 0 },
|
|
1271
|
-
{ x: 0.5, y: 0 },
|
|
1272
|
-
{ x: 1, y: 0 },
|
|
1273
|
-
{ x: 1, y: 0.5 },
|
|
1274
|
-
{ x: 1, y: 1 },
|
|
1275
|
-
{ x: 0.5, y: 1 },
|
|
1276
|
-
{ x: 0, y: 1 },
|
|
1277
|
-
{ x: 0, y: 0.5 },
|
|
1278
|
-
{ x: 0.5, y: 0.5 }
|
|
1279
|
-
];
|
|
1280
|
-
directionData.forEach(item => item.type = 'percent');
|
|
1281
|
-
const AroundHelper = {
|
|
1282
|
-
directionData,
|
|
1283
|
-
tempPoint: {},
|
|
1284
|
-
get: get$4,
|
|
1285
|
-
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1286
|
-
const point = get$4(around);
|
|
1287
|
-
to.x = point.x;
|
|
1288
|
-
to.y = point.y;
|
|
1289
|
-
if (point.type === 'percent') {
|
|
1290
|
-
to.x *= bounds.width;
|
|
1291
|
-
to.y *= bounds.height;
|
|
1292
|
-
if (pointBounds) {
|
|
1293
|
-
to.x -= pointBounds.x;
|
|
1294
|
-
to.y -= pointBounds.y;
|
|
1295
|
-
if (point.x)
|
|
1296
|
-
to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
|
|
1297
|
-
if (point.y)
|
|
1298
|
-
to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
if (!onlySize) {
|
|
1302
|
-
to.x += bounds.x;
|
|
1303
|
-
to.y += bounds.y;
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
function get$4(around) {
|
|
1308
|
-
return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
const { toPoint: toPoint$4 } = AroundHelper;
|
|
1312
|
-
const AlignHelper = {
|
|
1313
|
-
toPoint(align, contentBounds, bounds, to, onlySize) {
|
|
1314
|
-
toPoint$4(align, bounds, to, onlySize, contentBounds);
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
|
|
1318
1332
|
const StringNumberMap = {
|
|
1319
1333
|
'0': 1,
|
|
1320
1334
|
'1': 1,
|
|
@@ -1445,11 +1459,17 @@ var LeaferUI = (function (exports) {
|
|
|
1445
1459
|
return rs;
|
|
1446
1460
|
},
|
|
1447
1461
|
need(name) {
|
|
1448
|
-
console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1462
|
+
console.error('please install and import plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1449
1463
|
}
|
|
1450
1464
|
};
|
|
1451
1465
|
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
1452
1466
|
|
|
1467
|
+
const Creator = {
|
|
1468
|
+
editor(_options) {
|
|
1469
|
+
return Plugin.need('editor');
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
|
|
1453
1473
|
const debug$d = Debug.get('UICreator');
|
|
1454
1474
|
const UICreator = {
|
|
1455
1475
|
list: {},
|
|
@@ -1587,6 +1607,10 @@ var LeaferUI = (function (exports) {
|
|
|
1587
1607
|
for (let i = 0, len = list.length; i < len; i++)
|
|
1588
1608
|
map[list[i]] = true;
|
|
1589
1609
|
return map;
|
|
1610
|
+
},
|
|
1611
|
+
stintSet(data, attrName, value) {
|
|
1612
|
+
value || (value = undefined);
|
|
1613
|
+
data[attrName] !== value && (data[attrName] = value);
|
|
1590
1614
|
}
|
|
1591
1615
|
};
|
|
1592
1616
|
const { assign } = DataHelper;
|
|
@@ -2045,7 +2069,7 @@ var LeaferUI = (function (exports) {
|
|
|
2045
2069
|
contextMethod()
|
|
2046
2070
|
], Canvas.prototype, "strokeText", null);
|
|
2047
2071
|
|
|
2048
|
-
const { copy: copy$
|
|
2072
|
+
const { copy: copy$9, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
|
|
2049
2073
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
2050
2074
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
2051
2075
|
class LeaferCanvasBase extends Canvas {
|
|
@@ -2277,7 +2301,7 @@ var LeaferUI = (function (exports) {
|
|
|
2277
2301
|
const { size, pixelSnap } = this, canvas = this.manager ? this.manager.get(size) : Creator.canvas(Object.assign({}, size));
|
|
2278
2302
|
canvas.save();
|
|
2279
2303
|
if (useSameWorldTransform)
|
|
2280
|
-
copy$
|
|
2304
|
+
copy$9(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
|
|
2281
2305
|
if (useSameSmooth)
|
|
2282
2306
|
canvas.smooth = this.smooth;
|
|
2283
2307
|
canvas.pixelSnap !== pixelSnap && (canvas.pixelSnap = pixelSnap);
|
|
@@ -2388,7 +2412,7 @@ var LeaferUI = (function (exports) {
|
|
|
2388
2412
|
const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
|
|
2389
2413
|
const { set, toNumberPoints } = PointHelper;
|
|
2390
2414
|
const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2391
|
-
const tempPoint$
|
|
2415
|
+
const tempPoint$1 = {};
|
|
2392
2416
|
const BezierHelper = {
|
|
2393
2417
|
points(data, originPoints, curve, close) {
|
|
2394
2418
|
let points = toNumberPoints(originPoints);
|
|
@@ -2410,6 +2434,8 @@ var LeaferUI = (function (exports) {
|
|
|
2410
2434
|
cY = points[i + 3];
|
|
2411
2435
|
ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
|
|
2412
2436
|
cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
|
|
2437
|
+
if (!ba && !cb)
|
|
2438
|
+
continue;
|
|
2413
2439
|
d = ba + cb;
|
|
2414
2440
|
ba = (t * ba) / d;
|
|
2415
2441
|
cb = (t * cb) / d;
|
|
@@ -2579,8 +2605,8 @@ var LeaferUI = (function (exports) {
|
|
|
2579
2605
|
addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
|
|
2580
2606
|
addPoint$1(pointBounds, toX, toY);
|
|
2581
2607
|
for (let i = 0, len = tList.length; i < len; i++) {
|
|
2582
|
-
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$
|
|
2583
|
-
addPoint$1(pointBounds, tempPoint$
|
|
2608
|
+
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
|
|
2609
|
+
addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
|
|
2584
2610
|
}
|
|
2585
2611
|
},
|
|
2586
2612
|
getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
|
|
@@ -2654,7 +2680,7 @@ var LeaferUI = (function (exports) {
|
|
|
2654
2680
|
};
|
|
2655
2681
|
|
|
2656
2682
|
const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$3, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
|
|
2657
|
-
const { rect: rect$
|
|
2683
|
+
const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2658
2684
|
const { ellipticalArc } = EllipseHelper;
|
|
2659
2685
|
const debug$b = Debug.get('PathConvert');
|
|
2660
2686
|
const setEndPoint$1 = {};
|
|
@@ -2851,7 +2877,7 @@ var LeaferUI = (function (exports) {
|
|
|
2851
2877
|
case N$3:
|
|
2852
2878
|
x = old[i + 1];
|
|
2853
2879
|
y = old[i + 2];
|
|
2854
|
-
curveMode ? rect$
|
|
2880
|
+
curveMode ? rect$3(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
|
|
2855
2881
|
i += 5;
|
|
2856
2882
|
break;
|
|
2857
2883
|
case D$3:
|
|
@@ -3027,7 +3053,7 @@ var LeaferUI = (function (exports) {
|
|
|
3027
3053
|
};
|
|
3028
3054
|
const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
|
|
3029
3055
|
|
|
3030
|
-
const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$
|
|
3056
|
+
const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$2, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
|
|
3031
3057
|
class PathCreator {
|
|
3032
3058
|
set path(value) { this.__path = value; }
|
|
3033
3059
|
get path() { return this.__path; }
|
|
@@ -3074,7 +3100,7 @@ var LeaferUI = (function (exports) {
|
|
|
3074
3100
|
return this;
|
|
3075
3101
|
}
|
|
3076
3102
|
rect(x, y, width, height) {
|
|
3077
|
-
rect$
|
|
3103
|
+
rect$2(this.__path, x, y, width, height);
|
|
3078
3104
|
this.paint();
|
|
3079
3105
|
return this;
|
|
3080
3106
|
}
|
|
@@ -3192,7 +3218,7 @@ var LeaferUI = (function (exports) {
|
|
|
3192
3218
|
|
|
3193
3219
|
const { M: M$1, L: L$2, C, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
|
|
3194
3220
|
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
|
|
3195
|
-
const { addPointBounds, copy: copy$
|
|
3221
|
+
const { addPointBounds, copy: copy$8, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
|
|
3196
3222
|
const debug$9 = Debug.get('PathBounds');
|
|
3197
3223
|
let radius, radiusX, radiusY;
|
|
3198
3224
|
const tempPointBounds = {};
|
|
@@ -3264,7 +3290,7 @@ var LeaferUI = (function (exports) {
|
|
|
3264
3290
|
break;
|
|
3265
3291
|
case G:
|
|
3266
3292
|
ellipse$1(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], data[i + 7], data[i + 8], tempPointBounds, setEndPoint);
|
|
3267
|
-
i === 0 ? copy$
|
|
3293
|
+
i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3268
3294
|
x = setEndPoint.x;
|
|
3269
3295
|
y = setEndPoint.y;
|
|
3270
3296
|
i += 9;
|
|
@@ -3280,7 +3306,7 @@ var LeaferUI = (function (exports) {
|
|
|
3280
3306
|
break;
|
|
3281
3307
|
case O:
|
|
3282
3308
|
arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
|
|
3283
|
-
i === 0 ? copy$
|
|
3309
|
+
i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3284
3310
|
x = setEndPoint.x;
|
|
3285
3311
|
y = setEndPoint.y;
|
|
3286
3312
|
i += 7;
|
|
@@ -3295,7 +3321,7 @@ var LeaferUI = (function (exports) {
|
|
|
3295
3321
|
break;
|
|
3296
3322
|
case U:
|
|
3297
3323
|
arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
|
|
3298
|
-
i === 0 ? copy$
|
|
3324
|
+
i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3299
3325
|
x = setEndPoint.x;
|
|
3300
3326
|
y = setEndPoint.y;
|
|
3301
3327
|
i += 6;
|
|
@@ -3389,7 +3415,7 @@ var LeaferUI = (function (exports) {
|
|
|
3389
3415
|
}
|
|
3390
3416
|
|
|
3391
3417
|
const FileHelper = {
|
|
3392
|
-
|
|
3418
|
+
alphaPixelTypes: ['png', 'webp', 'svg'],
|
|
3393
3419
|
upperCaseTypeMap: {},
|
|
3394
3420
|
mineType(type) {
|
|
3395
3421
|
if (!type || type.startsWith('image'))
|
|
@@ -3416,7 +3442,7 @@ var LeaferUI = (function (exports) {
|
|
|
3416
3442
|
}
|
|
3417
3443
|
};
|
|
3418
3444
|
const F = FileHelper;
|
|
3419
|
-
F.
|
|
3445
|
+
F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3420
3446
|
|
|
3421
3447
|
const debug$8 = Debug.get('TaskProcessor');
|
|
3422
3448
|
class TaskItem {
|
|
@@ -3733,8 +3759,8 @@ var LeaferUI = (function (exports) {
|
|
|
3733
3759
|
list.length = 0;
|
|
3734
3760
|
}
|
|
3735
3761
|
},
|
|
3736
|
-
|
|
3737
|
-
return FileHelper.
|
|
3762
|
+
hasAlphaPixel(config) {
|
|
3763
|
+
return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
|
|
3738
3764
|
},
|
|
3739
3765
|
isFormat(format, config) {
|
|
3740
3766
|
if (config.format === format)
|
|
@@ -3772,7 +3798,7 @@ var LeaferUI = (function (exports) {
|
|
|
3772
3798
|
this.setView(view.config ? view.view : view);
|
|
3773
3799
|
}
|
|
3774
3800
|
ImageManager.isFormat('svg', config) && (this.isSVG = true);
|
|
3775
|
-
ImageManager.
|
|
3801
|
+
ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
|
|
3776
3802
|
}
|
|
3777
3803
|
load(onSuccess, onError) {
|
|
3778
3804
|
if (!this.loading) {
|
|
@@ -4231,8 +4257,8 @@ var LeaferUI = (function (exports) {
|
|
|
4231
4257
|
};
|
|
4232
4258
|
}
|
|
4233
4259
|
|
|
4234
|
-
const { copy: copy$
|
|
4235
|
-
const matrix = {}, { round } = Math;
|
|
4260
|
+
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4261
|
+
const matrix$1 = {}, { round } = Math;
|
|
4236
4262
|
const LeafHelper = {
|
|
4237
4263
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4238
4264
|
if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
|
|
@@ -4327,13 +4353,13 @@ var LeaferUI = (function (exports) {
|
|
|
4327
4353
|
transition = scaleY;
|
|
4328
4354
|
scaleY = scaleX;
|
|
4329
4355
|
}
|
|
4330
|
-
copy$
|
|
4331
|
-
scaleOfOuter$2(matrix, origin, scaleX, scaleY);
|
|
4356
|
+
copy$7(matrix$1, o);
|
|
4357
|
+
scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
|
|
4332
4358
|
if (t.origin || t.around) {
|
|
4333
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4359
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4334
4360
|
}
|
|
4335
4361
|
else {
|
|
4336
|
-
const x = t.x + matrix.e - o.e, y = t.y + matrix.f - o.f;
|
|
4362
|
+
const x = t.x + matrix$1.e - o.e, y = t.y + matrix$1.f - o.f;
|
|
4337
4363
|
if (transition && !resize)
|
|
4338
4364
|
t.animate({ x, y, scaleX: t.scaleX * scaleX, scaleY: t.scaleY * scaleY }, transition);
|
|
4339
4365
|
else
|
|
@@ -4345,32 +4371,32 @@ var LeaferUI = (function (exports) {
|
|
|
4345
4371
|
},
|
|
4346
4372
|
rotateOfLocal(t, origin, angle, transition) {
|
|
4347
4373
|
const o = t.__localMatrix;
|
|
4348
|
-
copy$
|
|
4349
|
-
rotateOfOuter$2(matrix, origin, angle);
|
|
4374
|
+
copy$7(matrix$1, o);
|
|
4375
|
+
rotateOfOuter$2(matrix$1, origin, angle);
|
|
4350
4376
|
if (t.origin || t.around)
|
|
4351
|
-
L.setTransform(t, matrix, false, transition);
|
|
4377
|
+
L.setTransform(t, matrix$1, false, transition);
|
|
4352
4378
|
else
|
|
4353
|
-
t.set({ x: t.x + matrix.e - o.e, y: t.y + matrix.f - o.f, rotation: MathHelper.formatRotation(t.rotation + angle) }, transition);
|
|
4379
|
+
t.set({ x: t.x + matrix$1.e - o.e, y: t.y + matrix$1.f - o.f, rotation: MathHelper.formatRotation(t.rotation + angle) }, transition);
|
|
4354
4380
|
},
|
|
4355
4381
|
skewOfWorld(t, origin, skewX, skewY, resize, transition) {
|
|
4356
4382
|
L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize, transition);
|
|
4357
4383
|
},
|
|
4358
4384
|
skewOfLocal(t, origin, skewX, skewY = 0, resize, transition) {
|
|
4359
|
-
copy$
|
|
4360
|
-
skewOfOuter(matrix, origin, skewX, skewY);
|
|
4361
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4385
|
+
copy$7(matrix$1, t.__localMatrix);
|
|
4386
|
+
skewOfOuter(matrix$1, origin, skewX, skewY);
|
|
4387
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4362
4388
|
},
|
|
4363
4389
|
transformWorld(t, transform, resize, transition) {
|
|
4364
|
-
copy$
|
|
4365
|
-
multiplyParent$2(matrix, transform);
|
|
4390
|
+
copy$7(matrix$1, t.worldTransform);
|
|
4391
|
+
multiplyParent$2(matrix$1, transform);
|
|
4366
4392
|
if (t.parent)
|
|
4367
|
-
divideParent(matrix, t.parent.worldTransform);
|
|
4368
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4393
|
+
divideParent(matrix$1, t.parent.worldTransform);
|
|
4394
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4369
4395
|
},
|
|
4370
4396
|
transform(t, transform, resize, transition) {
|
|
4371
|
-
copy$
|
|
4372
|
-
multiplyParent$2(matrix, transform);
|
|
4373
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4397
|
+
copy$7(matrix$1, t.localTransform);
|
|
4398
|
+
multiplyParent$2(matrix$1, transform);
|
|
4399
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4374
4400
|
},
|
|
4375
4401
|
setTransform(t, transform, resize, transition) {
|
|
4376
4402
|
const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
|
|
@@ -4404,9 +4430,9 @@ var LeaferUI = (function (exports) {
|
|
|
4404
4430
|
return innerOrigin;
|
|
4405
4431
|
},
|
|
4406
4432
|
getRelativeWorld(t, relative, temp) {
|
|
4407
|
-
copy$
|
|
4408
|
-
divideParent(matrix, relative.worldTransform);
|
|
4409
|
-
return temp ? matrix : Object.assign({}, matrix);
|
|
4433
|
+
copy$7(matrix$1, t.worldTransform);
|
|
4434
|
+
divideParent(matrix$1, relative.worldTransform);
|
|
4435
|
+
return temp ? matrix$1 : Object.assign({}, matrix$1);
|
|
4410
4436
|
},
|
|
4411
4437
|
drop(t, parent, index, resize) {
|
|
4412
4438
|
t.setTransform(L.getRelativeWorld(t, parent, true), resize);
|
|
@@ -4460,7 +4486,7 @@ var LeaferUI = (function (exports) {
|
|
|
4460
4486
|
}
|
|
4461
4487
|
};
|
|
4462
4488
|
|
|
4463
|
-
const { updateBounds: updateBounds$
|
|
4489
|
+
const { updateBounds: updateBounds$3 } = LeafHelper;
|
|
4464
4490
|
const BranchHelper = {
|
|
4465
4491
|
sort(a, b) {
|
|
4466
4492
|
return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
|
|
@@ -4522,11 +4548,11 @@ var LeaferUI = (function (exports) {
|
|
|
4522
4548
|
branch = branchStack[i];
|
|
4523
4549
|
children = branch.children;
|
|
4524
4550
|
for (let j = 0, len = children.length; j < len; j++) {
|
|
4525
|
-
updateBounds$
|
|
4551
|
+
updateBounds$3(children[j]);
|
|
4526
4552
|
}
|
|
4527
4553
|
if (exclude && exclude === branch)
|
|
4528
4554
|
continue;
|
|
4529
|
-
updateBounds$
|
|
4555
|
+
updateBounds$3(branch);
|
|
4530
4556
|
}
|
|
4531
4557
|
}
|
|
4532
4558
|
};
|
|
@@ -4544,8 +4570,8 @@ var LeaferUI = (function (exports) {
|
|
|
4544
4570
|
}
|
|
4545
4571
|
};
|
|
4546
4572
|
|
|
4547
|
-
const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
|
|
4548
|
-
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$
|
|
4573
|
+
const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2 } = LeafHelper;
|
|
4574
|
+
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$6 } = BoundsHelper;
|
|
4549
4575
|
const localContent = '_localContentBounds';
|
|
4550
4576
|
const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
|
|
4551
4577
|
class LeafLayout {
|
|
@@ -4588,7 +4614,9 @@ var LeaferUI = (function (exports) {
|
|
|
4588
4614
|
this._localRenderBounds = local;
|
|
4589
4615
|
}
|
|
4590
4616
|
update() {
|
|
4591
|
-
const { leafer } =
|
|
4617
|
+
const { leaf } = this, { leafer } = leaf;
|
|
4618
|
+
if (leaf.isApp)
|
|
4619
|
+
return updateBounds$2(leaf);
|
|
4592
4620
|
if (leafer) {
|
|
4593
4621
|
if (leafer.ready)
|
|
4594
4622
|
leafer.watcher.changed && leafer.layouter.layout();
|
|
@@ -4596,7 +4624,7 @@ var LeaferUI = (function (exports) {
|
|
|
4596
4624
|
leafer.start();
|
|
4597
4625
|
}
|
|
4598
4626
|
else {
|
|
4599
|
-
let root =
|
|
4627
|
+
let root = leaf;
|
|
4600
4628
|
while (root.parent && !root.parent.leafer) {
|
|
4601
4629
|
root = root.parent;
|
|
4602
4630
|
}
|
|
@@ -4703,7 +4731,7 @@ var LeaferUI = (function (exports) {
|
|
|
4703
4731
|
}
|
|
4704
4732
|
if (!layoutBounds)
|
|
4705
4733
|
layoutBounds = MatrixHelper.getLayout(matrix);
|
|
4706
|
-
copy$
|
|
4734
|
+
copy$6(layoutBounds, bounds);
|
|
4707
4735
|
PointHelper.copy(layoutBounds, point);
|
|
4708
4736
|
if (unscale) {
|
|
4709
4737
|
const { scaleX, scaleY } = layoutBounds;
|
|
@@ -4818,7 +4846,7 @@ var LeaferUI = (function (exports) {
|
|
|
4818
4846
|
}
|
|
4819
4847
|
childrenSortChange() {
|
|
4820
4848
|
if (!this.childrenSortChanged) {
|
|
4821
|
-
this.childrenSortChanged = true;
|
|
4849
|
+
this.childrenSortChanged = this.affectChildrenSort = true;
|
|
4822
4850
|
this.leaf.forceUpdate('surface');
|
|
4823
4851
|
}
|
|
4824
4852
|
}
|
|
@@ -4885,6 +4913,40 @@ var LeaferUI = (function (exports) {
|
|
|
4885
4913
|
ImageEvent.LOADED = 'image.loaded';
|
|
4886
4914
|
ImageEvent.ERROR = 'image.error';
|
|
4887
4915
|
|
|
4916
|
+
class BoundsEvent extends Event {
|
|
4917
|
+
static checkHas(leaf, type, mode) {
|
|
4918
|
+
if (mode === 'on') {
|
|
4919
|
+
type === WORLD ? leaf.__hasWorldEvent = true : leaf.__hasLocalEvent = true;
|
|
4920
|
+
}
|
|
4921
|
+
else {
|
|
4922
|
+
leaf.__hasLocalEvent = leaf.hasEvent(RESIZE) || leaf.hasEvent(INNER) || leaf.hasEvent(LOCAL);
|
|
4923
|
+
leaf.__hasWorldEvent = leaf.hasEvent(WORLD);
|
|
4924
|
+
}
|
|
4925
|
+
}
|
|
4926
|
+
static emitLocal(leaf) {
|
|
4927
|
+
if (leaf.leaferIsReady) {
|
|
4928
|
+
const { resized } = leaf.__layout;
|
|
4929
|
+
if (resized !== 'local') {
|
|
4930
|
+
leaf.emit(RESIZE, leaf);
|
|
4931
|
+
if (resized === 'inner')
|
|
4932
|
+
leaf.emit(INNER, leaf);
|
|
4933
|
+
}
|
|
4934
|
+
leaf.emit(LOCAL, leaf);
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
static emitWorld(leaf) {
|
|
4938
|
+
if (leaf.leaferIsReady)
|
|
4939
|
+
leaf.emit(WORLD, this);
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
BoundsEvent.RESIZE = 'bounds.resize';
|
|
4943
|
+
BoundsEvent.INNER = 'bounds.inner';
|
|
4944
|
+
BoundsEvent.LOCAL = 'bounds.local';
|
|
4945
|
+
BoundsEvent.WORLD = 'bounds.world';
|
|
4946
|
+
const { RESIZE, INNER, LOCAL, WORLD } = BoundsEvent;
|
|
4947
|
+
const boundsEventMap = {};
|
|
4948
|
+
[RESIZE, INNER, LOCAL, WORLD].forEach(key => boundsEventMap[key] = 1);
|
|
4949
|
+
|
|
4888
4950
|
class ResizeEvent extends Event {
|
|
4889
4951
|
get bigger() {
|
|
4890
4952
|
if (!this.old)
|
|
@@ -4981,9 +5043,12 @@ var LeaferUI = (function (exports) {
|
|
|
4981
5043
|
set event(map) { this.on(map); }
|
|
4982
5044
|
on(type, listener, options) {
|
|
4983
5045
|
if (!listener) {
|
|
4984
|
-
let event
|
|
4985
|
-
|
|
4986
|
-
|
|
5046
|
+
let event;
|
|
5047
|
+
if (type instanceof Array)
|
|
5048
|
+
type.forEach(item => this.on(item[0], item[1], item[2]));
|
|
5049
|
+
else
|
|
5050
|
+
for (let key in type)
|
|
5051
|
+
(event = type[key]) instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
|
|
4987
5052
|
return;
|
|
4988
5053
|
}
|
|
4989
5054
|
let capture, once;
|
|
@@ -5013,6 +5078,8 @@ var LeaferUI = (function (exports) {
|
|
|
5013
5078
|
else {
|
|
5014
5079
|
map[type] = [item];
|
|
5015
5080
|
}
|
|
5081
|
+
if (boundsEventMap[type])
|
|
5082
|
+
BoundsEvent.checkHas(this, type, 'on');
|
|
5016
5083
|
}
|
|
5017
5084
|
});
|
|
5018
5085
|
}
|
|
@@ -5034,6 +5101,8 @@ var LeaferUI = (function (exports) {
|
|
|
5034
5101
|
events.splice(index, 1);
|
|
5035
5102
|
if (!events.length)
|
|
5036
5103
|
delete map[type];
|
|
5104
|
+
if (boundsEventMap[type])
|
|
5105
|
+
BoundsEvent.checkHas(this, type, 'off');
|
|
5037
5106
|
}
|
|
5038
5107
|
}
|
|
5039
5108
|
});
|
|
@@ -5053,19 +5122,31 @@ var LeaferUI = (function (exports) {
|
|
|
5053
5122
|
}
|
|
5054
5123
|
}
|
|
5055
5124
|
on_(type, listener, bind, options) {
|
|
5056
|
-
if (
|
|
5057
|
-
|
|
5058
|
-
|
|
5125
|
+
if (!listener)
|
|
5126
|
+
(type instanceof Array) && type.forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]));
|
|
5127
|
+
else
|
|
5128
|
+
this.on(type, bind ? listener = listener.bind(bind) : listener, options);
|
|
5059
5129
|
return { type, current: this, listener, options };
|
|
5060
5130
|
}
|
|
5061
5131
|
off_(id) {
|
|
5062
5132
|
if (!id)
|
|
5063
5133
|
return;
|
|
5064
5134
|
const list = id instanceof Array ? id : [id];
|
|
5065
|
-
list.forEach(item =>
|
|
5135
|
+
list.forEach(item => {
|
|
5136
|
+
if (!item.listener)
|
|
5137
|
+
(item.type instanceof Array) && item.type.forEach(v => item.current.off(v[0], v[1], v[3]));
|
|
5138
|
+
else
|
|
5139
|
+
item.current.off(item.type, item.listener, item.options);
|
|
5140
|
+
});
|
|
5066
5141
|
list.length = 0;
|
|
5067
5142
|
}
|
|
5068
|
-
once(type, listener, capture) {
|
|
5143
|
+
once(type, listener, captureOrBind, capture) {
|
|
5144
|
+
if (!listener)
|
|
5145
|
+
return (type instanceof Array) && type.forEach(item => this.once(item[0], item[1], item[2], item[3]));
|
|
5146
|
+
if (typeof captureOrBind === 'object')
|
|
5147
|
+
listener = listener.bind(captureOrBind);
|
|
5148
|
+
else
|
|
5149
|
+
capture = captureOrBind;
|
|
5069
5150
|
this.on(type, listener, { once: true, capture });
|
|
5070
5151
|
}
|
|
5071
5152
|
emit(type, event, capture) {
|
|
@@ -5177,7 +5258,7 @@ var LeaferUI = (function (exports) {
|
|
|
5177
5258
|
};
|
|
5178
5259
|
|
|
5179
5260
|
const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
|
|
5180
|
-
const { toPoint: toPoint$3, tempPoint
|
|
5261
|
+
const { toPoint: toPoint$3, tempPoint } = AroundHelper;
|
|
5181
5262
|
const LeafMatrix = {
|
|
5182
5263
|
__updateWorldMatrix() {
|
|
5183
5264
|
multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
|
|
@@ -5186,33 +5267,39 @@ var LeaferUI = (function (exports) {
|
|
|
5186
5267
|
if (this.__local) {
|
|
5187
5268
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
5188
5269
|
if (layout.affectScaleOrRotation) {
|
|
5189
|
-
if (layout.scaleChanged || layout.rotationChanged) {
|
|
5270
|
+
if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
|
|
5190
5271
|
setLayout(local, data, null, null, layout.affectRotation);
|
|
5191
|
-
layout.scaleChanged = layout.rotationChanged =
|
|
5272
|
+
layout.scaleChanged = layout.rotationChanged = undefined;
|
|
5192
5273
|
}
|
|
5193
5274
|
}
|
|
5194
5275
|
local.e = data.x + data.offsetX;
|
|
5195
5276
|
local.f = data.y + data.offsetY;
|
|
5196
5277
|
if (data.around || data.origin) {
|
|
5197
|
-
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint
|
|
5198
|
-
translateInner(local, -tempPoint
|
|
5278
|
+
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint);
|
|
5279
|
+
translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
|
|
5199
5280
|
}
|
|
5200
5281
|
}
|
|
5201
|
-
this.__layout.matrixChanged =
|
|
5282
|
+
this.__layout.matrixChanged = undefined;
|
|
5202
5283
|
}
|
|
5203
5284
|
};
|
|
5204
5285
|
|
|
5205
5286
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5206
5287
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5207
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$
|
|
5288
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
|
|
5208
5289
|
const { toBounds: toBounds$1 } = PathBounds;
|
|
5209
5290
|
const LeafBounds = {
|
|
5210
5291
|
__updateWorldBounds() {
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5292
|
+
const layout = this.__layout;
|
|
5293
|
+
toOuterOf$1(layout.renderBounds, this.__world, this.__world);
|
|
5294
|
+
if (layout.resized) {
|
|
5295
|
+
if (layout.resized === 'inner')
|
|
5296
|
+
this.__onUpdateSize();
|
|
5297
|
+
if (this.__hasLocalEvent)
|
|
5298
|
+
BoundsEvent.emitLocal(this);
|
|
5299
|
+
layout.resized = undefined;
|
|
5215
5300
|
}
|
|
5301
|
+
if (this.__hasWorldEvent)
|
|
5302
|
+
BoundsEvent.emitWorld(this);
|
|
5216
5303
|
},
|
|
5217
5304
|
__updateLocalBounds() {
|
|
5218
5305
|
const layout = this.__layout;
|
|
@@ -5221,12 +5308,12 @@ var LeaferUI = (function (exports) {
|
|
|
5221
5308
|
this.__updatePath();
|
|
5222
5309
|
this.__updateRenderPath();
|
|
5223
5310
|
this.__updateBoxBounds();
|
|
5224
|
-
layout.resized =
|
|
5311
|
+
layout.resized = 'inner';
|
|
5225
5312
|
}
|
|
5226
5313
|
if (layout.localBoxChanged) {
|
|
5227
5314
|
if (this.__local)
|
|
5228
5315
|
this.__updateLocalBoxBounds();
|
|
5229
|
-
layout.localBoxChanged =
|
|
5316
|
+
layout.localBoxChanged = undefined;
|
|
5230
5317
|
if (layout.strokeSpread)
|
|
5231
5318
|
layout.strokeChanged = true;
|
|
5232
5319
|
if (layout.renderSpread)
|
|
@@ -5234,7 +5321,7 @@ var LeaferUI = (function (exports) {
|
|
|
5234
5321
|
if (this.parent)
|
|
5235
5322
|
this.parent.__layout.boxChange();
|
|
5236
5323
|
}
|
|
5237
|
-
layout.boxChanged =
|
|
5324
|
+
layout.boxChanged = undefined;
|
|
5238
5325
|
if (layout.strokeChanged) {
|
|
5239
5326
|
layout.strokeSpread = this.__updateStrokeSpread();
|
|
5240
5327
|
if (layout.strokeSpread) {
|
|
@@ -5246,12 +5333,12 @@ var LeaferUI = (function (exports) {
|
|
|
5246
5333
|
else {
|
|
5247
5334
|
layout.spreadStrokeCancel();
|
|
5248
5335
|
}
|
|
5249
|
-
layout.strokeChanged =
|
|
5336
|
+
layout.strokeChanged = undefined;
|
|
5250
5337
|
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
|
|
5251
5338
|
layout.renderChanged = true;
|
|
5252
5339
|
if (this.parent)
|
|
5253
5340
|
this.parent.__layout.strokeChange();
|
|
5254
|
-
layout.resized =
|
|
5341
|
+
layout.resized = 'inner';
|
|
5255
5342
|
}
|
|
5256
5343
|
if (layout.renderChanged) {
|
|
5257
5344
|
layout.renderSpread = this.__updateRenderSpread();
|
|
@@ -5264,11 +5351,12 @@ var LeaferUI = (function (exports) {
|
|
|
5264
5351
|
else {
|
|
5265
5352
|
layout.spreadRenderCancel();
|
|
5266
5353
|
}
|
|
5267
|
-
layout.renderChanged =
|
|
5354
|
+
layout.renderChanged = undefined;
|
|
5268
5355
|
if (this.parent)
|
|
5269
5356
|
this.parent.__layout.renderChange();
|
|
5270
5357
|
}
|
|
5271
|
-
layout.
|
|
5358
|
+
layout.resized || (layout.resized = 'local');
|
|
5359
|
+
layout.boundsChanged = undefined;
|
|
5272
5360
|
},
|
|
5273
5361
|
__updateLocalBoxBounds() {
|
|
5274
5362
|
if (this.__hasMotionPath)
|
|
@@ -5328,7 +5416,7 @@ var LeaferUI = (function (exports) {
|
|
|
5328
5416
|
},
|
|
5329
5417
|
__updateRenderBounds() {
|
|
5330
5418
|
const layout = this.__layout;
|
|
5331
|
-
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$
|
|
5419
|
+
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5332
5420
|
}
|
|
5333
5421
|
};
|
|
5334
5422
|
|
|
@@ -5433,7 +5521,7 @@ var LeaferUI = (function (exports) {
|
|
|
5433
5521
|
const { LEAF, create } = IncrementId;
|
|
5434
5522
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5435
5523
|
const { toOuterOf } = BoundsHelper;
|
|
5436
|
-
const { copy: copy$
|
|
5524
|
+
const { copy: copy$4, move } = PointHelper;
|
|
5437
5525
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5438
5526
|
exports.Leaf = class Leaf {
|
|
5439
5527
|
get tag() { return this.__tag; }
|
|
@@ -5646,7 +5734,7 @@ var LeaferUI = (function (exports) {
|
|
|
5646
5734
|
}
|
|
5647
5735
|
else {
|
|
5648
5736
|
if (to)
|
|
5649
|
-
copy$
|
|
5737
|
+
copy$4(to, world);
|
|
5650
5738
|
}
|
|
5651
5739
|
}
|
|
5652
5740
|
localToWorld(local, to, distance, relative) {
|
|
@@ -5655,7 +5743,7 @@ var LeaferUI = (function (exports) {
|
|
|
5655
5743
|
}
|
|
5656
5744
|
else {
|
|
5657
5745
|
if (to)
|
|
5658
|
-
copy$
|
|
5746
|
+
copy$4(to, local);
|
|
5659
5747
|
}
|
|
5660
5748
|
}
|
|
5661
5749
|
worldToInner(world, to, distance, relative) {
|
|
@@ -5808,7 +5896,7 @@ var LeaferUI = (function (exports) {
|
|
|
5808
5896
|
off(_type, _listener, _options) { }
|
|
5809
5897
|
on_(_type, _listener, _bind, _options) { return undefined; }
|
|
5810
5898
|
off_(_id) { }
|
|
5811
|
-
once(_type, _listener, _capture) { }
|
|
5899
|
+
once(_type, _listener, _captureOrBind, _capture) { }
|
|
5812
5900
|
emit(_type, _event, _capture) { }
|
|
5813
5901
|
emitEvent(_event, _capture) { }
|
|
5814
5902
|
hasEvent(_type, _capture) { return false; }
|
|
@@ -6145,7 +6233,7 @@ var LeaferUI = (function (exports) {
|
|
|
6145
6233
|
}
|
|
6146
6234
|
}
|
|
6147
6235
|
|
|
6148
|
-
const version = "1.6.
|
|
6236
|
+
const version = "1.6.3";
|
|
6149
6237
|
|
|
6150
6238
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6151
6239
|
get allowBackgroundColor() { return true; }
|
|
@@ -6304,17 +6392,15 @@ var LeaferUI = (function (exports) {
|
|
|
6304
6392
|
this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
|
|
6305
6393
|
this.__updatedList = new LeafList();
|
|
6306
6394
|
this.totalTimes++;
|
|
6307
|
-
this.changed = false;
|
|
6308
|
-
this.hasVisible = false;
|
|
6309
|
-
this.hasRemove = false;
|
|
6310
|
-
this.hasAdd = false;
|
|
6395
|
+
this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
6311
6396
|
}
|
|
6312
6397
|
__listenEvents() {
|
|
6313
|
-
const { target } = this;
|
|
6314
6398
|
this.__eventIds = [
|
|
6315
|
-
target.on_(
|
|
6316
|
-
|
|
6317
|
-
|
|
6399
|
+
this.target.on_([
|
|
6400
|
+
[PropertyEvent.CHANGE, this.__onAttrChange, this],
|
|
6401
|
+
[[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
|
|
6402
|
+
[WatchEvent.REQUEST, this.__onRquestData, this]
|
|
6403
|
+
])
|
|
6318
6404
|
];
|
|
6319
6405
|
}
|
|
6320
6406
|
__removeListenEvents() {
|
|
@@ -6324,8 +6410,7 @@ var LeaferUI = (function (exports) {
|
|
|
6324
6410
|
if (this.target) {
|
|
6325
6411
|
this.stop();
|
|
6326
6412
|
this.__removeListenEvents();
|
|
6327
|
-
this.target = null;
|
|
6328
|
-
this.__updatedList = null;
|
|
6413
|
+
this.target = this.__updatedList = null;
|
|
6329
6414
|
}
|
|
6330
6415
|
}
|
|
6331
6416
|
}
|
|
@@ -6430,7 +6515,7 @@ var LeaferUI = (function (exports) {
|
|
|
6430
6515
|
this.disabled = true;
|
|
6431
6516
|
}
|
|
6432
6517
|
layout() {
|
|
6433
|
-
if (!this.running)
|
|
6518
|
+
if (this.layouting || !this.running)
|
|
6434
6519
|
return;
|
|
6435
6520
|
const { target } = this;
|
|
6436
6521
|
this.times = 0;
|
|
@@ -6513,12 +6598,10 @@ var LeaferUI = (function (exports) {
|
|
|
6513
6598
|
}
|
|
6514
6599
|
static fullLayout(target) {
|
|
6515
6600
|
updateAllMatrix(target, true);
|
|
6516
|
-
if (target.isBranch)
|
|
6601
|
+
if (target.isBranch)
|
|
6517
6602
|
BranchHelper.updateBounds(target);
|
|
6518
|
-
|
|
6519
|
-
else {
|
|
6603
|
+
else
|
|
6520
6604
|
LeafHelper.updateBounds(target);
|
|
6521
|
-
}
|
|
6522
6605
|
updateAllChange(target);
|
|
6523
6606
|
}
|
|
6524
6607
|
addExtra(leaf) {
|
|
@@ -6541,11 +6624,12 @@ var LeaferUI = (function (exports) {
|
|
|
6541
6624
|
this.__updatedList = event.data.updatedList;
|
|
6542
6625
|
}
|
|
6543
6626
|
__listenEvents() {
|
|
6544
|
-
const { target } = this;
|
|
6545
6627
|
this.__eventIds = [
|
|
6546
|
-
target.on_(
|
|
6547
|
-
|
|
6548
|
-
|
|
6628
|
+
this.target.on_([
|
|
6629
|
+
[LayoutEvent.REQUEST, this.layout, this],
|
|
6630
|
+
[LayoutEvent.AGAIN, this.layoutAgain, this],
|
|
6631
|
+
[WatchEvent.DATA, this.__onReceiveWatchData, this]
|
|
6632
|
+
])
|
|
6549
6633
|
];
|
|
6550
6634
|
}
|
|
6551
6635
|
__removeListenEvents() {
|
|
@@ -6776,12 +6860,13 @@ var LeaferUI = (function (exports) {
|
|
|
6776
6860
|
this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
|
|
6777
6861
|
}
|
|
6778
6862
|
__listenEvents() {
|
|
6779
|
-
const { target } = this;
|
|
6780
6863
|
this.__eventIds = [
|
|
6781
|
-
target.on_(
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6864
|
+
this.target.on_([
|
|
6865
|
+
[RenderEvent.REQUEST, this.update, this],
|
|
6866
|
+
[LayoutEvent.END, this.__onLayoutEnd, this],
|
|
6867
|
+
[RenderEvent.AGAIN, this.renderAgain, this],
|
|
6868
|
+
[ResizeEvent.RESIZE, this.__onResize, this]
|
|
6869
|
+
])
|
|
6785
6870
|
];
|
|
6786
6871
|
}
|
|
6787
6872
|
__removeListenEvents() {
|
|
@@ -6840,8 +6925,32 @@ var LeaferUI = (function (exports) {
|
|
|
6840
6925
|
};
|
|
6841
6926
|
}
|
|
6842
6927
|
|
|
6928
|
+
function hasTransparent$3(color) {
|
|
6929
|
+
if (!color || color.length === 7 || color.length === 4)
|
|
6930
|
+
return false;
|
|
6931
|
+
if (color === 'transparent')
|
|
6932
|
+
return true;
|
|
6933
|
+
const first = color[0];
|
|
6934
|
+
if (first === '#') {
|
|
6935
|
+
switch (color.length) {
|
|
6936
|
+
case 5: return color[4] !== 'f' && color[4] !== 'F';
|
|
6937
|
+
case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
|
|
6938
|
+
}
|
|
6939
|
+
}
|
|
6940
|
+
else if (first === 'r' || first === 'h') {
|
|
6941
|
+
if (color[3] === 'a') {
|
|
6942
|
+
const i = color.lastIndexOf(',');
|
|
6943
|
+
if (i > -1)
|
|
6944
|
+
return parseFloat(color.slice(i + 1)) < 1;
|
|
6945
|
+
}
|
|
6946
|
+
}
|
|
6947
|
+
return false;
|
|
6948
|
+
}
|
|
6949
|
+
|
|
6843
6950
|
const TextConvert = {};
|
|
6844
|
-
const ColorConvert = {
|
|
6951
|
+
const ColorConvert = {
|
|
6952
|
+
hasTransparent: hasTransparent$3
|
|
6953
|
+
};
|
|
6845
6954
|
const UnitConvert = {
|
|
6846
6955
|
number(value, percentRefer) {
|
|
6847
6956
|
return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
|
|
@@ -6867,6 +6976,7 @@ var LeaferUI = (function (exports) {
|
|
|
6867
6976
|
};
|
|
6868
6977
|
|
|
6869
6978
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6979
|
+
const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
|
|
6870
6980
|
const emptyPaint = {};
|
|
6871
6981
|
const debug$1 = Debug.get('UIData');
|
|
6872
6982
|
class UIData extends LeafData {
|
|
@@ -6925,38 +7035,22 @@ var LeaferUI = (function (exports) {
|
|
|
6925
7035
|
if (this.__naturalWidth)
|
|
6926
7036
|
this.__removeNaturalSize();
|
|
6927
7037
|
if (typeof value === 'string' || !value) {
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
PaintImage.recycleImage('fill', this);
|
|
6931
|
-
this.__isFills = false;
|
|
6932
|
-
this.__pixelFill && (this.__pixelFill = false);
|
|
6933
|
-
}
|
|
7038
|
+
stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
|
|
7039
|
+
this.__isFills && this.__removePaint('fill', true);
|
|
6934
7040
|
this._fill = value;
|
|
6935
7041
|
}
|
|
6936
7042
|
else if (typeof value === 'object') {
|
|
6937
|
-
this.
|
|
6938
|
-
const layout = this.__leaf.__layout;
|
|
6939
|
-
layout.boxChanged || layout.boxChange();
|
|
6940
|
-
this.__isFills = true;
|
|
6941
|
-
this._fill || (this._fill = emptyPaint);
|
|
7043
|
+
this.__setPaint('fill', value);
|
|
6942
7044
|
}
|
|
6943
7045
|
}
|
|
6944
7046
|
setStroke(value) {
|
|
6945
7047
|
if (typeof value === 'string' || !value) {
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
PaintImage.recycleImage('stroke', this);
|
|
6949
|
-
this.__isStrokes = false;
|
|
6950
|
-
this.__pixelStroke && (this.__pixelStroke = false);
|
|
6951
|
-
}
|
|
7048
|
+
stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
|
|
7049
|
+
this.__isStrokes && this.__removePaint('stroke', true);
|
|
6952
7050
|
this._stroke = value;
|
|
6953
7051
|
}
|
|
6954
7052
|
else if (typeof value === 'object') {
|
|
6955
|
-
this.
|
|
6956
|
-
const layout = this.__leaf.__layout;
|
|
6957
|
-
layout.boxChanged || layout.boxChange();
|
|
6958
|
-
this.__isStrokes = true;
|
|
6959
|
-
this._stroke || (this._stroke = emptyPaint);
|
|
7053
|
+
this.__setPaint('stroke', value);
|
|
6960
7054
|
}
|
|
6961
7055
|
}
|
|
6962
7056
|
setPath(value) {
|
|
@@ -6986,7 +7080,34 @@ var LeaferUI = (function (exports) {
|
|
|
6986
7080
|
Paint.compute('fill', this.__leaf);
|
|
6987
7081
|
if (stroke)
|
|
6988
7082
|
Paint.compute('stroke', this.__leaf);
|
|
6989
|
-
this.__needComputePaint =
|
|
7083
|
+
this.__needComputePaint = undefined;
|
|
7084
|
+
}
|
|
7085
|
+
__setPaint(attrName, value) {
|
|
7086
|
+
this.__setInput(attrName, value);
|
|
7087
|
+
const layout = this.__leaf.__layout;
|
|
7088
|
+
layout.boxChanged || layout.boxChange();
|
|
7089
|
+
if (value instanceof Array && !value.length) {
|
|
7090
|
+
this.__removePaint(attrName);
|
|
7091
|
+
}
|
|
7092
|
+
else {
|
|
7093
|
+
if (attrName === 'fill')
|
|
7094
|
+
this.__isFills = true, this._fill || (this._fill = emptyPaint);
|
|
7095
|
+
else
|
|
7096
|
+
this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
|
|
7097
|
+
}
|
|
7098
|
+
}
|
|
7099
|
+
__removePaint(attrName, removeInput) {
|
|
7100
|
+
if (removeInput)
|
|
7101
|
+
this.__removeInput(attrName);
|
|
7102
|
+
PaintImage.recycleImage(attrName, this);
|
|
7103
|
+
if (attrName === 'fill') {
|
|
7104
|
+
stintSet$2(this, '__isAlphaPixelFill', undefined);
|
|
7105
|
+
this._fill = this.__isFills = undefined;
|
|
7106
|
+
}
|
|
7107
|
+
else {
|
|
7108
|
+
stintSet$2(this, '__isAlphaPixelStroke', undefined);
|
|
7109
|
+
this._stroke = this.__isStrokes = undefined;
|
|
7110
|
+
}
|
|
6990
7111
|
}
|
|
6991
7112
|
}
|
|
6992
7113
|
function setArray(data, key, value) {
|
|
@@ -6994,10 +7115,10 @@ var LeaferUI = (function (exports) {
|
|
|
6994
7115
|
if (value instanceof Array) {
|
|
6995
7116
|
if (value.some((item) => item.visible === false))
|
|
6996
7117
|
value = value.filter((item) => item.visible !== false);
|
|
6997
|
-
value.length || (value =
|
|
7118
|
+
value.length || (value = undefined);
|
|
6998
7119
|
}
|
|
6999
7120
|
else
|
|
7000
|
-
value = value && value.visible !== false ? [value] :
|
|
7121
|
+
value = value && value.visible !== false ? [value] : undefined;
|
|
7001
7122
|
data['_' + key] = value;
|
|
7002
7123
|
}
|
|
7003
7124
|
|
|
@@ -7100,8 +7221,6 @@ var LeaferUI = (function (exports) {
|
|
|
7100
7221
|
this._url = value;
|
|
7101
7222
|
}
|
|
7102
7223
|
__setImageFill(value) {
|
|
7103
|
-
if (this.__leaf.image)
|
|
7104
|
-
this.__leaf.image = null;
|
|
7105
7224
|
this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
|
|
7106
7225
|
}
|
|
7107
7226
|
__getData() {
|
|
@@ -7167,21 +7286,19 @@ var LeaferUI = (function (exports) {
|
|
|
7167
7286
|
}
|
|
7168
7287
|
};
|
|
7169
7288
|
|
|
7289
|
+
const { stintSet: stintSet$1 } = DataHelper;
|
|
7170
7290
|
const UIRender = {
|
|
7171
7291
|
__updateChange() {
|
|
7172
|
-
const data = this.__
|
|
7292
|
+
const data = this.__;
|
|
7173
7293
|
if (data.__useEffect) {
|
|
7174
|
-
const { shadow,
|
|
7175
|
-
data.
|
|
7294
|
+
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7295
|
+
stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
|
|
7296
|
+
data.__useEffect = !!(shadow || otherEffect);
|
|
7176
7297
|
}
|
|
7177
|
-
|
|
7178
|
-
|
|
7298
|
+
stintSet$1(this.__world, 'half', data.__hasHalf);
|
|
7299
|
+
stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7179
7300
|
data.__checkSingle();
|
|
7180
|
-
|
|
7181
|
-
if (complex)
|
|
7182
|
-
data.__complex = true;
|
|
7183
|
-
else
|
|
7184
|
-
data.__complex && (data.__complex = false);
|
|
7301
|
+
stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7185
7302
|
},
|
|
7186
7303
|
__drawFast(canvas, options) {
|
|
7187
7304
|
drawFast(this, canvas, options);
|
|
@@ -7191,21 +7308,23 @@ var LeaferUI = (function (exports) {
|
|
|
7191
7308
|
if (data.__complex) {
|
|
7192
7309
|
if (data.__needComputePaint)
|
|
7193
7310
|
data.__computePaint();
|
|
7194
|
-
const { fill, stroke, __drawAfterFill } = data;
|
|
7311
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
|
|
7195
7312
|
this.__drawRenderPath(canvas);
|
|
7196
|
-
if (data.__useEffect) {
|
|
7313
|
+
if (data.__useEffect && !__isFastShadow) {
|
|
7197
7314
|
const shape = Paint.shape(this, canvas, options);
|
|
7198
7315
|
this.__nowWorld = this.__getNowWorld(options);
|
|
7199
7316
|
const { shadow, innerShadow, filter } = data;
|
|
7200
7317
|
if (shadow)
|
|
7201
7318
|
Effect.shadow(this, canvas, shape);
|
|
7319
|
+
if (__fillAfterStroke)
|
|
7320
|
+
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7202
7321
|
if (fill)
|
|
7203
7322
|
data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7204
7323
|
if (__drawAfterFill)
|
|
7205
7324
|
this.__drawAfterFill(canvas, options);
|
|
7206
7325
|
if (innerShadow)
|
|
7207
7326
|
Effect.innerShadow(this, canvas, shape);
|
|
7208
|
-
if (stroke)
|
|
7327
|
+
if (stroke && !__fillAfterStroke)
|
|
7209
7328
|
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7210
7329
|
if (filter)
|
|
7211
7330
|
Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
@@ -7214,21 +7333,27 @@ var LeaferUI = (function (exports) {
|
|
|
7214
7333
|
shape.canvas.recycle();
|
|
7215
7334
|
}
|
|
7216
7335
|
else {
|
|
7336
|
+
if (__fillAfterStroke)
|
|
7337
|
+
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7338
|
+
if (__isFastShadow) {
|
|
7339
|
+
const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
|
|
7340
|
+
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
7341
|
+
}
|
|
7217
7342
|
if (fill)
|
|
7218
7343
|
data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7344
|
+
if (__isFastShadow)
|
|
7345
|
+
canvas.restore();
|
|
7219
7346
|
if (__drawAfterFill)
|
|
7220
7347
|
this.__drawAfterFill(canvas, options);
|
|
7221
|
-
if (stroke)
|
|
7348
|
+
if (stroke && !__fillAfterStroke)
|
|
7222
7349
|
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7223
7350
|
}
|
|
7224
7351
|
}
|
|
7225
7352
|
else {
|
|
7226
|
-
if (data.__pathInputed)
|
|
7353
|
+
if (data.__pathInputed)
|
|
7227
7354
|
drawFast(this, canvas, options);
|
|
7228
|
-
|
|
7229
|
-
else {
|
|
7355
|
+
else
|
|
7230
7356
|
this.__drawFast(canvas, options);
|
|
7231
|
-
}
|
|
7232
7357
|
}
|
|
7233
7358
|
},
|
|
7234
7359
|
__renderShape(canvas, options, ignoreFill, ignoreStroke) {
|
|
@@ -7237,11 +7362,11 @@ var LeaferUI = (function (exports) {
|
|
|
7237
7362
|
const { fill, stroke } = this.__;
|
|
7238
7363
|
this.__drawRenderPath(canvas);
|
|
7239
7364
|
if (fill && !ignoreFill)
|
|
7240
|
-
this.__.
|
|
7365
|
+
this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7241
7366
|
if (this.__.__isCanvas)
|
|
7242
7367
|
this.__drawAfterFill(canvas, options);
|
|
7243
7368
|
if (stroke && !ignoreStroke)
|
|
7244
|
-
this.__.
|
|
7369
|
+
this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7245
7370
|
}
|
|
7246
7371
|
},
|
|
7247
7372
|
__drawAfterFill(canvas, options) {
|
|
@@ -7256,13 +7381,15 @@ var LeaferUI = (function (exports) {
|
|
|
7256
7381
|
}
|
|
7257
7382
|
};
|
|
7258
7383
|
function drawFast(ui, canvas, options) {
|
|
7259
|
-
const { fill, stroke, __drawAfterFill } = ui.__;
|
|
7384
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
|
|
7260
7385
|
ui.__drawRenderPath(canvas);
|
|
7386
|
+
if (__fillAfterStroke)
|
|
7387
|
+
Paint.stroke(stroke, ui, canvas);
|
|
7261
7388
|
if (fill)
|
|
7262
7389
|
Paint.fill(fill, ui, canvas);
|
|
7263
7390
|
if (__drawAfterFill)
|
|
7264
7391
|
ui.__drawAfterFill(canvas, options);
|
|
7265
|
-
if (stroke)
|
|
7392
|
+
if (stroke && !__fillAfterStroke)
|
|
7266
7393
|
Paint.stroke(stroke, ui, canvas);
|
|
7267
7394
|
}
|
|
7268
7395
|
|
|
@@ -7634,6 +7761,9 @@ var LeaferUI = (function (exports) {
|
|
|
7634
7761
|
__decorate([
|
|
7635
7762
|
surfaceType()
|
|
7636
7763
|
], exports.UI.prototype, "placeholderColor", void 0);
|
|
7764
|
+
__decorate([
|
|
7765
|
+
dataType(100)
|
|
7766
|
+
], exports.UI.prototype, "placeholderDelay", void 0);
|
|
7637
7767
|
__decorate([
|
|
7638
7768
|
dataType({})
|
|
7639
7769
|
], exports.UI.prototype, "data", void 0);
|
|
@@ -8035,15 +8165,20 @@ var LeaferUI = (function (exports) {
|
|
|
8035
8165
|
}
|
|
8036
8166
|
__listenEvents() {
|
|
8037
8167
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
8038
|
-
this.once(
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8168
|
+
this.once([
|
|
8169
|
+
[LeaferEvent.START, () => Run.end(runId)],
|
|
8170
|
+
[LayoutEvent.START, this.updateLazyBounds, this],
|
|
8171
|
+
[RenderEvent.START, this.__onCreated, this],
|
|
8172
|
+
[RenderEvent.END, this.__onViewReady, this]
|
|
8173
|
+
]);
|
|
8174
|
+
this.__eventIds.push(this.on_([
|
|
8175
|
+
[WatchEvent.DATA, this.__onWatchData, this],
|
|
8176
|
+
[LayoutEvent.END, this.__onLayoutEnd, this],
|
|
8177
|
+
[RenderEvent.NEXT, this.__onNextRender, this]
|
|
8178
|
+
]));
|
|
8043
8179
|
}
|
|
8044
8180
|
__removeListenEvents() {
|
|
8045
8181
|
this.off_(this.__eventIds);
|
|
8046
|
-
this.__eventIds.length = 0;
|
|
8047
8182
|
}
|
|
8048
8183
|
destroy(sync) {
|
|
8049
8184
|
const doDestory = () => {
|
|
@@ -8103,8 +8238,8 @@ var LeaferUI = (function (exports) {
|
|
|
8103
8238
|
registerUI()
|
|
8104
8239
|
], exports.Rect);
|
|
8105
8240
|
|
|
8106
|
-
const { copy: copy$
|
|
8107
|
-
const rect = exports.Rect.prototype, group = exports.Group.prototype;
|
|
8241
|
+
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8242
|
+
const rect$1 = exports.Rect.prototype, group = exports.Group.prototype;
|
|
8108
8243
|
const childrenRenderBounds = {};
|
|
8109
8244
|
exports.Box = class Box extends exports.Group {
|
|
8110
8245
|
get __tag() { return 'Box'; }
|
|
@@ -8149,15 +8284,15 @@ var LeaferUI = (function (exports) {
|
|
|
8149
8284
|
const { renderBounds } = this.__layout;
|
|
8150
8285
|
if (this.children.length) {
|
|
8151
8286
|
super.__updateRenderBounds();
|
|
8152
|
-
copy$
|
|
8287
|
+
copy$3(childrenRenderBounds, renderBounds);
|
|
8153
8288
|
this.__updateRectRenderBounds();
|
|
8154
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds)
|
|
8289
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
8155
8290
|
if (isOverflow && this.__.overflow !== 'hide')
|
|
8156
8291
|
add(renderBounds, childrenRenderBounds);
|
|
8157
8292
|
}
|
|
8158
8293
|
else
|
|
8159
8294
|
this.__updateRectRenderBounds();
|
|
8160
|
-
|
|
8295
|
+
DataHelper.stintSet(this, 'isOverflow', isOverflow);
|
|
8161
8296
|
}
|
|
8162
8297
|
__updateRectRenderBounds() { }
|
|
8163
8298
|
__updateRectChange() { }
|
|
@@ -8201,25 +8336,25 @@ var LeaferUI = (function (exports) {
|
|
|
8201
8336
|
affectRenderBoundsType('show')
|
|
8202
8337
|
], exports.Box.prototype, "overflow", void 0);
|
|
8203
8338
|
__decorate([
|
|
8204
|
-
rewrite(rect.__updateStrokeSpread)
|
|
8339
|
+
rewrite(rect$1.__updateStrokeSpread)
|
|
8205
8340
|
], exports.Box.prototype, "__updateStrokeSpread", null);
|
|
8206
8341
|
__decorate([
|
|
8207
|
-
rewrite(rect.__updateRenderSpread)
|
|
8342
|
+
rewrite(rect$1.__updateRenderSpread)
|
|
8208
8343
|
], exports.Box.prototype, "__updateRectRenderSpread", null);
|
|
8209
8344
|
__decorate([
|
|
8210
|
-
rewrite(rect.__updateBoxBounds)
|
|
8345
|
+
rewrite(rect$1.__updateBoxBounds)
|
|
8211
8346
|
], exports.Box.prototype, "__updateRectBoxBounds", null);
|
|
8212
8347
|
__decorate([
|
|
8213
|
-
rewrite(rect.__updateStrokeBounds)
|
|
8348
|
+
rewrite(rect$1.__updateStrokeBounds)
|
|
8214
8349
|
], exports.Box.prototype, "__updateStrokeBounds", null);
|
|
8215
8350
|
__decorate([
|
|
8216
|
-
rewrite(rect.__updateRenderBounds)
|
|
8351
|
+
rewrite(rect$1.__updateRenderBounds)
|
|
8217
8352
|
], exports.Box.prototype, "__updateRectRenderBounds", null);
|
|
8218
8353
|
__decorate([
|
|
8219
|
-
rewrite(rect.__updateChange)
|
|
8354
|
+
rewrite(rect$1.__updateChange)
|
|
8220
8355
|
], exports.Box.prototype, "__updateRectChange", null);
|
|
8221
8356
|
__decorate([
|
|
8222
|
-
rewrite(rect.__render)
|
|
8357
|
+
rewrite(rect$1.__render)
|
|
8223
8358
|
], exports.Box.prototype, "__renderRect", null);
|
|
8224
8359
|
__decorate([
|
|
8225
8360
|
rewrite(group.__render)
|
|
@@ -8461,18 +8596,10 @@ var LeaferUI = (function (exports) {
|
|
|
8461
8596
|
|
|
8462
8597
|
exports.Image = class Image extends exports.Rect {
|
|
8463
8598
|
get __tag() { return 'Image'; }
|
|
8464
|
-
get ready() {
|
|
8599
|
+
get ready() { const { image } = this; return image && image.ready; }
|
|
8600
|
+
get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
|
|
8465
8601
|
constructor(data) {
|
|
8466
8602
|
super(data);
|
|
8467
|
-
this.on_(ImageEvent.LOADED, this.__onLoaded, this);
|
|
8468
|
-
}
|
|
8469
|
-
__onLoaded(e) {
|
|
8470
|
-
if (e.attrName === 'fill' && e.attrValue.url === this.url)
|
|
8471
|
-
this.image = e.image;
|
|
8472
|
-
}
|
|
8473
|
-
destroy() {
|
|
8474
|
-
this.image = null;
|
|
8475
|
-
super.destroy();
|
|
8476
8603
|
}
|
|
8477
8604
|
};
|
|
8478
8605
|
__decorate([
|
|
@@ -8488,11 +8615,11 @@ var LeaferUI = (function (exports) {
|
|
|
8488
8615
|
|
|
8489
8616
|
exports.Canvas = class Canvas extends exports.Rect {
|
|
8490
8617
|
get __tag() { return 'Canvas'; }
|
|
8618
|
+
get context() { return this.canvas.context; }
|
|
8491
8619
|
get ready() { return !this.url; }
|
|
8492
8620
|
constructor(data) {
|
|
8493
8621
|
super(data);
|
|
8494
8622
|
this.canvas = Creator.canvas(this.__);
|
|
8495
|
-
this.context = this.canvas.context;
|
|
8496
8623
|
if (data && data.url)
|
|
8497
8624
|
this.drawImage(data.url);
|
|
8498
8625
|
}
|
|
@@ -8536,7 +8663,7 @@ var LeaferUI = (function (exports) {
|
|
|
8536
8663
|
destroy() {
|
|
8537
8664
|
if (this.canvas) {
|
|
8538
8665
|
this.canvas.destroy();
|
|
8539
|
-
this.canvas =
|
|
8666
|
+
this.canvas = null;
|
|
8540
8667
|
}
|
|
8541
8668
|
super.destroy();
|
|
8542
8669
|
}
|
|
@@ -8612,12 +8739,11 @@ var LeaferUI = (function (exports) {
|
|
|
8612
8739
|
super.__updateBoxBounds();
|
|
8613
8740
|
if (italic)
|
|
8614
8741
|
b.width += fontSize * 0.16;
|
|
8615
|
-
|
|
8616
|
-
if (isOverflow)
|
|
8742
|
+
DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
|
|
8743
|
+
if (this.isOverflow)
|
|
8617
8744
|
setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
|
|
8618
8745
|
else
|
|
8619
8746
|
data.__textBoxBounds = b;
|
|
8620
|
-
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8621
8747
|
}
|
|
8622
8748
|
__onUpdateSize() {
|
|
8623
8749
|
if (this.__box)
|
|
@@ -8862,32 +8988,557 @@ var LeaferUI = (function (exports) {
|
|
|
8862
8988
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
8863
8989
|
}
|
|
8864
8990
|
|
|
8991
|
+
let App = class App extends exports.Leafer {
|
|
8992
|
+
get __tag() { return 'App'; }
|
|
8993
|
+
get isApp() { return true; }
|
|
8994
|
+
constructor(userConfig, data) {
|
|
8995
|
+
super(userConfig, data);
|
|
8996
|
+
}
|
|
8997
|
+
init(userConfig, parentApp) {
|
|
8998
|
+
super.init(userConfig, parentApp);
|
|
8999
|
+
if (userConfig) {
|
|
9000
|
+
const { ground, tree, sky, editor } = userConfig;
|
|
9001
|
+
if (ground)
|
|
9002
|
+
this.ground = this.addLeafer(ground);
|
|
9003
|
+
if (tree || editor)
|
|
9004
|
+
this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
|
|
9005
|
+
if (sky || editor)
|
|
9006
|
+
this.sky = this.addLeafer(sky);
|
|
9007
|
+
if (editor)
|
|
9008
|
+
Creator.editor(editor, this);
|
|
9009
|
+
}
|
|
9010
|
+
}
|
|
9011
|
+
__setApp() {
|
|
9012
|
+
const { canvas } = this;
|
|
9013
|
+
const { realCanvas, view } = this.config;
|
|
9014
|
+
if (realCanvas || view === this.canvas.view || !canvas.parentView)
|
|
9015
|
+
this.realCanvas = true;
|
|
9016
|
+
else
|
|
9017
|
+
canvas.unrealCanvas();
|
|
9018
|
+
this.leafer = this;
|
|
9019
|
+
this.watcher.disable();
|
|
9020
|
+
this.layouter.disable();
|
|
9021
|
+
}
|
|
9022
|
+
__updateLocalBounds() {
|
|
9023
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9024
|
+
super.__updateLocalBounds();
|
|
9025
|
+
}
|
|
9026
|
+
start() {
|
|
9027
|
+
super.start();
|
|
9028
|
+
this.forEach(leafer => leafer.start());
|
|
9029
|
+
}
|
|
9030
|
+
stop() {
|
|
9031
|
+
this.forEach(leafer => leafer.stop());
|
|
9032
|
+
super.stop();
|
|
9033
|
+
}
|
|
9034
|
+
unlockLayout() {
|
|
9035
|
+
super.unlockLayout();
|
|
9036
|
+
this.forEach(leafer => leafer.unlockLayout());
|
|
9037
|
+
}
|
|
9038
|
+
lockLayout() {
|
|
9039
|
+
super.lockLayout();
|
|
9040
|
+
this.forEach(leafer => leafer.lockLayout());
|
|
9041
|
+
}
|
|
9042
|
+
forceRender(bounds, sync) {
|
|
9043
|
+
this.forEach(leafer => leafer.forceRender(bounds, sync));
|
|
9044
|
+
}
|
|
9045
|
+
addLeafer(merge) {
|
|
9046
|
+
const leafer = new exports.Leafer(merge);
|
|
9047
|
+
this.add(leafer);
|
|
9048
|
+
return leafer;
|
|
9049
|
+
}
|
|
9050
|
+
add(leafer, index) {
|
|
9051
|
+
if (!leafer.view) {
|
|
9052
|
+
if (this.realCanvas && !this.canvas.bounds) {
|
|
9053
|
+
setTimeout(() => this.add(leafer, index), 10);
|
|
9054
|
+
return;
|
|
9055
|
+
}
|
|
9056
|
+
leafer.init(this.__getChildConfig(leafer.userConfig), this);
|
|
9057
|
+
}
|
|
9058
|
+
super.add(leafer, index);
|
|
9059
|
+
if (index !== undefined)
|
|
9060
|
+
leafer.canvas.childIndex = index;
|
|
9061
|
+
this.__listenChildEvents(leafer);
|
|
9062
|
+
}
|
|
9063
|
+
forEach(fn) {
|
|
9064
|
+
this.children.forEach(fn);
|
|
9065
|
+
}
|
|
9066
|
+
__onCreated() {
|
|
9067
|
+
this.created = this.children.every(child => child.created);
|
|
9068
|
+
}
|
|
9069
|
+
__onReady() {
|
|
9070
|
+
if (this.children.every(child => child.ready))
|
|
9071
|
+
super.__onReady();
|
|
9072
|
+
}
|
|
9073
|
+
__onViewReady() {
|
|
9074
|
+
if (this.children.every(child => child.viewReady))
|
|
9075
|
+
super.__onViewReady();
|
|
9076
|
+
}
|
|
9077
|
+
__onChildRenderEnd(e) {
|
|
9078
|
+
this.renderer.addBlock(e.renderBounds);
|
|
9079
|
+
if (this.viewReady)
|
|
9080
|
+
this.renderer.update();
|
|
9081
|
+
}
|
|
9082
|
+
__render(canvas, options) {
|
|
9083
|
+
if (canvas.context)
|
|
9084
|
+
this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
|
|
9085
|
+
}
|
|
9086
|
+
__onResize(event) {
|
|
9087
|
+
this.forEach(leafer => leafer.resize(event));
|
|
9088
|
+
super.__onResize(event);
|
|
9089
|
+
}
|
|
9090
|
+
updateLayout() {
|
|
9091
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9092
|
+
}
|
|
9093
|
+
__getChildConfig(userConfig) {
|
|
9094
|
+
const config = Object.assign({}, this.config);
|
|
9095
|
+
config.hittable = config.realCanvas = undefined;
|
|
9096
|
+
if (userConfig)
|
|
9097
|
+
DataHelper.assign(config, userConfig);
|
|
9098
|
+
if (this.autoLayout)
|
|
9099
|
+
DataHelper.copyAttrs(config, this, canvasSizeAttrs);
|
|
9100
|
+
config.view = this.realCanvas ? undefined : this.view;
|
|
9101
|
+
config.fill = undefined;
|
|
9102
|
+
return config;
|
|
9103
|
+
}
|
|
9104
|
+
__listenChildEvents(leafer) {
|
|
9105
|
+
leafer.once([
|
|
9106
|
+
[LayoutEvent.END, this.__onReady, this],
|
|
9107
|
+
[RenderEvent.START, this.__onCreated, this],
|
|
9108
|
+
[RenderEvent.END, this.__onViewReady, this]
|
|
9109
|
+
]);
|
|
9110
|
+
if (this.realCanvas)
|
|
9111
|
+
this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
|
|
9112
|
+
}
|
|
9113
|
+
};
|
|
9114
|
+
App = __decorate([
|
|
9115
|
+
registerUI()
|
|
9116
|
+
], App);
|
|
9117
|
+
|
|
9118
|
+
const downKeyMap = {};
|
|
9119
|
+
const Keyboard = {
|
|
9120
|
+
isHoldSpaceKey() {
|
|
9121
|
+
return Keyboard.isHold('Space');
|
|
9122
|
+
},
|
|
9123
|
+
isHold(code) {
|
|
9124
|
+
return downKeyMap[code];
|
|
9125
|
+
},
|
|
9126
|
+
setDownCode(code) {
|
|
9127
|
+
if (!downKeyMap[code])
|
|
9128
|
+
downKeyMap[code] = true;
|
|
9129
|
+
},
|
|
9130
|
+
setUpCode(code) {
|
|
9131
|
+
downKeyMap[code] = false;
|
|
9132
|
+
}
|
|
9133
|
+
};
|
|
9134
|
+
|
|
9135
|
+
const PointerButton = {
|
|
9136
|
+
LEFT: 1,
|
|
9137
|
+
RIGHT: 2,
|
|
9138
|
+
MIDDLE: 4,
|
|
9139
|
+
defaultLeft(event) { if (!event.buttons)
|
|
9140
|
+
event.buttons = 1; },
|
|
9141
|
+
left(event) { return event.buttons === 1; },
|
|
9142
|
+
right(event) { return event.buttons === 2; },
|
|
9143
|
+
middle(event) { return event.buttons === 4; }
|
|
9144
|
+
};
|
|
9145
|
+
|
|
9146
|
+
class UIEvent extends Event {
|
|
9147
|
+
get spaceKey() { return Keyboard.isHoldSpaceKey(); }
|
|
9148
|
+
get left() { return PointerButton.left(this); }
|
|
9149
|
+
get right() { return PointerButton.right(this); }
|
|
9150
|
+
get middle() { return PointerButton.middle(this); }
|
|
9151
|
+
constructor(params) {
|
|
9152
|
+
super(params.type);
|
|
9153
|
+
this.bubbles = true;
|
|
9154
|
+
Object.assign(this, params);
|
|
9155
|
+
}
|
|
9156
|
+
getBoxPoint(relative) {
|
|
9157
|
+
return (relative || this.current).getBoxPoint(this);
|
|
9158
|
+
}
|
|
9159
|
+
getInnerPoint(relative) {
|
|
9160
|
+
return (relative || this.current).getInnerPoint(this);
|
|
9161
|
+
}
|
|
9162
|
+
getLocalPoint(relative) {
|
|
9163
|
+
return (relative || this.current).getLocalPoint(this);
|
|
9164
|
+
}
|
|
9165
|
+
getPagePoint() {
|
|
9166
|
+
return this.current.getPagePoint(this);
|
|
9167
|
+
}
|
|
9168
|
+
getInner(relative) { return this.getInnerPoint(relative); }
|
|
9169
|
+
getLocal(relative) { return this.getLocalPoint(relative); }
|
|
9170
|
+
getPage() { return this.getPagePoint(); }
|
|
9171
|
+
static changeName(oldName, newName) {
|
|
9172
|
+
EventCreator.changeName(oldName, newName);
|
|
9173
|
+
}
|
|
9174
|
+
}
|
|
9175
|
+
|
|
9176
|
+
let PointerEvent = class PointerEvent extends UIEvent {
|
|
9177
|
+
};
|
|
9178
|
+
PointerEvent.POINTER = 'pointer';
|
|
9179
|
+
PointerEvent.BEFORE_DOWN = 'pointer.before_down';
|
|
9180
|
+
PointerEvent.BEFORE_MOVE = 'pointer.before_move';
|
|
9181
|
+
PointerEvent.BEFORE_UP = 'pointer.before_up';
|
|
9182
|
+
PointerEvent.DOWN = 'pointer.down';
|
|
9183
|
+
PointerEvent.MOVE = 'pointer.move';
|
|
9184
|
+
PointerEvent.UP = 'pointer.up';
|
|
9185
|
+
PointerEvent.OVER = 'pointer.over';
|
|
9186
|
+
PointerEvent.OUT = 'pointer.out';
|
|
9187
|
+
PointerEvent.ENTER = 'pointer.enter';
|
|
9188
|
+
PointerEvent.LEAVE = 'pointer.leave';
|
|
9189
|
+
PointerEvent.TAP = 'tap';
|
|
9190
|
+
PointerEvent.DOUBLE_TAP = 'double_tap';
|
|
9191
|
+
PointerEvent.CLICK = 'click';
|
|
9192
|
+
PointerEvent.DOUBLE_CLICK = 'double_click';
|
|
9193
|
+
PointerEvent.LONG_PRESS = 'long_press';
|
|
9194
|
+
PointerEvent.LONG_TAP = 'long_tap';
|
|
9195
|
+
PointerEvent.MENU = 'pointer.menu';
|
|
9196
|
+
PointerEvent.MENU_TAP = 'pointer.menu_tap';
|
|
9197
|
+
PointerEvent = __decorate([
|
|
9198
|
+
registerUIEvent()
|
|
9199
|
+
], PointerEvent);
|
|
9200
|
+
|
|
9201
|
+
const tempMove = {};
|
|
9202
|
+
let DragEvent = class DragEvent extends PointerEvent {
|
|
9203
|
+
static setList(data) {
|
|
9204
|
+
this.list = data instanceof LeafList ? data : new LeafList(data);
|
|
9205
|
+
}
|
|
9206
|
+
static setData(data) {
|
|
9207
|
+
this.data = data;
|
|
9208
|
+
}
|
|
9209
|
+
static getValidMove(leaf, start, total) {
|
|
9210
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9211
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9212
|
+
if (dragBounds)
|
|
9213
|
+
this.getMoveInDragBounds(leaf.__localBoxBounds, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9214
|
+
if (draggable === 'x')
|
|
9215
|
+
move.y = 0;
|
|
9216
|
+
if (draggable === 'y')
|
|
9217
|
+
move.x = 0;
|
|
9218
|
+
return move;
|
|
9219
|
+
}
|
|
9220
|
+
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9221
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9222
|
+
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9223
|
+
if (!change)
|
|
9224
|
+
move = Object.assign({}, move);
|
|
9225
|
+
if (BoundsHelper.includes(childBox, dragBounds)) {
|
|
9226
|
+
if (x > dragBounds.x)
|
|
9227
|
+
move.x += dragBounds.x - x;
|
|
9228
|
+
else if (right < boundsRight)
|
|
9229
|
+
move.x += boundsRight - right;
|
|
9230
|
+
if (y > dragBounds.y)
|
|
9231
|
+
move.y += dragBounds.y - y;
|
|
9232
|
+
else if (bottom < boundsBottom)
|
|
9233
|
+
move.y += boundsBottom - bottom;
|
|
9234
|
+
}
|
|
9235
|
+
else {
|
|
9236
|
+
if (x < dragBounds.x)
|
|
9237
|
+
move.x += dragBounds.x - x;
|
|
9238
|
+
else if (right > boundsRight)
|
|
9239
|
+
move.x += boundsRight - right;
|
|
9240
|
+
if (y < dragBounds.y)
|
|
9241
|
+
move.y += dragBounds.y - y;
|
|
9242
|
+
else if (bottom > boundsBottom)
|
|
9243
|
+
move.y += boundsBottom - bottom;
|
|
9244
|
+
}
|
|
9245
|
+
return move;
|
|
9246
|
+
}
|
|
9247
|
+
getPageMove(total) {
|
|
9248
|
+
this.assignMove(total);
|
|
9249
|
+
return this.current.getPagePoint(tempMove, null, true);
|
|
9250
|
+
}
|
|
9251
|
+
getInnerMove(relative, total) {
|
|
9252
|
+
if (!relative)
|
|
9253
|
+
relative = this.current;
|
|
9254
|
+
this.assignMove(total);
|
|
9255
|
+
return relative.getInnerPoint(tempMove, null, true);
|
|
9256
|
+
}
|
|
9257
|
+
getLocalMove(relative, total) {
|
|
9258
|
+
if (!relative)
|
|
9259
|
+
relative = this.current;
|
|
9260
|
+
this.assignMove(total);
|
|
9261
|
+
return relative.getLocalPoint(tempMove, null, true);
|
|
9262
|
+
}
|
|
9263
|
+
getPageTotal() {
|
|
9264
|
+
return this.getPageMove(true);
|
|
9265
|
+
}
|
|
9266
|
+
getInnerTotal(relative) {
|
|
9267
|
+
return this.getInnerMove(relative, true);
|
|
9268
|
+
}
|
|
9269
|
+
getLocalTotal(relative) {
|
|
9270
|
+
return this.getLocalMove(relative, true);
|
|
9271
|
+
}
|
|
9272
|
+
getPageBounds() {
|
|
9273
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9274
|
+
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9275
|
+
BoundsHelper.unsign(bounds);
|
|
9276
|
+
return bounds;
|
|
9277
|
+
}
|
|
9278
|
+
assignMove(total) {
|
|
9279
|
+
tempMove.x = total ? this.totalX : this.moveX;
|
|
9280
|
+
tempMove.y = total ? this.totalY : this.moveY;
|
|
9281
|
+
}
|
|
9282
|
+
};
|
|
9283
|
+
DragEvent.BEFORE_DRAG = 'drag.before_drag';
|
|
9284
|
+
DragEvent.START = 'drag.start';
|
|
9285
|
+
DragEvent.DRAG = 'drag';
|
|
9286
|
+
DragEvent.END = 'drag.end';
|
|
9287
|
+
DragEvent.OVER = 'drag.over';
|
|
9288
|
+
DragEvent.OUT = 'drag.out';
|
|
9289
|
+
DragEvent.ENTER = 'drag.enter';
|
|
9290
|
+
DragEvent.LEAVE = 'drag.leave';
|
|
9291
|
+
DragEvent = __decorate([
|
|
9292
|
+
registerUIEvent()
|
|
9293
|
+
], DragEvent);
|
|
9294
|
+
|
|
9295
|
+
let DropEvent = class DropEvent extends PointerEvent {
|
|
9296
|
+
static setList(data) {
|
|
9297
|
+
DragEvent.setList(data);
|
|
9298
|
+
}
|
|
9299
|
+
static setData(data) {
|
|
9300
|
+
DragEvent.setData(data);
|
|
9301
|
+
}
|
|
9302
|
+
};
|
|
9303
|
+
DropEvent.DROP = 'drop';
|
|
9304
|
+
DropEvent = __decorate([
|
|
9305
|
+
registerUIEvent()
|
|
9306
|
+
], DropEvent);
|
|
9307
|
+
|
|
9308
|
+
let MoveEvent = class MoveEvent extends DragEvent {
|
|
9309
|
+
};
|
|
9310
|
+
MoveEvent.BEFORE_MOVE = 'move.before_move';
|
|
9311
|
+
MoveEvent.START = 'move.start';
|
|
9312
|
+
MoveEvent.MOVE = 'move';
|
|
9313
|
+
MoveEvent.END = 'move.end';
|
|
9314
|
+
MoveEvent = __decorate([
|
|
9315
|
+
registerUIEvent()
|
|
9316
|
+
], MoveEvent);
|
|
9317
|
+
|
|
9318
|
+
let RotateEvent = class RotateEvent extends PointerEvent {
|
|
9319
|
+
};
|
|
9320
|
+
RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
|
|
9321
|
+
RotateEvent.START = 'rotate.start';
|
|
9322
|
+
RotateEvent.ROTATE = 'rotate';
|
|
9323
|
+
RotateEvent.END = 'rotate.end';
|
|
9324
|
+
RotateEvent = __decorate([
|
|
9325
|
+
registerUIEvent()
|
|
9326
|
+
], RotateEvent);
|
|
9327
|
+
|
|
9328
|
+
let SwipeEvent = class SwipeEvent extends DragEvent {
|
|
9329
|
+
};
|
|
9330
|
+
SwipeEvent.SWIPE = 'swipe';
|
|
9331
|
+
SwipeEvent.LEFT = 'swipe.left';
|
|
9332
|
+
SwipeEvent.RIGHT = 'swipe.right';
|
|
9333
|
+
SwipeEvent.UP = 'swipe.up';
|
|
9334
|
+
SwipeEvent.DOWN = 'swipe.down';
|
|
9335
|
+
SwipeEvent = __decorate([
|
|
9336
|
+
registerUIEvent()
|
|
9337
|
+
], SwipeEvent);
|
|
9338
|
+
|
|
9339
|
+
let ZoomEvent = class ZoomEvent extends PointerEvent {
|
|
9340
|
+
};
|
|
9341
|
+
ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
|
|
9342
|
+
ZoomEvent.START = 'zoom.start';
|
|
9343
|
+
ZoomEvent.ZOOM = 'zoom';
|
|
9344
|
+
ZoomEvent.END = 'zoom.end';
|
|
9345
|
+
ZoomEvent = __decorate([
|
|
9346
|
+
registerUIEvent()
|
|
9347
|
+
], ZoomEvent);
|
|
9348
|
+
|
|
9349
|
+
let KeyEvent = class KeyEvent extends UIEvent {
|
|
9350
|
+
};
|
|
9351
|
+
KeyEvent.DOWN = 'key.down';
|
|
9352
|
+
KeyEvent.HOLD = 'key.hold';
|
|
9353
|
+
KeyEvent.UP = 'key.up';
|
|
9354
|
+
KeyEvent = __decorate([
|
|
9355
|
+
registerUIEvent()
|
|
9356
|
+
], KeyEvent);
|
|
9357
|
+
|
|
9358
|
+
new LeafList();
|
|
9359
|
+
|
|
9360
|
+
Debug.get('emit');
|
|
9361
|
+
|
|
9362
|
+
const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
|
|
9363
|
+
const inner = {};
|
|
9364
|
+
const leaf = exports.Leaf.prototype;
|
|
9365
|
+
leaf.__hitWorld = function (point) {
|
|
9366
|
+
const data = this.__;
|
|
9367
|
+
if (!data.hitSelf)
|
|
9368
|
+
return false;
|
|
9369
|
+
const world = this.__world, layout = this.__layout;
|
|
9370
|
+
const isSmall = world.width < 10 && world.height < 10;
|
|
9371
|
+
if (data.hitRadius) {
|
|
9372
|
+
copy$2(inner, point), point = inner;
|
|
9373
|
+
setRadius(point, data.hitRadius);
|
|
9374
|
+
}
|
|
9375
|
+
toInnerRadiusPointOf(point, world, inner);
|
|
9376
|
+
if (data.hitBox || isSmall) {
|
|
9377
|
+
if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
|
|
9378
|
+
return true;
|
|
9379
|
+
if (isSmall)
|
|
9380
|
+
return false;
|
|
9381
|
+
}
|
|
9382
|
+
if (layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
9383
|
+
this.__updateHitCanvas();
|
|
9384
|
+
if (!layout.boundsChanged)
|
|
9385
|
+
layout.hitCanvasChanged = false;
|
|
9386
|
+
}
|
|
9387
|
+
return this.__hit(inner);
|
|
9388
|
+
};
|
|
9389
|
+
leaf.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
|
|
9390
|
+
leaf.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
|
|
9391
|
+
leaf.__hitPixel = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitPixel(inner, this.__layout.renderBounds, this.__hitCanvas.hitScale); };
|
|
9392
|
+
leaf.__drawHitPath = function (canvas) { if (canvas)
|
|
9393
|
+
this.__drawRenderPath(canvas); };
|
|
9394
|
+
|
|
9395
|
+
const matrix = new Matrix();
|
|
9396
|
+
const ui$1 = exports.UI.prototype;
|
|
9397
|
+
ui$1.__updateHitCanvas = function () {
|
|
9398
|
+
if (this.__box)
|
|
9399
|
+
this.__box.__updateHitCanvas();
|
|
9400
|
+
const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
|
|
9401
|
+
const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
9402
|
+
const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
|
|
9403
|
+
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
9404
|
+
if (!this.__hitCanvas)
|
|
9405
|
+
this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
|
|
9406
|
+
const h = this.__hitCanvas;
|
|
9407
|
+
if (isHitPixel) {
|
|
9408
|
+
const { renderBounds } = this.__layout;
|
|
9409
|
+
const size = Platform.image.hitCanvasSize;
|
|
9410
|
+
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
9411
|
+
const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
|
|
9412
|
+
h.resize({ width, height, pixelRatio: 1 });
|
|
9413
|
+
h.clear();
|
|
9414
|
+
ImageManager.patternLocked = true;
|
|
9415
|
+
this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y) }, !isHitPixelFill, !isHitPixelStroke);
|
|
9416
|
+
ImageManager.patternLocked = false;
|
|
9417
|
+
h.resetTransform();
|
|
9418
|
+
data.__isHitPixel = true;
|
|
9419
|
+
}
|
|
9420
|
+
else {
|
|
9421
|
+
data.__isHitPixel && (data.__isHitPixel = false);
|
|
9422
|
+
}
|
|
9423
|
+
this.__drawHitPath(h);
|
|
9424
|
+
h.setStrokeOptions(data);
|
|
9425
|
+
};
|
|
9426
|
+
ui$1.__hit = function (inner) {
|
|
9427
|
+
if (this.__box && this.__box.__hit(inner))
|
|
9428
|
+
return true;
|
|
9429
|
+
const data = this.__;
|
|
9430
|
+
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
9431
|
+
return true;
|
|
9432
|
+
const { hitFill } = data;
|
|
9433
|
+
const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
|
|
9434
|
+
if (needHitFillPath && this.__hitFill(inner))
|
|
9435
|
+
return true;
|
|
9436
|
+
const { hitStroke, __strokeWidth } = data;
|
|
9437
|
+
const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
|
|
9438
|
+
if (!needHitFillPath && !needHitStrokePath)
|
|
9439
|
+
return false;
|
|
9440
|
+
const radiusWidth = inner.radiusX * 2;
|
|
9441
|
+
let hitWidth = radiusWidth;
|
|
9442
|
+
if (needHitStrokePath) {
|
|
9443
|
+
switch (data.strokeAlign) {
|
|
9444
|
+
case 'inside':
|
|
9445
|
+
hitWidth += __strokeWidth * 2;
|
|
9446
|
+
if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
9447
|
+
return true;
|
|
9448
|
+
hitWidth = radiusWidth;
|
|
9449
|
+
break;
|
|
9450
|
+
case 'center':
|
|
9451
|
+
hitWidth += __strokeWidth;
|
|
9452
|
+
break;
|
|
9453
|
+
case 'outside':
|
|
9454
|
+
hitWidth += __strokeWidth * 2;
|
|
9455
|
+
if (!needHitFillPath) {
|
|
9456
|
+
if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
9457
|
+
return true;
|
|
9458
|
+
hitWidth = radiusWidth;
|
|
9459
|
+
}
|
|
9460
|
+
break;
|
|
9461
|
+
}
|
|
9462
|
+
}
|
|
9463
|
+
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
9464
|
+
};
|
|
9465
|
+
|
|
9466
|
+
const ui = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
|
|
9467
|
+
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
9468
|
+
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
9469
|
+
ui.__updateHitCanvas.call(this);
|
|
9470
|
+
else if (this.__hitCanvas)
|
|
9471
|
+
this.__hitCanvas = null;
|
|
9472
|
+
};
|
|
9473
|
+
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
9474
|
+
return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
9475
|
+
};
|
|
9476
|
+
|
|
9477
|
+
exports.Text.prototype.__drawHitPath = function (canvas) {
|
|
9478
|
+
const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
|
|
9479
|
+
canvas.beginPath();
|
|
9480
|
+
if (__letterSpacing < 0)
|
|
9481
|
+
this.__drawPathByBox(canvas);
|
|
9482
|
+
else
|
|
9483
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
9484
|
+
};
|
|
9485
|
+
|
|
9486
|
+
function getSelector(ui) {
|
|
9487
|
+
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
9488
|
+
}
|
|
9489
|
+
exports.Group.prototype.pick = function (hitPoint, options) {
|
|
9490
|
+
options || (options = emptyData);
|
|
9491
|
+
this.updateLayout();
|
|
9492
|
+
return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
9493
|
+
};
|
|
9494
|
+
|
|
9495
|
+
const canvas = LeaferCanvasBase.prototype;
|
|
9496
|
+
canvas.hitFill = function (point, fillRule) {
|
|
9497
|
+
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
|
|
9498
|
+
};
|
|
9499
|
+
canvas.hitStroke = function (point, strokeWidth) {
|
|
9500
|
+
this.strokeWidth = strokeWidth;
|
|
9501
|
+
return this.context.isPointInStroke(point.x, point.y);
|
|
9502
|
+
};
|
|
9503
|
+
canvas.hitPixel = function (radiusPoint, offset, scale = 1) {
|
|
9504
|
+
let { x, y, radiusX, radiusY } = radiusPoint;
|
|
9505
|
+
if (offset)
|
|
9506
|
+
x -= offset.x, y -= offset.y;
|
|
9507
|
+
tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
|
|
9508
|
+
const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
|
|
9509
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
9510
|
+
if (data[i + 3] > 0)
|
|
9511
|
+
return true;
|
|
9512
|
+
}
|
|
9513
|
+
return data[3] > 0;
|
|
9514
|
+
};
|
|
9515
|
+
|
|
8865
9516
|
function strokeText(stroke, ui, canvas) {
|
|
8866
|
-
|
|
8867
|
-
const isStrokes = typeof stroke !== 'string';
|
|
8868
|
-
switch (strokeAlign) {
|
|
9517
|
+
switch (ui.__.strokeAlign) {
|
|
8869
9518
|
case 'center':
|
|
8870
|
-
|
|
8871
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
9519
|
+
drawCenter$1(stroke, 1, ui, canvas);
|
|
8872
9520
|
break;
|
|
8873
9521
|
case 'inside':
|
|
8874
|
-
|
|
9522
|
+
drawAlign(stroke, 'inside', ui, canvas);
|
|
8875
9523
|
break;
|
|
8876
9524
|
case 'outside':
|
|
8877
|
-
|
|
9525
|
+
ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
|
|
8878
9526
|
break;
|
|
8879
9527
|
}
|
|
8880
9528
|
}
|
|
8881
|
-
function
|
|
8882
|
-
const
|
|
9529
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
9530
|
+
const data = ui.__;
|
|
9531
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
|
|
9532
|
+
data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
9533
|
+
}
|
|
9534
|
+
function drawAlign(stroke, align, ui, canvas) {
|
|
8883
9535
|
const out = canvas.getSameCanvas(true, true);
|
|
8884
|
-
out.
|
|
8885
|
-
|
|
8886
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
|
|
9536
|
+
out.font = ui.__.__font;
|
|
9537
|
+
drawCenter$1(stroke, 2, ui, out);
|
|
8887
9538
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
8888
9539
|
fillText(ui, out);
|
|
8889
9540
|
out.blendMode = 'normal';
|
|
8890
|
-
if (ui.__worldFlipped)
|
|
9541
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
8891
9542
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
8892
9543
|
else
|
|
8893
9544
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
@@ -8929,90 +9580,60 @@ var LeaferUI = (function (exports) {
|
|
|
8929
9580
|
}
|
|
8930
9581
|
|
|
8931
9582
|
function stroke(stroke, ui, canvas) {
|
|
8932
|
-
const
|
|
8933
|
-
|
|
8934
|
-
if (!__strokeWidth)
|
|
9583
|
+
const data = ui.__;
|
|
9584
|
+
if (!data.__strokeWidth)
|
|
8935
9585
|
return;
|
|
8936
|
-
if (__font) {
|
|
9586
|
+
if (data.__font) {
|
|
8937
9587
|
strokeText(stroke, ui, canvas);
|
|
8938
9588
|
}
|
|
8939
9589
|
else {
|
|
8940
|
-
switch (strokeAlign) {
|
|
9590
|
+
switch (data.strokeAlign) {
|
|
8941
9591
|
case 'center':
|
|
8942
|
-
|
|
8943
|
-
canvas.stroke();
|
|
8944
|
-
if (options.__useArrow)
|
|
8945
|
-
strokeArrow(ui, canvas);
|
|
9592
|
+
drawCenter(stroke, 1, ui, canvas);
|
|
8946
9593
|
break;
|
|
8947
9594
|
case 'inside':
|
|
8948
|
-
canvas
|
|
8949
|
-
canvas.setStroke(stroke, __strokeWidth * 2, options);
|
|
8950
|
-
options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
|
|
8951
|
-
canvas.stroke();
|
|
8952
|
-
canvas.restore();
|
|
9595
|
+
drawInside(stroke, ui, canvas);
|
|
8953
9596
|
break;
|
|
8954
9597
|
case 'outside':
|
|
8955
|
-
|
|
8956
|
-
out.setStroke(stroke, __strokeWidth * 2, options);
|
|
8957
|
-
ui.__drawRenderPath(out);
|
|
8958
|
-
out.stroke();
|
|
8959
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
8960
|
-
out.clearWorld(ui.__layout.renderBounds);
|
|
8961
|
-
if (ui.__worldFlipped)
|
|
8962
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
8963
|
-
else
|
|
8964
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
8965
|
-
out.recycle(ui.__nowWorld);
|
|
9598
|
+
drawOutside(stroke, ui, canvas);
|
|
8966
9599
|
break;
|
|
8967
9600
|
}
|
|
8968
9601
|
}
|
|
8969
9602
|
}
|
|
8970
9603
|
function strokes(strokes, ui, canvas) {
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
9604
|
+
stroke(strokes, ui, canvas);
|
|
9605
|
+
}
|
|
9606
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
9607
|
+
const data = ui.__;
|
|
9608
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9609
|
+
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
9610
|
+
if (data.__useArrow)
|
|
9611
|
+
Paint.strokeArrow(stroke, ui, canvas);
|
|
9612
|
+
}
|
|
9613
|
+
function drawInside(stroke, ui, canvas) {
|
|
9614
|
+
const data = ui.__;
|
|
9615
|
+
canvas.save();
|
|
9616
|
+
data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
|
|
9617
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
9618
|
+
canvas.restore();
|
|
9619
|
+
}
|
|
9620
|
+
function drawOutside(stroke, ui, canvas) {
|
|
9621
|
+
const data = ui.__;
|
|
9622
|
+
if (data.__fillAfterStroke) {
|
|
9623
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
8977
9624
|
}
|
|
8978
9625
|
else {
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
drawStrokesStyle(strokes, false, ui, canvas);
|
|
8991
|
-
canvas.restore();
|
|
8992
|
-
break;
|
|
8993
|
-
case 'outside':
|
|
8994
|
-
const { renderBounds } = ui.__layout;
|
|
8995
|
-
const out = canvas.getSameCanvas(true, true);
|
|
8996
|
-
ui.__drawRenderPath(out);
|
|
8997
|
-
out.setStroke(undefined, __strokeWidth * 2, options);
|
|
8998
|
-
drawStrokesStyle(strokes, false, ui, out);
|
|
8999
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
9000
|
-
out.clearWorld(renderBounds);
|
|
9001
|
-
if (ui.__worldFlipped)
|
|
9002
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9003
|
-
else
|
|
9004
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
9005
|
-
out.recycle(ui.__nowWorld);
|
|
9006
|
-
break;
|
|
9007
|
-
}
|
|
9008
|
-
}
|
|
9009
|
-
}
|
|
9010
|
-
function strokeArrow(ui, canvas) {
|
|
9011
|
-
if (ui.__.dashPattern) {
|
|
9012
|
-
canvas.beginPath();
|
|
9013
|
-
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
9014
|
-
canvas.dashPattern = null;
|
|
9015
|
-
canvas.stroke();
|
|
9626
|
+
const { renderBounds } = ui.__layout;
|
|
9627
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9628
|
+
ui.__drawRenderPath(out);
|
|
9629
|
+
drawCenter(stroke, 2, ui, out);
|
|
9630
|
+
data.windingRule ? out.clip(data.windingRule) : out.clip();
|
|
9631
|
+
out.clearWorld(renderBounds);
|
|
9632
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
9633
|
+
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9634
|
+
else
|
|
9635
|
+
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
9636
|
+
out.recycle(ui.__nowWorld);
|
|
9016
9637
|
}
|
|
9017
9638
|
}
|
|
9018
9639
|
|
|
@@ -9059,9 +9680,10 @@ var LeaferUI = (function (exports) {
|
|
|
9059
9680
|
}
|
|
9060
9681
|
|
|
9061
9682
|
let recycleMap;
|
|
9683
|
+
const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
|
|
9062
9684
|
function compute(attrName, ui) {
|
|
9063
9685
|
const data = ui.__, leafPaints = [];
|
|
9064
|
-
let paints = data.__input[attrName],
|
|
9686
|
+
let paints = data.__input[attrName], isAlphaPixel, isTransparent;
|
|
9065
9687
|
if (!(paints instanceof Array))
|
|
9066
9688
|
paints = [paints];
|
|
9067
9689
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
@@ -9071,29 +9693,55 @@ var LeaferUI = (function (exports) {
|
|
|
9071
9693
|
leafPaints.push(item);
|
|
9072
9694
|
}
|
|
9073
9695
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
9074
|
-
if (leafPaints.length
|
|
9075
|
-
|
|
9076
|
-
|
|
9696
|
+
if (leafPaints.length) {
|
|
9697
|
+
if (leafPaints.every(item => item.isTransparent)) {
|
|
9698
|
+
if (leafPaints.some(item => item.image))
|
|
9699
|
+
isAlphaPixel = true;
|
|
9700
|
+
isTransparent = true;
|
|
9701
|
+
}
|
|
9702
|
+
}
|
|
9703
|
+
if (attrName === 'fill') {
|
|
9704
|
+
stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
|
|
9705
|
+
stintSet(data, '__isTransparentFill', isTransparent);
|
|
9706
|
+
}
|
|
9707
|
+
else {
|
|
9708
|
+
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
9709
|
+
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
9710
|
+
}
|
|
9077
9711
|
}
|
|
9078
9712
|
function getLeafPaint(attrName, paint, ui) {
|
|
9079
9713
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|
|
9080
9714
|
return undefined;
|
|
9715
|
+
let data;
|
|
9081
9716
|
const { boxBounds } = ui.__layout;
|
|
9082
9717
|
switch (paint.type) {
|
|
9083
|
-
case 'solid':
|
|
9084
|
-
let { type, blendMode, color, opacity } = paint;
|
|
9085
|
-
return { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
9086
9718
|
case 'image':
|
|
9087
|
-
|
|
9719
|
+
data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
9720
|
+
break;
|
|
9088
9721
|
case 'linear':
|
|
9089
|
-
|
|
9722
|
+
data = PaintGradient.linearGradient(paint, boxBounds);
|
|
9723
|
+
break;
|
|
9090
9724
|
case 'radial':
|
|
9091
|
-
|
|
9725
|
+
data = PaintGradient.radialGradient(paint, boxBounds);
|
|
9726
|
+
break;
|
|
9092
9727
|
case 'angular':
|
|
9093
|
-
|
|
9728
|
+
data = PaintGradient.conicGradient(paint, boxBounds);
|
|
9729
|
+
break;
|
|
9730
|
+
case 'solid':
|
|
9731
|
+
const { type, blendMode, color, opacity } = paint;
|
|
9732
|
+
data = { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
9733
|
+
break;
|
|
9094
9734
|
default:
|
|
9095
|
-
|
|
9735
|
+
if (paint.r !== undefined)
|
|
9736
|
+
data = { type: 'solid', style: ColorConvert.string(paint) };
|
|
9737
|
+
}
|
|
9738
|
+
if (data) {
|
|
9739
|
+
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
9740
|
+
data.isTransparent = true;
|
|
9741
|
+
if (paint.blendMode)
|
|
9742
|
+
data.blendMode = paint.blendMode;
|
|
9096
9743
|
}
|
|
9744
|
+
return data;
|
|
9097
9745
|
}
|
|
9098
9746
|
|
|
9099
9747
|
const PaintModule = {
|
|
@@ -9159,12 +9807,10 @@ var LeaferUI = (function (exports) {
|
|
|
9159
9807
|
|
|
9160
9808
|
const { get: get$2, translate } = MatrixHelper;
|
|
9161
9809
|
const tempBox = new Bounds();
|
|
9162
|
-
const tempPoint = {};
|
|
9163
9810
|
const tempScaleData = {};
|
|
9811
|
+
const tempImage = {};
|
|
9164
9812
|
function createData(leafPaint, image, paint, box) {
|
|
9165
|
-
const {
|
|
9166
|
-
if (blendMode)
|
|
9167
|
-
leafPaint.blendMode = blendMode;
|
|
9813
|
+
const { changeful, sync } = paint;
|
|
9168
9814
|
if (changeful)
|
|
9169
9815
|
leafPaint.changeful = changeful;
|
|
9170
9816
|
if (sync)
|
|
@@ -9172,38 +9818,38 @@ var LeaferUI = (function (exports) {
|
|
|
9172
9818
|
leafPaint.data = getPatternData(paint, box, image);
|
|
9173
9819
|
}
|
|
9174
9820
|
function getPatternData(paint, box, image) {
|
|
9175
|
-
let { width, height } = image;
|
|
9176
9821
|
if (paint.padding)
|
|
9177
9822
|
box = tempBox.set(box).shrink(paint.padding);
|
|
9178
9823
|
if (paint.mode === 'strench')
|
|
9179
9824
|
paint.mode = 'stretch';
|
|
9825
|
+
let { width, height } = image;
|
|
9180
9826
|
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
9181
9827
|
const sameBox = box.width === width && box.height === height;
|
|
9182
9828
|
const data = { mode };
|
|
9183
9829
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
9184
|
-
|
|
9185
|
-
let
|
|
9830
|
+
BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
|
|
9831
|
+
let scaleX, scaleY;
|
|
9186
9832
|
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
9187
9833
|
if (!sameBox || rotation) {
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9834
|
+
scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
|
|
9835
|
+
BoundsHelper.put(box, image, align, scaleX, false, tempImage);
|
|
9836
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
9191
9837
|
}
|
|
9192
9838
|
}
|
|
9193
|
-
else
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9839
|
+
else {
|
|
9840
|
+
if (scale || size) {
|
|
9841
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
9842
|
+
scaleX = tempScaleData.scaleX;
|
|
9843
|
+
scaleY = tempScaleData.scaleY;
|
|
9844
|
+
}
|
|
9845
|
+
if (align) {
|
|
9846
|
+
if (scaleX)
|
|
9847
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
9848
|
+
AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
|
|
9849
|
+
}
|
|
9204
9850
|
}
|
|
9205
9851
|
if (offset)
|
|
9206
|
-
|
|
9852
|
+
PointHelper.move(tempImage, offset);
|
|
9207
9853
|
switch (mode) {
|
|
9208
9854
|
case 'stretch':
|
|
9209
9855
|
if (!sameBox)
|
|
@@ -9211,12 +9857,12 @@ var LeaferUI = (function (exports) {
|
|
|
9211
9857
|
break;
|
|
9212
9858
|
case 'normal':
|
|
9213
9859
|
case 'clip':
|
|
9214
|
-
if (x || y || scaleX || rotation)
|
|
9215
|
-
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
9860
|
+
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
9861
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9216
9862
|
break;
|
|
9217
9863
|
case 'repeat':
|
|
9218
9864
|
if (!sameBox || scaleX || rotation)
|
|
9219
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
|
|
9865
|
+
repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
|
|
9220
9866
|
if (!repeat)
|
|
9221
9867
|
data.repeat = 'repeat';
|
|
9222
9868
|
break;
|
|
@@ -9224,7 +9870,7 @@ var LeaferUI = (function (exports) {
|
|
|
9224
9870
|
case 'cover':
|
|
9225
9871
|
default:
|
|
9226
9872
|
if (scaleX)
|
|
9227
|
-
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
9873
|
+
fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9228
9874
|
}
|
|
9229
9875
|
if (!data.transform) {
|
|
9230
9876
|
if (box.x || box.y) {
|
|
@@ -9257,6 +9903,8 @@ var LeaferUI = (function (exports) {
|
|
|
9257
9903
|
}
|
|
9258
9904
|
else {
|
|
9259
9905
|
leafPaint = { type: paint.type, image };
|
|
9906
|
+
if (image.hasAlphaPixel)
|
|
9907
|
+
leafPaint.isTransparent = true;
|
|
9260
9908
|
cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
|
|
9261
9909
|
}
|
|
9262
9910
|
if (firstUse || image.loading)
|
|
@@ -9281,7 +9929,7 @@ var LeaferUI = (function (exports) {
|
|
|
9281
9929
|
ignoreRender(ui, false);
|
|
9282
9930
|
if (!ui.destroyed) {
|
|
9283
9931
|
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9284
|
-
if (image.
|
|
9932
|
+
if (image.hasAlphaPixel)
|
|
9285
9933
|
ui.__layout.hitCanvasChanged = true;
|
|
9286
9934
|
ui.forceUpdate('surface');
|
|
9287
9935
|
}
|
|
@@ -9293,13 +9941,17 @@ var LeaferUI = (function (exports) {
|
|
|
9293
9941
|
onLoadError(ui, event, error);
|
|
9294
9942
|
leafPaint.loadId = null;
|
|
9295
9943
|
});
|
|
9296
|
-
if (ui.placeholderColor)
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9944
|
+
if (ui.placeholderColor) {
|
|
9945
|
+
if (!ui.placeholderDelay)
|
|
9946
|
+
image.isPlacehold = true;
|
|
9947
|
+
else
|
|
9948
|
+
setTimeout(() => {
|
|
9949
|
+
if (!image.ready) {
|
|
9950
|
+
image.isPlacehold = true;
|
|
9951
|
+
ui.forceUpdate('surface');
|
|
9952
|
+
}
|
|
9953
|
+
}, ui.placeholderDelay);
|
|
9954
|
+
}
|
|
9303
9955
|
}
|
|
9304
9956
|
return leafPaint;
|
|
9305
9957
|
}
|
|
@@ -9505,32 +10157,33 @@ var LeaferUI = (function (exports) {
|
|
|
9505
10157
|
repeatMode
|
|
9506
10158
|
};
|
|
9507
10159
|
|
|
9508
|
-
const { toPoint: toPoint$2 } = AroundHelper;
|
|
10160
|
+
const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
|
|
9509
10161
|
const realFrom$2 = {};
|
|
9510
10162
|
const realTo$2 = {};
|
|
9511
10163
|
function linearGradient(paint, box) {
|
|
9512
|
-
let { from, to, type,
|
|
10164
|
+
let { from, to, type, opacity } = paint;
|
|
9513
10165
|
toPoint$2(from || 'top', box, realFrom$2);
|
|
9514
10166
|
toPoint$2(to || 'bottom', box, realTo$2);
|
|
9515
10167
|
const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
|
|
9516
|
-
applyStops(style, paint.stops, opacity);
|
|
9517
10168
|
const data = { type, style };
|
|
9518
|
-
|
|
9519
|
-
data.blendMode = blendMode;
|
|
10169
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9520
10170
|
return data;
|
|
9521
10171
|
}
|
|
9522
|
-
function applyStops(gradient, stops, opacity) {
|
|
10172
|
+
function applyStops(data, gradient, stops, opacity) {
|
|
9523
10173
|
if (stops) {
|
|
9524
|
-
let stop;
|
|
10174
|
+
let stop, color, offset, isTransparent;
|
|
9525
10175
|
for (let i = 0, len = stops.length; i < len; i++) {
|
|
9526
10176
|
stop = stops[i];
|
|
9527
|
-
if (typeof stop === 'string')
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
10177
|
+
if (typeof stop === 'string')
|
|
10178
|
+
offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
|
|
10179
|
+
else
|
|
10180
|
+
offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
|
|
10181
|
+
gradient.addColorStop(offset, color);
|
|
10182
|
+
if (!isTransparent && hasTransparent(color))
|
|
10183
|
+
isTransparent = true;
|
|
9533
10184
|
}
|
|
10185
|
+
if (isTransparent)
|
|
10186
|
+
data.isTransparent = true;
|
|
9534
10187
|
}
|
|
9535
10188
|
}
|
|
9536
10189
|
|
|
@@ -9540,17 +10193,15 @@ var LeaferUI = (function (exports) {
|
|
|
9540
10193
|
const realFrom$1 = {};
|
|
9541
10194
|
const realTo$1 = {};
|
|
9542
10195
|
function radialGradient(paint, box) {
|
|
9543
|
-
let { from, to, type, opacity,
|
|
10196
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
9544
10197
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
9545
10198
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
9546
10199
|
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
9547
|
-
applyStops(style, paint.stops, opacity);
|
|
9548
10200
|
const data = { type, style };
|
|
10201
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9549
10202
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
9550
10203
|
if (transform)
|
|
9551
10204
|
data.transform = transform;
|
|
9552
|
-
if (blendMode)
|
|
9553
|
-
data.blendMode = blendMode;
|
|
9554
10205
|
return data;
|
|
9555
10206
|
}
|
|
9556
10207
|
function getTransform(box, from, to, stretch, rotate90) {
|
|
@@ -9576,17 +10227,15 @@ var LeaferUI = (function (exports) {
|
|
|
9576
10227
|
const realFrom = {};
|
|
9577
10228
|
const realTo = {};
|
|
9578
10229
|
function conicGradient(paint, box) {
|
|
9579
|
-
let { from, to, type, opacity,
|
|
10230
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
9580
10231
|
toPoint(from || 'center', box, realFrom);
|
|
9581
10232
|
toPoint(to || 'bottom', box, realTo);
|
|
9582
10233
|
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
9583
|
-
applyStops(style, paint.stops, opacity);
|
|
9584
10234
|
const data = { type, style };
|
|
10235
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9585
10236
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
9586
10237
|
if (transform)
|
|
9587
10238
|
data.transform = transform;
|
|
9588
|
-
if (blendMode)
|
|
9589
|
-
data.blendMode = blendMode;
|
|
9590
10239
|
return data;
|
|
9591
10240
|
}
|
|
9592
10241
|
|
|
@@ -9919,6 +10568,8 @@ var LeaferUI = (function (exports) {
|
|
|
9919
10568
|
lastCharType = null;
|
|
9920
10569
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
9921
10570
|
word = { data: [] }, row = { words: [] };
|
|
10571
|
+
if (__letterSpacing)
|
|
10572
|
+
content = [...content];
|
|
9922
10573
|
for (let i = 0, len = content.length; i < len; i++) {
|
|
9923
10574
|
char = content[i];
|
|
9924
10575
|
if (char === '\n') {
|
|
@@ -10337,6 +10988,7 @@ var LeaferUI = (function (exports) {
|
|
|
10337
10988
|
exports.AutoBounds = AutoBounds;
|
|
10338
10989
|
exports.BezierHelper = BezierHelper;
|
|
10339
10990
|
exports.Bounds = Bounds;
|
|
10991
|
+
exports.BoundsEvent = BoundsEvent;
|
|
10340
10992
|
exports.BoundsHelper = BoundsHelper;
|
|
10341
10993
|
exports.BoxData = BoxData;
|
|
10342
10994
|
exports.BranchHelper = BranchHelper;
|
|
@@ -10483,7 +11135,7 @@ var LeaferUI = (function (exports) {
|
|
|
10483
11135
|
exports.surfaceType = surfaceType;
|
|
10484
11136
|
exports.tempBounds = tempBounds$1;
|
|
10485
11137
|
exports.tempMatrix = tempMatrix;
|
|
10486
|
-
exports.tempPoint = tempPoint$
|
|
11138
|
+
exports.tempPoint = tempPoint$2;
|
|
10487
11139
|
exports.useCanvas = useCanvas;
|
|
10488
11140
|
exports.useModule = useModule;
|
|
10489
11141
|
exports.version = version;
|