leafer-ui 1.0.0 → 1.0.2
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/README.md +11 -3
- package/dist/web.cjs +3193 -0
- package/dist/web.esm.js +91 -72
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +321 -180
- package/dist/web.min.cjs +1 -0
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +319 -181
- package/dist/web.module.min.js +1 -1
- package/package.json +18 -12
package/dist/web.js
CHANGED
|
@@ -51,6 +51,8 @@ var LeaferUI = (function (exports) {
|
|
|
51
51
|
const { round, pow: pow$1, PI: PI$4 } = Math;
|
|
52
52
|
const MathHelper = {
|
|
53
53
|
within(value, min, max) {
|
|
54
|
+
if (typeof min === 'object')
|
|
55
|
+
max = min.max, min = min.min;
|
|
54
56
|
if (min !== undefined && value < min)
|
|
55
57
|
value = min;
|
|
56
58
|
if (max !== undefined && value > max)
|
|
@@ -112,6 +114,19 @@ var LeaferUI = (function (exports) {
|
|
|
112
114
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
113
115
|
num = round(num * a) / a;
|
|
114
116
|
return num === -0 ? 0 : num;
|
|
117
|
+
},
|
|
118
|
+
getScaleData(scale, size, originSize, scaleData) {
|
|
119
|
+
if (!scaleData)
|
|
120
|
+
scaleData = {};
|
|
121
|
+
if (size) {
|
|
122
|
+
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
123
|
+
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
124
|
+
}
|
|
125
|
+
else if (scale) {
|
|
126
|
+
scaleData.scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
127
|
+
scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
128
|
+
}
|
|
129
|
+
return scaleData;
|
|
115
130
|
}
|
|
116
131
|
};
|
|
117
132
|
const OneRadian = PI$4 / 180;
|
|
@@ -153,10 +168,10 @@ var LeaferUI = (function (exports) {
|
|
|
153
168
|
t.e += x;
|
|
154
169
|
t.f += y;
|
|
155
170
|
},
|
|
156
|
-
translateInner(t, x, y,
|
|
171
|
+
translateInner(t, x, y, hasOrigin) {
|
|
157
172
|
t.e += t.a * x + t.c * y;
|
|
158
173
|
t.f += t.b * x + t.d * y;
|
|
159
|
-
if (
|
|
174
|
+
if (hasOrigin)
|
|
160
175
|
t.e -= x, t.f -= y;
|
|
161
176
|
},
|
|
162
177
|
scale(t, scaleX, scaleY = scaleX) {
|
|
@@ -315,7 +330,7 @@ var LeaferUI = (function (exports) {
|
|
|
315
330
|
to.y -= (f * a - e * b) * s;
|
|
316
331
|
}
|
|
317
332
|
},
|
|
318
|
-
setLayout(t, layout, origin, bcChanged) {
|
|
333
|
+
setLayout(t, layout, origin, around, bcChanged) {
|
|
319
334
|
const { x, y, scaleX, scaleY } = layout;
|
|
320
335
|
if (bcChanged === undefined)
|
|
321
336
|
bcChanged = layout.rotation || layout.skewX || layout.skewY;
|
|
@@ -347,10 +362,10 @@ var LeaferUI = (function (exports) {
|
|
|
347
362
|
}
|
|
348
363
|
t.e = x;
|
|
349
364
|
t.f = y;
|
|
350
|
-
if (origin)
|
|
351
|
-
M$6.translateInner(t, -origin.x, -origin.y,
|
|
365
|
+
if (origin = origin || around)
|
|
366
|
+
M$6.translateInner(t, -origin.x, -origin.y, !around);
|
|
352
367
|
},
|
|
353
|
-
getLayout(t, origin, firstSkewY) {
|
|
368
|
+
getLayout(t, origin, around, firstSkewY) {
|
|
354
369
|
const { a, b, c, d, e, f } = t;
|
|
355
370
|
let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
|
|
356
371
|
if (b || c) {
|
|
@@ -379,9 +394,11 @@ var LeaferUI = (function (exports) {
|
|
|
379
394
|
scaleY = d;
|
|
380
395
|
rotation = skewX = skewY = 0;
|
|
381
396
|
}
|
|
382
|
-
if (origin) {
|
|
397
|
+
if (origin = around || origin) {
|
|
383
398
|
x += origin.x * a + origin.y * c;
|
|
384
399
|
y += origin.x * b + origin.y * d;
|
|
400
|
+
if (!around)
|
|
401
|
+
x -= origin.x, y -= origin.y;
|
|
385
402
|
}
|
|
386
403
|
return { x, y, scaleX, scaleY, rotation, skewX, skewY };
|
|
387
404
|
},
|
|
@@ -408,7 +425,7 @@ var LeaferUI = (function (exports) {
|
|
|
408
425
|
};
|
|
409
426
|
const M$6 = MatrixHelper;
|
|
410
427
|
|
|
411
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
428
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
412
429
|
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
413
430
|
const PointHelper = {
|
|
414
431
|
defaultPoint: getPointData(),
|
|
@@ -464,7 +481,7 @@ var LeaferUI = (function (exports) {
|
|
|
464
481
|
tempToOuterOf(t, matrix) {
|
|
465
482
|
const { tempPoint: temp } = P$5;
|
|
466
483
|
copy$b(temp, t);
|
|
467
|
-
toOuterPoint$
|
|
484
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
468
485
|
return temp;
|
|
469
486
|
},
|
|
470
487
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -483,7 +500,7 @@ var LeaferUI = (function (exports) {
|
|
|
483
500
|
toInnerPoint$2(matrix, t, to);
|
|
484
501
|
},
|
|
485
502
|
toOuterOf(t, matrix, to) {
|
|
486
|
-
toOuterPoint$
|
|
503
|
+
toOuterPoint$3(matrix, t, to);
|
|
487
504
|
},
|
|
488
505
|
getCenter(t, to) {
|
|
489
506
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -709,12 +726,12 @@ var LeaferUI = (function (exports) {
|
|
|
709
726
|
toInnerPoint(outer, to, distance) {
|
|
710
727
|
MatrixHelper.toInnerPoint(this, outer, to, distance);
|
|
711
728
|
}
|
|
712
|
-
setLayout(data, origin) {
|
|
713
|
-
MatrixHelper.setLayout(this, data, origin);
|
|
729
|
+
setLayout(data, origin, around) {
|
|
730
|
+
MatrixHelper.setLayout(this, data, origin, around);
|
|
714
731
|
return this;
|
|
715
732
|
}
|
|
716
|
-
getLayout(origin, firstSkewY) {
|
|
717
|
-
return MatrixHelper.getLayout(this, origin, firstSkewY);
|
|
733
|
+
getLayout(origin, around, firstSkewY) {
|
|
734
|
+
return MatrixHelper.getLayout(this, origin, around, firstSkewY);
|
|
718
735
|
}
|
|
719
736
|
withScale(scaleX, scaleY) {
|
|
720
737
|
return MatrixHelper.withScale(this, scaleX, scaleY);
|
|
@@ -763,7 +780,7 @@ var LeaferUI = (function (exports) {
|
|
|
763
780
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
764
781
|
|
|
765
782
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
766
|
-
const { toOuterPoint: toOuterPoint$
|
|
783
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
767
784
|
const { float, fourNumber } = MathHelper;
|
|
768
785
|
const { floor, ceil: ceil$2 } = Math;
|
|
769
786
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
@@ -783,17 +800,24 @@ var LeaferUI = (function (exports) {
|
|
|
783
800
|
t.width = bounds.width;
|
|
784
801
|
t.height = bounds.height;
|
|
785
802
|
},
|
|
786
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
803
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
804
|
+
const { x, y, width, height } = bounds;
|
|
787
805
|
if (spread instanceof Array) {
|
|
788
806
|
const four = fourNumber(spread);
|
|
789
807
|
isShrink
|
|
790
|
-
? B.set(t,
|
|
791
|
-
: B.set(t,
|
|
808
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
809
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
792
810
|
}
|
|
793
811
|
else {
|
|
794
812
|
if (isShrink)
|
|
795
813
|
spread = -spread;
|
|
796
|
-
B.set(t,
|
|
814
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
815
|
+
}
|
|
816
|
+
if (side) {
|
|
817
|
+
if (side === 'width')
|
|
818
|
+
t.y = y, t.height = height;
|
|
819
|
+
else
|
|
820
|
+
t.x = x, t.width = width;
|
|
797
821
|
}
|
|
798
822
|
},
|
|
799
823
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -870,16 +894,16 @@ var LeaferUI = (function (exports) {
|
|
|
870
894
|
else {
|
|
871
895
|
point.x = t.x;
|
|
872
896
|
point.y = t.y;
|
|
873
|
-
toOuterPoint$
|
|
897
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
874
898
|
setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
875
899
|
point.x = t.x + t.width;
|
|
876
|
-
toOuterPoint$
|
|
900
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
877
901
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
878
902
|
point.y = t.y + t.height;
|
|
879
|
-
toOuterPoint$
|
|
903
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
880
904
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
881
905
|
point.x = t.x;
|
|
882
|
-
toOuterPoint$
|
|
906
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
883
907
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
884
908
|
toBounds$4(tempPointBounds$1, to);
|
|
885
909
|
}
|
|
@@ -893,16 +917,16 @@ var LeaferUI = (function (exports) {
|
|
|
893
917
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
894
918
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
895
919
|
},
|
|
896
|
-
getSpread(t, spread) {
|
|
920
|
+
getSpread(t, spread, side) {
|
|
897
921
|
const n = {};
|
|
898
|
-
B.copyAndSpread(n, t, spread);
|
|
922
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
899
923
|
return n;
|
|
900
924
|
},
|
|
901
|
-
spread(t, spread) {
|
|
902
|
-
B.copyAndSpread(t, t, spread);
|
|
925
|
+
spread(t, spread, side) {
|
|
926
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
903
927
|
},
|
|
904
|
-
shrink(t, shrink) {
|
|
905
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
928
|
+
shrink(t, shrink, side) {
|
|
929
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
906
930
|
},
|
|
907
931
|
ceil(t) {
|
|
908
932
|
const { x, y } = t;
|
|
@@ -1085,12 +1109,12 @@ var LeaferUI = (function (exports) {
|
|
|
1085
1109
|
getFitMatrix(put, baseScale) {
|
|
1086
1110
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1087
1111
|
}
|
|
1088
|
-
spread(fourNumber) {
|
|
1089
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1112
|
+
spread(fourNumber, side) {
|
|
1113
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1090
1114
|
return this;
|
|
1091
1115
|
}
|
|
1092
|
-
shrink(fourNumber) {
|
|
1093
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1116
|
+
shrink(fourNumber, side) {
|
|
1117
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1094
1118
|
return this;
|
|
1095
1119
|
}
|
|
1096
1120
|
ceil() {
|
|
@@ -2002,7 +2026,7 @@ var LeaferUI = (function (exports) {
|
|
|
2002
2026
|
DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
|
|
2003
2027
|
this.size.pixelRatio || (this.size.pixelRatio = 1);
|
|
2004
2028
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2005
|
-
if (!this.unreal) {
|
|
2029
|
+
if (this.context && !this.unreal) {
|
|
2006
2030
|
this.updateViewSize();
|
|
2007
2031
|
this.smooth = this.config.smooth;
|
|
2008
2032
|
}
|
|
@@ -2175,7 +2199,7 @@ var LeaferUI = (function (exports) {
|
|
|
2175
2199
|
this.manager ? this.manager.recycle(this) : this.destroy();
|
|
2176
2200
|
}
|
|
2177
2201
|
}
|
|
2178
|
-
updateRender() { }
|
|
2202
|
+
updateRender(_bounds) { }
|
|
2179
2203
|
unrealCanvas() { }
|
|
2180
2204
|
destroy() {
|
|
2181
2205
|
this.manager = this.view = this.parentView = null;
|
|
@@ -2907,60 +2931,75 @@ var LeaferUI = (function (exports) {
|
|
|
2907
2931
|
}
|
|
2908
2932
|
beginPath() {
|
|
2909
2933
|
beginPath(this.__path);
|
|
2934
|
+
this.paint();
|
|
2910
2935
|
return this;
|
|
2911
2936
|
}
|
|
2912
2937
|
moveTo(x, y) {
|
|
2913
2938
|
moveTo$4(this.__path, x, y);
|
|
2939
|
+
this.paint();
|
|
2914
2940
|
return this;
|
|
2915
2941
|
}
|
|
2916
2942
|
lineTo(x, y) {
|
|
2917
2943
|
lineTo$3(this.__path, x, y);
|
|
2944
|
+
this.paint();
|
|
2918
2945
|
return this;
|
|
2919
2946
|
}
|
|
2920
2947
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2921
2948
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2949
|
+
this.paint();
|
|
2922
2950
|
return this;
|
|
2923
2951
|
}
|
|
2924
2952
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2925
2953
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2954
|
+
this.paint();
|
|
2926
2955
|
return this;
|
|
2927
2956
|
}
|
|
2928
2957
|
closePath() {
|
|
2929
2958
|
closePath$3(this.__path);
|
|
2959
|
+
this.paint();
|
|
2930
2960
|
return this;
|
|
2931
2961
|
}
|
|
2932
2962
|
rect(x, y, width, height) {
|
|
2933
2963
|
rect$2(this.__path, x, y, width, height);
|
|
2964
|
+
this.paint();
|
|
2934
2965
|
return this;
|
|
2935
2966
|
}
|
|
2936
2967
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2937
2968
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2969
|
+
this.paint();
|
|
2938
2970
|
return this;
|
|
2939
2971
|
}
|
|
2940
2972
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2941
2973
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2974
|
+
this.paint();
|
|
2942
2975
|
return this;
|
|
2943
2976
|
}
|
|
2944
2977
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2945
2978
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2979
|
+
this.paint();
|
|
2946
2980
|
return this;
|
|
2947
2981
|
}
|
|
2948
2982
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2949
2983
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2984
|
+
this.paint();
|
|
2950
2985
|
return this;
|
|
2951
2986
|
}
|
|
2952
2987
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2953
2988
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2989
|
+
this.paint();
|
|
2954
2990
|
return this;
|
|
2955
2991
|
}
|
|
2956
2992
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2957
2993
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2994
|
+
this.paint();
|
|
2958
2995
|
return this;
|
|
2959
2996
|
}
|
|
2960
2997
|
drawPoints(points, curve, close) {
|
|
2961
2998
|
drawPoints$2(this.__path, points, curve, close);
|
|
2999
|
+
this.paint();
|
|
2962
3000
|
return this;
|
|
2963
3001
|
}
|
|
3002
|
+
paint() { }
|
|
2964
3003
|
}
|
|
2965
3004
|
|
|
2966
3005
|
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
@@ -3982,7 +4021,7 @@ var LeaferUI = (function (exports) {
|
|
|
3982
4021
|
};
|
|
3983
4022
|
}
|
|
3984
4023
|
|
|
3985
|
-
const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4024
|
+
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3986
4025
|
const matrix$1 = {};
|
|
3987
4026
|
const LeafHelper = {
|
|
3988
4027
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4047,10 +4086,9 @@ var LeaferUI = (function (exports) {
|
|
|
4047
4086
|
}
|
|
4048
4087
|
return true;
|
|
4049
4088
|
},
|
|
4050
|
-
moveWorld(t, x, y = 0) {
|
|
4089
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4051
4090
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4052
|
-
|
|
4053
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4091
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4054
4092
|
L.moveLocal(t, local.x, local.y);
|
|
4055
4093
|
},
|
|
4056
4094
|
moveLocal(t, x, y = 0) {
|
|
@@ -4069,8 +4107,13 @@ var LeaferUI = (function (exports) {
|
|
|
4069
4107
|
zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
|
|
4070
4108
|
copy$7(matrix$1, t.__localMatrix);
|
|
4071
4109
|
scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
|
|
4072
|
-
|
|
4073
|
-
|
|
4110
|
+
if (t.origin || t.around) {
|
|
4111
|
+
L.setTransform(t, matrix$1, resize);
|
|
4112
|
+
}
|
|
4113
|
+
else {
|
|
4114
|
+
moveByMatrix(t, matrix$1);
|
|
4115
|
+
t.scaleResize(scaleX, scaleY, resize !== true);
|
|
4116
|
+
}
|
|
4074
4117
|
},
|
|
4075
4118
|
rotateOfWorld(t, origin, angle) {
|
|
4076
4119
|
L.rotateOfLocal(t, getTempLocal(t, origin), angle);
|
|
@@ -4078,8 +4121,13 @@ var LeaferUI = (function (exports) {
|
|
|
4078
4121
|
rotateOfLocal(t, origin, angle) {
|
|
4079
4122
|
copy$7(matrix$1, t.__localMatrix);
|
|
4080
4123
|
rotateOfOuter$2(matrix$1, origin, angle);
|
|
4081
|
-
|
|
4082
|
-
|
|
4124
|
+
if (t.origin || t.around) {
|
|
4125
|
+
L.setTransform(t, matrix$1);
|
|
4126
|
+
}
|
|
4127
|
+
else {
|
|
4128
|
+
moveByMatrix(t, matrix$1);
|
|
4129
|
+
t.rotation = MathHelper.formatRotation(t.rotation + angle);
|
|
4130
|
+
}
|
|
4083
4131
|
},
|
|
4084
4132
|
skewOfWorld(t, origin, skewX, skewY, resize) {
|
|
4085
4133
|
L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
|
|
@@ -4102,7 +4150,7 @@ var LeaferUI = (function (exports) {
|
|
|
4102
4150
|
L.setTransform(t, matrix$1, resize);
|
|
4103
4151
|
},
|
|
4104
4152
|
setTransform(t, transform, resize) {
|
|
4105
|
-
const layout = getLayout(transform);
|
|
4153
|
+
const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around));
|
|
4106
4154
|
if (resize) {
|
|
4107
4155
|
const scaleX = layout.scaleX / t.scaleX;
|
|
4108
4156
|
const scaleY = layout.scaleY / t.scaleY;
|
|
@@ -4115,13 +4163,19 @@ var LeaferUI = (function (exports) {
|
|
|
4115
4163
|
t.set(layout);
|
|
4116
4164
|
}
|
|
4117
4165
|
},
|
|
4166
|
+
getFlipTransform(t, axis) {
|
|
4167
|
+
const m = getMatrixData();
|
|
4168
|
+
const sign = axis === 'x' ? 1 : -1;
|
|
4169
|
+
scaleOfOuter$2(m, L.getLocalOrigin(t, 'center'), -1 * sign, 1 * sign);
|
|
4170
|
+
return m;
|
|
4171
|
+
},
|
|
4118
4172
|
getLocalOrigin(t, origin) {
|
|
4119
4173
|
return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
|
|
4120
4174
|
},
|
|
4121
4175
|
getInnerOrigin(t, origin) {
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
return
|
|
4176
|
+
const innerOrigin = {};
|
|
4177
|
+
AroundHelper.toPoint(origin, t.boxBounds, innerOrigin);
|
|
4178
|
+
return innerOrigin;
|
|
4125
4179
|
},
|
|
4126
4180
|
getRelativeWorld(t, relative, temp) {
|
|
4127
4181
|
copy$7(matrix$1, t.worldTransform);
|
|
@@ -4548,7 +4602,10 @@ var LeaferUI = (function (exports) {
|
|
|
4548
4602
|
on(type, listener, options) {
|
|
4549
4603
|
let capture, once;
|
|
4550
4604
|
if (options) {
|
|
4551
|
-
if (
|
|
4605
|
+
if (options === 'once') {
|
|
4606
|
+
once = true;
|
|
4607
|
+
}
|
|
4608
|
+
else if (typeof options === 'boolean') {
|
|
4552
4609
|
capture = options;
|
|
4553
4610
|
}
|
|
4554
4611
|
else {
|
|
@@ -4579,7 +4636,7 @@ var LeaferUI = (function (exports) {
|
|
|
4579
4636
|
if (listener) {
|
|
4580
4637
|
let capture;
|
|
4581
4638
|
if (options)
|
|
4582
|
-
capture = typeof options === 'boolean' ? options : options.capture;
|
|
4639
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4583
4640
|
let events, index;
|
|
4584
4641
|
const map = __getListenerMap(this, capture);
|
|
4585
4642
|
typeList.forEach(type => {
|
|
@@ -4881,7 +4938,7 @@ var LeaferUI = (function (exports) {
|
|
|
4881
4938
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
4882
4939
|
if (layout.affectScaleOrRotation) {
|
|
4883
4940
|
if (layout.scaleChanged || layout.rotationChanged) {
|
|
4884
|
-
setLayout(local, data, null, layout.affectRotation);
|
|
4941
|
+
setLayout(local, data, null, null, layout.affectRotation);
|
|
4885
4942
|
layout.scaleChanged = layout.rotationChanged = false;
|
|
4886
4943
|
}
|
|
4887
4944
|
}
|
|
@@ -4889,7 +4946,7 @@ var LeaferUI = (function (exports) {
|
|
|
4889
4946
|
local.f = data.y + data.offsetY;
|
|
4890
4947
|
if (data.around || data.origin) {
|
|
4891
4948
|
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
|
|
4892
|
-
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.
|
|
4949
|
+
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
|
|
4893
4950
|
}
|
|
4894
4951
|
}
|
|
4895
4952
|
this.__layout.matrixChanged = false;
|
|
@@ -4898,7 +4955,7 @@ var LeaferUI = (function (exports) {
|
|
|
4898
4955
|
|
|
4899
4956
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4900
4957
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4901
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
4958
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
|
|
4902
4959
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4903
4960
|
const LeafBounds = {
|
|
4904
4961
|
__updateWorldBounds() {
|
|
@@ -4999,7 +5056,7 @@ var LeaferUI = (function (exports) {
|
|
|
4999
5056
|
updateAllMatrix$2(this);
|
|
5000
5057
|
updateBounds$1(this, this);
|
|
5001
5058
|
if (this.__.__autoSide)
|
|
5002
|
-
this.__updateBoxBounds();
|
|
5059
|
+
this.__updateBoxBounds(true);
|
|
5003
5060
|
}
|
|
5004
5061
|
else {
|
|
5005
5062
|
updateAllMatrix$2(this);
|
|
@@ -5017,11 +5074,11 @@ var LeaferUI = (function (exports) {
|
|
|
5017
5074
|
},
|
|
5018
5075
|
__updateStrokeBounds() {
|
|
5019
5076
|
const layout = this.__layout;
|
|
5020
|
-
copyAndSpread$
|
|
5077
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5021
5078
|
},
|
|
5022
5079
|
__updateRenderBounds() {
|
|
5023
5080
|
const layout = this.__layout;
|
|
5024
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5081
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5025
5082
|
}
|
|
5026
5083
|
};
|
|
5027
5084
|
|
|
@@ -5118,7 +5175,7 @@ var LeaferUI = (function (exports) {
|
|
|
5118
5175
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5119
5176
|
const { toOuterOf } = BoundsHelper;
|
|
5120
5177
|
const { copy: copy$4 } = PointHelper;
|
|
5121
|
-
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5178
|
+
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5122
5179
|
exports.Leaf = class Leaf {
|
|
5123
5180
|
get tag() { return this.__tag; }
|
|
5124
5181
|
set tag(_value) { }
|
|
@@ -5144,6 +5201,8 @@ var LeaferUI = (function (exports) {
|
|
|
5144
5201
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5145
5202
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5146
5203
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5204
|
+
set event(map) { let event; for (let key in map)
|
|
5205
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
|
|
5147
5206
|
constructor(data) {
|
|
5148
5207
|
this.innerId = create(LEAF);
|
|
5149
5208
|
this.reset(data);
|
|
@@ -5379,6 +5438,9 @@ var LeaferUI = (function (exports) {
|
|
|
5379
5438
|
move(x, y) {
|
|
5380
5439
|
moveLocal(this, x, y);
|
|
5381
5440
|
}
|
|
5441
|
+
moveInner(x, y) {
|
|
5442
|
+
moveWorld(this, x, y, true);
|
|
5443
|
+
}
|
|
5382
5444
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5383
5445
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5384
5446
|
}
|
|
@@ -5403,6 +5465,9 @@ var LeaferUI = (function (exports) {
|
|
|
5403
5465
|
skewOfWorld(worldOrigin, skewX, skewY, resize) {
|
|
5404
5466
|
skewOfWorld(this, worldOrigin, skewX, skewY, resize);
|
|
5405
5467
|
}
|
|
5468
|
+
flip(axis) {
|
|
5469
|
+
transform(this, getFlipTransform(this, axis));
|
|
5470
|
+
}
|
|
5406
5471
|
scaleResize(scaleX, scaleY = scaleX, _noResize) {
|
|
5407
5472
|
this.scaleX *= scaleX;
|
|
5408
5473
|
this.scaleY *= scaleY;
|
|
@@ -5760,7 +5825,7 @@ var LeaferUI = (function (exports) {
|
|
|
5760
5825
|
}
|
|
5761
5826
|
}
|
|
5762
5827
|
|
|
5763
|
-
const version = "1.0.
|
|
5828
|
+
const version = "1.0.1";
|
|
5764
5829
|
const inviteCode = {};
|
|
5765
5830
|
|
|
5766
5831
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
@@ -5784,7 +5849,8 @@ var LeaferUI = (function (exports) {
|
|
|
5784
5849
|
}
|
|
5785
5850
|
}
|
|
5786
5851
|
init() {
|
|
5787
|
-
const {
|
|
5852
|
+
const { config } = this;
|
|
5853
|
+
const view = config.view || config.canvas;
|
|
5788
5854
|
view ? this.__createViewFrom(view) : this.__createView();
|
|
5789
5855
|
const { style } = this.view;
|
|
5790
5856
|
style.display || (style.display = 'block');
|
|
@@ -5799,7 +5865,7 @@ var LeaferUI = (function (exports) {
|
|
|
5799
5865
|
}
|
|
5800
5866
|
this.__createContext();
|
|
5801
5867
|
if (!this.autoLayout)
|
|
5802
|
-
this.resize(
|
|
5868
|
+
this.resize(config);
|
|
5803
5869
|
}
|
|
5804
5870
|
set backgroundColor(color) { this.view.style.backgroundColor = color; }
|
|
5805
5871
|
get backgroundColor() { return this.view.style.backgroundColor; }
|
|
@@ -5855,26 +5921,37 @@ var LeaferUI = (function (exports) {
|
|
|
5855
5921
|
this.clientBounds = this.view.getBoundingClientRect();
|
|
5856
5922
|
}
|
|
5857
5923
|
startAutoLayout(autoBounds, listener) {
|
|
5858
|
-
this.autoBounds = autoBounds;
|
|
5859
5924
|
this.resizeListener = listener;
|
|
5860
|
-
|
|
5861
|
-
this.
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
this.
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
this.
|
|
5869
|
-
|
|
5925
|
+
if (autoBounds) {
|
|
5926
|
+
this.autoBounds = autoBounds;
|
|
5927
|
+
try {
|
|
5928
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
5929
|
+
this.updateClientBounds();
|
|
5930
|
+
for (const entry of entries)
|
|
5931
|
+
this.checkAutoBounds(entry.contentRect);
|
|
5932
|
+
});
|
|
5933
|
+
const parent = this.parentView;
|
|
5934
|
+
if (parent) {
|
|
5935
|
+
this.resizeObserver.observe(parent);
|
|
5936
|
+
this.checkAutoBounds(parent.getBoundingClientRect());
|
|
5937
|
+
}
|
|
5938
|
+
else {
|
|
5939
|
+
this.checkAutoBounds(this.view);
|
|
5940
|
+
debug$7.warn('no parent');
|
|
5941
|
+
}
|
|
5870
5942
|
}
|
|
5871
|
-
|
|
5872
|
-
this.
|
|
5873
|
-
debug$7.warn('no parent');
|
|
5943
|
+
catch (_a) {
|
|
5944
|
+
this.imitateResizeObserver();
|
|
5874
5945
|
}
|
|
5875
5946
|
}
|
|
5876
|
-
|
|
5877
|
-
|
|
5947
|
+
else {
|
|
5948
|
+
window.addEventListener('resize', () => {
|
|
5949
|
+
const pixelRatio = Platform.devicePixelRatio;
|
|
5950
|
+
if (this.pixelRatio !== pixelRatio) {
|
|
5951
|
+
const { width, height } = this;
|
|
5952
|
+
this.emitResize({ width, height, pixelRatio });
|
|
5953
|
+
}
|
|
5954
|
+
});
|
|
5878
5955
|
}
|
|
5879
5956
|
}
|
|
5880
5957
|
imitateResizeObserver() {
|
|
@@ -5887,17 +5964,12 @@ var LeaferUI = (function (exports) {
|
|
|
5887
5964
|
checkAutoBounds(parentSize) {
|
|
5888
5965
|
const view = this.view;
|
|
5889
5966
|
const { x, y, width, height } = this.autoBounds.getBoundsFrom(parentSize);
|
|
5890
|
-
|
|
5967
|
+
const size = { width, height, pixelRatio: Platform.devicePixelRatio };
|
|
5968
|
+
if (!this.isSameSize(size)) {
|
|
5891
5969
|
const { style } = view;
|
|
5892
|
-
const { pixelRatio } = this;
|
|
5893
5970
|
style.marginLeft = x + 'px';
|
|
5894
5971
|
style.marginTop = y + 'px';
|
|
5895
|
-
|
|
5896
|
-
const oldSize = {};
|
|
5897
|
-
DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
|
|
5898
|
-
this.resize(size);
|
|
5899
|
-
if (this.width !== undefined)
|
|
5900
|
-
this.resizeListener(new ResizeEvent(size, oldSize));
|
|
5972
|
+
this.emitResize(size);
|
|
5901
5973
|
}
|
|
5902
5974
|
}
|
|
5903
5975
|
stopAutoLayout() {
|
|
@@ -5908,6 +5980,13 @@ var LeaferUI = (function (exports) {
|
|
|
5908
5980
|
this.resizeObserver = null;
|
|
5909
5981
|
}
|
|
5910
5982
|
}
|
|
5983
|
+
emitResize(size) {
|
|
5984
|
+
const oldSize = {};
|
|
5985
|
+
DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
|
|
5986
|
+
this.resize(size);
|
|
5987
|
+
if (this.width !== undefined)
|
|
5988
|
+
this.resizeListener(new ResizeEvent(size, oldSize));
|
|
5989
|
+
}
|
|
5911
5990
|
unrealCanvas() {
|
|
5912
5991
|
if (!this.unreal && this.parentView) {
|
|
5913
5992
|
const view = this.view;
|
|
@@ -5988,7 +6067,7 @@ var LeaferUI = (function (exports) {
|
|
|
5988
6067
|
Platform.name = 'web';
|
|
5989
6068
|
Platform.isMobile = 'ontouchstart' in window;
|
|
5990
6069
|
Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
|
|
5991
|
-
Platform
|
|
6070
|
+
defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, devicePixelRatio); } });
|
|
5992
6071
|
const { userAgent } = navigator;
|
|
5993
6072
|
if (userAgent.indexOf("Firefox") > -1) {
|
|
5994
6073
|
Platform.conicGradientRotate90 = true;
|
|
@@ -6485,14 +6564,14 @@ var LeaferUI = (function (exports) {
|
|
|
6485
6564
|
if (Debug.showRepaint)
|
|
6486
6565
|
this.canvas.strokeWorld(bounds, 'red');
|
|
6487
6566
|
this.target.__render(this.canvas, options);
|
|
6488
|
-
this.renderBounds = realBounds || bounds;
|
|
6567
|
+
this.renderBounds = realBounds = realBounds || bounds;
|
|
6489
6568
|
this.renderOptions = options;
|
|
6490
|
-
this.totalBounds.isEmpty() ? this.totalBounds =
|
|
6569
|
+
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
6491
6570
|
if (Debug.showHitView)
|
|
6492
6571
|
this.renderHitView(options);
|
|
6493
6572
|
if (Debug.showBoundsView)
|
|
6494
6573
|
this.renderBoundsView(options);
|
|
6495
|
-
this.canvas.updateRender();
|
|
6574
|
+
this.canvas.updateRender(realBounds);
|
|
6496
6575
|
}
|
|
6497
6576
|
renderHitView(_options) { }
|
|
6498
6577
|
renderBoundsView(_options) { }
|
|
@@ -7072,6 +7151,11 @@ var LeaferUI = (function (exports) {
|
|
|
7072
7151
|
}
|
|
7073
7152
|
|
|
7074
7153
|
class LeaferData extends GroupData {
|
|
7154
|
+
__getInputData() {
|
|
7155
|
+
const data = super.__getInputData();
|
|
7156
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
7157
|
+
return data;
|
|
7158
|
+
}
|
|
7075
7159
|
}
|
|
7076
7160
|
|
|
7077
7161
|
class FrameData extends BoxData {
|
|
@@ -7149,6 +7233,11 @@ var LeaferUI = (function (exports) {
|
|
|
7149
7233
|
}
|
|
7150
7234
|
|
|
7151
7235
|
class CanvasData extends RectData {
|
|
7236
|
+
__getInputData() {
|
|
7237
|
+
const data = super.__getInputData();
|
|
7238
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
7239
|
+
return data;
|
|
7240
|
+
}
|
|
7152
7241
|
}
|
|
7153
7242
|
|
|
7154
7243
|
const UIBounds = {
|
|
@@ -7814,7 +7903,7 @@ var LeaferUI = (function (exports) {
|
|
|
7814
7903
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7815
7904
|
if (this.isApp)
|
|
7816
7905
|
this.__setApp();
|
|
7817
|
-
this.__checkAutoLayout(config);
|
|
7906
|
+
this.__checkAutoLayout(config, parentApp);
|
|
7818
7907
|
this.view = canvas.view;
|
|
7819
7908
|
if (parentApp) {
|
|
7820
7909
|
this.__bindApp(parentApp);
|
|
@@ -7915,9 +8004,10 @@ var LeaferUI = (function (exports) {
|
|
|
7915
8004
|
this.leafer = leafer;
|
|
7916
8005
|
this.__level = 1;
|
|
7917
8006
|
}
|
|
7918
|
-
__checkAutoLayout(config) {
|
|
7919
|
-
if (!
|
|
7920
|
-
|
|
8007
|
+
__checkAutoLayout(config, parentApp) {
|
|
8008
|
+
if (!parentApp) {
|
|
8009
|
+
if (!config.width || !config.height)
|
|
8010
|
+
this.autoLayout = new AutoBounds(config);
|
|
7921
8011
|
this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
|
|
7922
8012
|
}
|
|
7923
8013
|
}
|
|
@@ -8052,12 +8142,21 @@ var LeaferUI = (function (exports) {
|
|
|
8052
8142
|
list.push(item);
|
|
8053
8143
|
}
|
|
8054
8144
|
}
|
|
8055
|
-
zoom(_zoomType, _padding, _fixedScale) {
|
|
8145
|
+
zoom(_zoomType, _padding, _fixedScale) {
|
|
8146
|
+
return debug$3.error('need @leafer-in/view');
|
|
8147
|
+
}
|
|
8056
8148
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
8057
8149
|
getValidScale(changeScale) { return changeScale; }
|
|
8058
8150
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
8059
8151
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
8060
8152
|
}
|
|
8153
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
8154
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8155
|
+
}
|
|
8156
|
+
updateClientBounds() {
|
|
8157
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
8158
|
+
}
|
|
8159
|
+
receiveEvent(_event) { }
|
|
8061
8160
|
__checkUpdateLayout() {
|
|
8062
8161
|
this.__layout.update();
|
|
8063
8162
|
}
|
|
@@ -8141,7 +8240,7 @@ var LeaferUI = (function (exports) {
|
|
|
8141
8240
|
const rect$1 = exports.Rect.prototype;
|
|
8142
8241
|
const group$1 = exports.Group.prototype;
|
|
8143
8242
|
const childrenRenderBounds = {};
|
|
8144
|
-
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8243
|
+
const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8145
8244
|
exports.Box = class Box extends exports.Group {
|
|
8146
8245
|
get __tag() { return 'Box'; }
|
|
8147
8246
|
get isBranchLeaf() { return true; }
|
|
@@ -8155,20 +8254,23 @@ var LeaferUI = (function (exports) {
|
|
|
8155
8254
|
return this.__updateRectRenderSpread() || -1;
|
|
8156
8255
|
}
|
|
8157
8256
|
__updateRectBoxBounds() { }
|
|
8158
|
-
__updateBoxBounds() {
|
|
8257
|
+
__updateBoxBounds(secondLayout) {
|
|
8159
8258
|
const data = this.__;
|
|
8160
8259
|
if (this.children.length) {
|
|
8161
8260
|
if (data.__autoSide) {
|
|
8162
8261
|
if (this.leafer && this.leafer.ready)
|
|
8163
8262
|
this.leafer.layouter.addExtra(this);
|
|
8164
8263
|
super.__updateBoxBounds();
|
|
8264
|
+
const { boxBounds } = this.__layout;
|
|
8165
8265
|
if (!data.__autoSize) {
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
8266
|
+
if (data.__autoWidth)
|
|
8267
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
8268
|
+
else
|
|
8269
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
8171
8270
|
}
|
|
8271
|
+
if (secondLayout && data.flow && data.padding)
|
|
8272
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8273
|
+
this.__updateNaturalSize();
|
|
8172
8274
|
}
|
|
8173
8275
|
else {
|
|
8174
8276
|
this.__updateRectBoxBounds();
|
|
@@ -8188,13 +8290,13 @@ var LeaferUI = (function (exports) {
|
|
|
8188
8290
|
super.__updateRenderBounds();
|
|
8189
8291
|
copy$3(childrenRenderBounds, renderBounds);
|
|
8190
8292
|
this.__updateRectRenderBounds();
|
|
8191
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
8293
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
8192
8294
|
}
|
|
8193
8295
|
else {
|
|
8194
8296
|
this.__updateRectRenderBounds();
|
|
8195
8297
|
}
|
|
8196
8298
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8197
|
-
if (
|
|
8299
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
8198
8300
|
add(renderBounds, childrenRenderBounds);
|
|
8199
8301
|
}
|
|
8200
8302
|
__updateRectRenderBounds() { }
|
|
@@ -8528,14 +8630,26 @@ var LeaferUI = (function (exports) {
|
|
|
8528
8630
|
exports.Image = __decorate([
|
|
8529
8631
|
registerUI()
|
|
8530
8632
|
], exports.Image);
|
|
8633
|
+
const MyImage = exports.Image;
|
|
8531
8634
|
|
|
8532
8635
|
exports.Canvas = class Canvas extends exports.Rect {
|
|
8533
8636
|
get __tag() { return 'Canvas'; }
|
|
8637
|
+
get ready() { return !this.url; }
|
|
8534
8638
|
constructor(data) {
|
|
8535
8639
|
super(data);
|
|
8536
8640
|
this.canvas = Creator.canvas(this.__);
|
|
8537
8641
|
this.context = this.canvas.context;
|
|
8538
8642
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8643
|
+
if (data && data.url)
|
|
8644
|
+
this.drawImage(data.url);
|
|
8645
|
+
}
|
|
8646
|
+
drawImage(url) {
|
|
8647
|
+
new LeaferImage({ url }).load((image) => {
|
|
8648
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8649
|
+
this.url = undefined;
|
|
8650
|
+
this.paint();
|
|
8651
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8652
|
+
});
|
|
8539
8653
|
}
|
|
8540
8654
|
draw(ui, offset, scale, rotation) {
|
|
8541
8655
|
ui.__layout.update();
|
|
@@ -8579,8 +8693,7 @@ var LeaferUI = (function (exports) {
|
|
|
8579
8693
|
destroy() {
|
|
8580
8694
|
if (this.canvas) {
|
|
8581
8695
|
this.canvas.destroy();
|
|
8582
|
-
this.canvas = null;
|
|
8583
|
-
this.context = null;
|
|
8696
|
+
this.canvas = this.context = null;
|
|
8584
8697
|
}
|
|
8585
8698
|
super.destroy();
|
|
8586
8699
|
}
|
|
@@ -8595,7 +8708,7 @@ var LeaferUI = (function (exports) {
|
|
|
8595
8708
|
resizeType(100)
|
|
8596
8709
|
], exports.Canvas.prototype, "height", void 0);
|
|
8597
8710
|
__decorate([
|
|
8598
|
-
resizeType(
|
|
8711
|
+
resizeType(1)
|
|
8599
8712
|
], exports.Canvas.prototype, "pixelRatio", void 0);
|
|
8600
8713
|
__decorate([
|
|
8601
8714
|
resizeType(true)
|
|
@@ -8619,13 +8732,13 @@ var LeaferUI = (function (exports) {
|
|
|
8619
8732
|
super(data);
|
|
8620
8733
|
}
|
|
8621
8734
|
__drawHitPath(canvas) {
|
|
8622
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8735
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8623
8736
|
canvas.beginPath();
|
|
8624
8737
|
if (this.__.__letterSpacing < 0) {
|
|
8625
8738
|
this.__drawPathByData(canvas);
|
|
8626
8739
|
}
|
|
8627
8740
|
else {
|
|
8628
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8741
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8629
8742
|
}
|
|
8630
8743
|
}
|
|
8631
8744
|
__drawPathByData(drawer, _data) {
|
|
@@ -8818,7 +8931,8 @@ var LeaferUI = (function (exports) {
|
|
|
8818
8931
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8819
8932
|
clearPath() { return this; }
|
|
8820
8933
|
paint() {
|
|
8821
|
-
this.pathElement.
|
|
8934
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8935
|
+
this.pathElement.forceUpdate('path');
|
|
8822
8936
|
}
|
|
8823
8937
|
};
|
|
8824
8938
|
__decorate([
|
|
@@ -8828,7 +8942,7 @@ var LeaferUI = (function (exports) {
|
|
|
8828
8942
|
penPathType()
|
|
8829
8943
|
], exports.Pen.prototype, "path", void 0);
|
|
8830
8944
|
exports.Pen = __decorate([
|
|
8831
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8945
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8832
8946
|
registerUI()
|
|
8833
8947
|
], exports.Pen);
|
|
8834
8948
|
function penPathType() {
|
|
@@ -8933,11 +9047,13 @@ var LeaferUI = (function (exports) {
|
|
|
8933
9047
|
this.renderer.update();
|
|
8934
9048
|
}
|
|
8935
9049
|
__render(canvas, options) {
|
|
8936
|
-
if (
|
|
8937
|
-
|
|
8938
|
-
|
|
9050
|
+
if (canvas.context) {
|
|
9051
|
+
if (options.matrix) {
|
|
9052
|
+
const { a, b, c, d, e, f } = options.matrix;
|
|
9053
|
+
canvas.setTransform(a, b, c, d, e, f);
|
|
9054
|
+
}
|
|
9055
|
+
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
8939
9056
|
}
|
|
8940
|
-
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
8941
9057
|
}
|
|
8942
9058
|
__onResize(event) {
|
|
8943
9059
|
this.children.forEach(leafer => leafer.resize(event));
|
|
@@ -9049,6 +9165,7 @@ var LeaferUI = (function (exports) {
|
|
|
9049
9165
|
exports.PointerEvent = __decorate([
|
|
9050
9166
|
registerUIEvent()
|
|
9051
9167
|
], exports.PointerEvent);
|
|
9168
|
+
const MyPointerEvent = exports.PointerEvent;
|
|
9052
9169
|
|
|
9053
9170
|
const move = {};
|
|
9054
9171
|
exports.DragEvent = class DragEvent extends exports.PointerEvent {
|
|
@@ -9148,6 +9265,7 @@ var LeaferUI = (function (exports) {
|
|
|
9148
9265
|
exports.DragEvent = __decorate([
|
|
9149
9266
|
registerUIEvent()
|
|
9150
9267
|
], exports.DragEvent);
|
|
9268
|
+
const MyDragEvent = exports.DragEvent;
|
|
9151
9269
|
|
|
9152
9270
|
exports.DropEvent = class DropEvent extends exports.PointerEvent {
|
|
9153
9271
|
static setList(data) {
|
|
@@ -9229,36 +9347,32 @@ var LeaferUI = (function (exports) {
|
|
|
9229
9347
|
|
|
9230
9348
|
function document$1(leafer) {
|
|
9231
9349
|
addInteractionWindow(leafer);
|
|
9232
|
-
|
|
9233
|
-
|
|
9350
|
+
const { move, zoom } = leafer.config;
|
|
9351
|
+
move.scroll = 'limit';
|
|
9352
|
+
zoom.min = 1;
|
|
9353
|
+
}
|
|
9354
|
+
|
|
9355
|
+
function block(leafer) {
|
|
9356
|
+
const { config } = leafer;
|
|
9357
|
+
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9358
|
+
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9234
9359
|
}
|
|
9235
9360
|
|
|
9236
9361
|
const debug$2 = Debug.get('LeaferTypeCreator');
|
|
9237
9362
|
const LeaferTypeCreator = {
|
|
9238
9363
|
list: {},
|
|
9239
9364
|
register(name, fn) {
|
|
9240
|
-
|
|
9241
|
-
debug$2.repeat(name);
|
|
9242
|
-
}
|
|
9243
|
-
else {
|
|
9244
|
-
list[name] = fn;
|
|
9245
|
-
}
|
|
9365
|
+
list[name] ? debug$2.repeat(name) : list[name] = fn;
|
|
9246
9366
|
},
|
|
9247
9367
|
run(name, leafer) {
|
|
9248
9368
|
const fn = list[name];
|
|
9249
|
-
|
|
9250
|
-
fn(leafer);
|
|
9251
|
-
}
|
|
9252
|
-
else {
|
|
9253
|
-
debug$2.error('no', name);
|
|
9254
|
-
}
|
|
9369
|
+
fn && fn(leafer);
|
|
9255
9370
|
}
|
|
9256
9371
|
};
|
|
9257
9372
|
const { list, register } = LeaferTypeCreator;
|
|
9258
|
-
register('draw', () => { });
|
|
9259
|
-
register('custom', () => { });
|
|
9260
9373
|
register('design', addInteractionWindow);
|
|
9261
9374
|
register('document', document$1);
|
|
9375
|
+
register('block', block);
|
|
9262
9376
|
|
|
9263
9377
|
const leafer = exports.Leafer.prototype;
|
|
9264
9378
|
leafer.initType = function (type) {
|
|
@@ -9304,11 +9418,14 @@ var LeaferUI = (function (exports) {
|
|
|
9304
9418
|
};
|
|
9305
9419
|
|
|
9306
9420
|
class Transformer {
|
|
9421
|
+
get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
|
|
9307
9422
|
constructor(interaction) {
|
|
9308
9423
|
this.interaction = interaction;
|
|
9309
9424
|
}
|
|
9310
9425
|
move(data) {
|
|
9311
9426
|
const { interaction } = this;
|
|
9427
|
+
if (!data.moveType)
|
|
9428
|
+
data.moveType = 'move';
|
|
9312
9429
|
if (!this.moveData) {
|
|
9313
9430
|
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9314
9431
|
data.path = path;
|
|
@@ -9444,7 +9561,13 @@ var LeaferUI = (function (exports) {
|
|
|
9444
9561
|
find.add(list[i]);
|
|
9445
9562
|
}
|
|
9446
9563
|
return find;
|
|
9447
|
-
}
|
|
9564
|
+
},
|
|
9565
|
+
pathCanDrag(path) {
|
|
9566
|
+
return path && path.list.some(item => item.draggable || item.editable || (!item.isLeafer && item.hasEvent(exports.DragEvent.DRAG)));
|
|
9567
|
+
},
|
|
9568
|
+
pathHasOutside(path) {
|
|
9569
|
+
return path && path.list.some(item => item.isOutside);
|
|
9570
|
+
},
|
|
9448
9571
|
};
|
|
9449
9572
|
const I = InteractionHelper;
|
|
9450
9573
|
|
|
@@ -9473,8 +9596,10 @@ var LeaferUI = (function (exports) {
|
|
|
9473
9596
|
return;
|
|
9474
9597
|
}
|
|
9475
9598
|
if (!this.moving && canDrag) {
|
|
9476
|
-
if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty)
|
|
9599
|
+
if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty) {
|
|
9600
|
+
this.dragData.moveType = 'drag';
|
|
9477
9601
|
interaction.emit(exports.MoveEvent.START, this.dragData);
|
|
9602
|
+
}
|
|
9478
9603
|
}
|
|
9479
9604
|
if (!this.moving) {
|
|
9480
9605
|
this.dragStart(data, canDrag);
|
|
@@ -9513,6 +9638,7 @@ var LeaferUI = (function (exports) {
|
|
|
9513
9638
|
this.dragData.throughPath = throughPath;
|
|
9514
9639
|
this.dragData.path = path;
|
|
9515
9640
|
if (this.moving) {
|
|
9641
|
+
this.dragData.moveType = 'drag';
|
|
9516
9642
|
interaction.emit(exports.MoveEvent.BEFORE_MOVE, this.dragData);
|
|
9517
9643
|
interaction.emit(exports.MoveEvent.MOVE, this.dragData);
|
|
9518
9644
|
}
|
|
@@ -9579,6 +9705,7 @@ var LeaferUI = (function (exports) {
|
|
|
9579
9705
|
endDragData.path = path;
|
|
9580
9706
|
if (this.moving) {
|
|
9581
9707
|
this.moving = false;
|
|
9708
|
+
endDragData.moveType = 'drag';
|
|
9582
9709
|
interaction.emit(exports.MoveEvent.END, endDragData);
|
|
9583
9710
|
}
|
|
9584
9711
|
if (this.dragging) {
|
|
@@ -9637,7 +9764,7 @@ var LeaferUI = (function (exports) {
|
|
|
9637
9764
|
totalY += moveY;
|
|
9638
9765
|
PointHelper.move(downData, moveX, moveY);
|
|
9639
9766
|
PointHelper.move(this.dragData, moveX, moveY);
|
|
9640
|
-
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY }));
|
|
9767
|
+
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
|
|
9641
9768
|
interaction.pointerMoveReal(data);
|
|
9642
9769
|
}, 10);
|
|
9643
9770
|
}
|
|
@@ -9750,22 +9877,27 @@ var LeaferUI = (function (exports) {
|
|
|
9750
9877
|
swipeDistance: 20,
|
|
9751
9878
|
preventDefaultMenu: true
|
|
9752
9879
|
},
|
|
9880
|
+
touch: {
|
|
9881
|
+
preventDefault: true
|
|
9882
|
+
},
|
|
9753
9883
|
cursor: true,
|
|
9754
9884
|
keyEvent: true
|
|
9755
9885
|
};
|
|
9756
9886
|
|
|
9757
|
-
const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1 } = InteractionHelper;
|
|
9887
|
+
const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1, pathCanDrag: pathCanDrag$1, pathHasOutside } = InteractionHelper;
|
|
9758
9888
|
class InteractionBase {
|
|
9759
9889
|
get dragging() { return this.dragger.dragging; }
|
|
9760
|
-
get
|
|
9890
|
+
get transforming() { return this.transformer.transforming; }
|
|
9891
|
+
get moveMode() { return this.config.move.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9892
|
+
get canHover() { return this.config.pointer.hover && !this.config.mobile; }
|
|
9761
9893
|
get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
|
|
9762
|
-
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.
|
|
9894
|
+
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
|
|
9763
9895
|
get isHoldMiddleKey() { return this.config.move.holdMiddleKey && this.downData && PointerButton.middle(this.downData); }
|
|
9764
9896
|
get isHoldRightKey() { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData); }
|
|
9765
9897
|
get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
|
|
9766
9898
|
get hitRadius() { return this.config.pointer.hitRadius; }
|
|
9767
9899
|
constructor(target, canvas, selector, userConfig) {
|
|
9768
|
-
this.config = config;
|
|
9900
|
+
this.config = DataHelper.clone(config);
|
|
9769
9901
|
this.tapCount = 0;
|
|
9770
9902
|
this.downKeyMap = {};
|
|
9771
9903
|
this.target = target;
|
|
@@ -9852,6 +9984,7 @@ var LeaferUI = (function (exports) {
|
|
|
9852
9984
|
if (!downData)
|
|
9853
9985
|
return;
|
|
9854
9986
|
PointerButton.defaultLeft(data);
|
|
9987
|
+
data.multiTouch = downData.multiTouch;
|
|
9855
9988
|
this.findPath(data);
|
|
9856
9989
|
const upData = Object.assign(Object.assign({}, data), { path: data.path.clone() });
|
|
9857
9990
|
data.path.addList(downData.path.list);
|
|
@@ -9924,7 +10057,7 @@ var LeaferUI = (function (exports) {
|
|
|
9924
10057
|
this.updateCursor();
|
|
9925
10058
|
}
|
|
9926
10059
|
pointerHover(data) {
|
|
9927
|
-
if (this.
|
|
10060
|
+
if (this.canHover) {
|
|
9928
10061
|
this.pointerOverOrOut(data);
|
|
9929
10062
|
this.pointerEnterOrLeave(data);
|
|
9930
10063
|
}
|
|
@@ -10016,11 +10149,11 @@ var LeaferUI = (function (exports) {
|
|
|
10016
10149
|
return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
|
|
10017
10150
|
}
|
|
10018
10151
|
checkPath(data, useDefaultPath) {
|
|
10019
|
-
if (useDefaultPath || this.
|
|
10152
|
+
if (useDefaultPath || (this.moveMode && !pathHasOutside(data.path)))
|
|
10020
10153
|
data.path = this.defaultPath;
|
|
10021
10154
|
}
|
|
10022
10155
|
canMove(data) {
|
|
10023
|
-
return this.moveMode
|
|
10156
|
+
return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag$1(data.path))) && !pathHasOutside(data.path);
|
|
10024
10157
|
}
|
|
10025
10158
|
isDrag(leaf) {
|
|
10026
10159
|
return this.dragger.getList().has(leaf);
|
|
@@ -10061,7 +10194,7 @@ var LeaferUI = (function (exports) {
|
|
|
10061
10194
|
this.hoverData = data;
|
|
10062
10195
|
}
|
|
10063
10196
|
updateCursor(data) {
|
|
10064
|
-
if (!this.config.cursor || !this.
|
|
10197
|
+
if (!this.config.cursor || !this.canHover)
|
|
10065
10198
|
return;
|
|
10066
10199
|
if (!data) {
|
|
10067
10200
|
this.updateHoverData();
|
|
@@ -10383,7 +10516,7 @@ var LeaferUI = (function (exports) {
|
|
|
10383
10516
|
convertTouch(e, local) {
|
|
10384
10517
|
const touch = PointerEventHelper.getTouch(e);
|
|
10385
10518
|
const base = InteractionHelper.getBase(e);
|
|
10386
|
-
return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', pressure: touch.force });
|
|
10519
|
+
return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', multiTouch: e.touches.length > 1, pressure: touch.force });
|
|
10387
10520
|
},
|
|
10388
10521
|
getTouch(e) {
|
|
10389
10522
|
return e.targetTouches[0] || e.changedTouches[0];
|
|
@@ -10438,7 +10571,7 @@ var LeaferUI = (function (exports) {
|
|
|
10438
10571
|
}
|
|
10439
10572
|
};
|
|
10440
10573
|
|
|
10441
|
-
const { getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
|
|
10574
|
+
const { getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag } = InteractionHelper;
|
|
10442
10575
|
class Interaction extends InteractionBase {
|
|
10443
10576
|
__listenEvents() {
|
|
10444
10577
|
super.__listenEvents();
|
|
@@ -10524,21 +10657,21 @@ var LeaferUI = (function (exports) {
|
|
|
10524
10657
|
}
|
|
10525
10658
|
onPointerDown(e) {
|
|
10526
10659
|
this.preventDefaultPointer(e);
|
|
10527
|
-
this.
|
|
10528
|
-
if (this.useMultiTouch)
|
|
10660
|
+
if (this.config.pointer.touch || this.useMultiTouch)
|
|
10529
10661
|
return;
|
|
10662
|
+
this.usePointer || (this.usePointer = true);
|
|
10530
10663
|
this.pointerDown(PointerEventHelper.convert(e, this.getLocal(e)));
|
|
10531
10664
|
}
|
|
10532
10665
|
onPointerMove(e) {
|
|
10533
|
-
this.
|
|
10534
|
-
if (this.useMultiTouch || this.preventWindowPointer(e))
|
|
10666
|
+
if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
|
|
10535
10667
|
return;
|
|
10668
|
+
this.usePointer || (this.usePointer = true);
|
|
10536
10669
|
this.pointerMove(PointerEventHelper.convert(e, this.getLocal(e, true)));
|
|
10537
10670
|
}
|
|
10538
10671
|
onPointerUp(e) {
|
|
10539
10672
|
if (this.downData)
|
|
10540
10673
|
this.preventDefaultPointer(e);
|
|
10541
|
-
if (this.useMultiTouch || this.preventWindowPointer(e))
|
|
10674
|
+
if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
|
|
10542
10675
|
return;
|
|
10543
10676
|
this.pointerUp(PointerEventHelper.convert(e, this.getLocal(e)));
|
|
10544
10677
|
}
|
|
@@ -10571,7 +10704,11 @@ var LeaferUI = (function (exports) {
|
|
|
10571
10704
|
this.pointerCancel();
|
|
10572
10705
|
}
|
|
10573
10706
|
onTouchStart(e) {
|
|
10574
|
-
|
|
10707
|
+
const touch = PointerEventHelper.getTouch(e);
|
|
10708
|
+
const local = this.getLocal(touch, true);
|
|
10709
|
+
const { preventDefault } = this.config.touch;
|
|
10710
|
+
if (preventDefault === true || (preventDefault === 'auto' && pathCanDrag(this.findPath(local))))
|
|
10711
|
+
e.preventDefault();
|
|
10575
10712
|
this.multiTouchStart(e);
|
|
10576
10713
|
if (this.usePointer)
|
|
10577
10714
|
return;
|
|
@@ -10580,8 +10717,7 @@ var LeaferUI = (function (exports) {
|
|
|
10580
10717
|
this.touchTimer = 0;
|
|
10581
10718
|
}
|
|
10582
10719
|
this.useTouch = true;
|
|
10583
|
-
|
|
10584
|
-
this.pointerDown(PointerEventHelper.convertTouch(e, this.getLocal(touch, true)));
|
|
10720
|
+
this.pointerDown(PointerEventHelper.convertTouch(e, local));
|
|
10585
10721
|
}
|
|
10586
10722
|
onTouchMove(e) {
|
|
10587
10723
|
this.multiTouchMove(e);
|
|
@@ -10608,7 +10744,7 @@ var LeaferUI = (function (exports) {
|
|
|
10608
10744
|
this.pointerCancel();
|
|
10609
10745
|
}
|
|
10610
10746
|
multiTouchStart(e) {
|
|
10611
|
-
this.useMultiTouch = (e.touches.length
|
|
10747
|
+
this.useMultiTouch = (e.touches.length > 1);
|
|
10612
10748
|
this.touches = this.useMultiTouch ? this.getTouches(e.touches) : undefined;
|
|
10613
10749
|
if (this.useMultiTouch)
|
|
10614
10750
|
this.pointerCancel();
|
|
@@ -11064,10 +11200,13 @@ var LeaferUI = (function (exports) {
|
|
|
11064
11200
|
const { get: get$2, translate } = MatrixHelper;
|
|
11065
11201
|
const tempBox = new Bounds();
|
|
11066
11202
|
const tempPoint = {};
|
|
11203
|
+
const tempScaleData = {};
|
|
11067
11204
|
function createData(leafPaint, image, paint, box) {
|
|
11068
|
-
const { blendMode } = paint;
|
|
11205
|
+
const { blendMode, sync } = paint;
|
|
11069
11206
|
if (blendMode)
|
|
11070
11207
|
leafPaint.blendMode = blendMode;
|
|
11208
|
+
if (sync)
|
|
11209
|
+
leafPaint.sync = sync;
|
|
11071
11210
|
leafPaint.data = getPatternData(paint, box, image);
|
|
11072
11211
|
}
|
|
11073
11212
|
function getPatternData(paint, box, image) {
|
|
@@ -11087,13 +11226,10 @@ var LeaferUI = (function (exports) {
|
|
|
11087
11226
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
11088
11227
|
}
|
|
11089
11228
|
}
|
|
11090
|
-
else if (size) {
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
|
|
11094
|
-
else if (scale) {
|
|
11095
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
11096
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
11229
|
+
else if (scale || size) {
|
|
11230
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
11231
|
+
scaleX = tempScaleData.scaleX;
|
|
11232
|
+
scaleY = tempScaleData.scaleY;
|
|
11097
11233
|
}
|
|
11098
11234
|
if (align) {
|
|
11099
11235
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -11298,7 +11434,7 @@ var LeaferUI = (function (exports) {
|
|
|
11298
11434
|
const { abs } = Math;
|
|
11299
11435
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
11300
11436
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
11301
|
-
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
11437
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
|
|
11302
11438
|
return false;
|
|
11303
11439
|
}
|
|
11304
11440
|
else {
|
|
@@ -11332,7 +11468,7 @@ var LeaferUI = (function (exports) {
|
|
|
11332
11468
|
return true;
|
|
11333
11469
|
}
|
|
11334
11470
|
else {
|
|
11335
|
-
if (!paint.style || Export.running) {
|
|
11471
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
11336
11472
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
11337
11473
|
}
|
|
11338
11474
|
else {
|
|
@@ -12202,6 +12338,7 @@ var LeaferUI = (function (exports) {
|
|
|
12202
12338
|
export(leaf, filename, options) {
|
|
12203
12339
|
this.running = true;
|
|
12204
12340
|
const fileType = FileHelper.fileType(filename);
|
|
12341
|
+
const isDownload = filename.includes('.');
|
|
12205
12342
|
options = FileHelper.getExportOptions(options);
|
|
12206
12343
|
return addTask((success) => new Promise((resolve) => {
|
|
12207
12344
|
const over = (result) => {
|
|
@@ -12211,19 +12348,13 @@ var LeaferUI = (function (exports) {
|
|
|
12211
12348
|
};
|
|
12212
12349
|
const { toURL } = Platform;
|
|
12213
12350
|
const { download } = Platform.origin;
|
|
12214
|
-
if (
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
else if (fileType === 'json') {
|
|
12218
|
-
download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
12219
|
-
return over({ data: true });
|
|
12351
|
+
if (fileType === 'json') {
|
|
12352
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
12353
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
12220
12354
|
}
|
|
12221
|
-
if (
|
|
12222
|
-
|
|
12223
|
-
|
|
12224
|
-
else if (fileType === 'svg') {
|
|
12225
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
12226
|
-
return over({ data: true });
|
|
12355
|
+
if (fileType === 'svg') {
|
|
12356
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
12357
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
12227
12358
|
}
|
|
12228
12359
|
const { leafer } = leaf;
|
|
12229
12360
|
if (leafer) {
|
|
@@ -12232,14 +12363,8 @@ var LeaferUI = (function (exports) {
|
|
|
12232
12363
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
12233
12364
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
12234
12365
|
const { slice, trim, onCanvas } = options;
|
|
12235
|
-
let scale = options.scale || 1;
|
|
12236
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
12237
12366
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
12238
12367
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
12239
|
-
if (leaf.isApp) {
|
|
12240
|
-
scale *= pixelRatio;
|
|
12241
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
12242
|
-
}
|
|
12243
12368
|
const screenshot = options.screenshot || leaf.isApp;
|
|
12244
12369
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
12245
12370
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -12273,10 +12398,21 @@ var LeaferUI = (function (exports) {
|
|
|
12273
12398
|
}
|
|
12274
12399
|
renderBounds = leaf.getBounds('render', relative);
|
|
12275
12400
|
}
|
|
12276
|
-
const {
|
|
12401
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
12402
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
12403
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
12404
|
+
if (leaf.isApp) {
|
|
12405
|
+
scaleData.scaleX *= pixelRatio;
|
|
12406
|
+
scaleData.scaleY *= pixelRatio;
|
|
12407
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
12408
|
+
}
|
|
12409
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
12410
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
12277
12411
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
12278
|
-
|
|
12412
|
+
let sliceLeaf;
|
|
12279
12413
|
if (slice) {
|
|
12414
|
+
sliceLeaf = leaf;
|
|
12415
|
+
sliceLeaf.__worldOpacity = 0;
|
|
12280
12416
|
leaf = leafer;
|
|
12281
12417
|
renderOptions.bounds = canvas.bounds;
|
|
12282
12418
|
}
|
|
@@ -12291,6 +12427,8 @@ var LeaferUI = (function (exports) {
|
|
|
12291
12427
|
leaf.__render(canvas, renderOptions);
|
|
12292
12428
|
}
|
|
12293
12429
|
canvas.restore();
|
|
12430
|
+
if (sliceLeaf)
|
|
12431
|
+
sliceLeaf.__updateWorldOpacity();
|
|
12294
12432
|
if (trim) {
|
|
12295
12433
|
trimBounds = getTrimBounds(canvas);
|
|
12296
12434
|
const old = canvas, { width, height } = trimBounds;
|
|
@@ -12440,6 +12578,9 @@ var LeaferUI = (function (exports) {
|
|
|
12440
12578
|
exports.Matrix = Matrix;
|
|
12441
12579
|
exports.MatrixHelper = MatrixHelper;
|
|
12442
12580
|
exports.MultiTouchHelper = MultiTouchHelper;
|
|
12581
|
+
exports.MyDragEvent = MyDragEvent;
|
|
12582
|
+
exports.MyImage = MyImage;
|
|
12583
|
+
exports.MyPointerEvent = MyPointerEvent;
|
|
12443
12584
|
exports.NeedConvertToCanvasCommandMap = NeedConvertToCanvasCommandMap;
|
|
12444
12585
|
exports.OneRadian = OneRadian;
|
|
12445
12586
|
exports.PI2 = PI2;
|