leafer-ui 1.0.0-rc.7 → 1.0.0-rc.8
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 +1 -1
- package/dist/web.esm.js +46 -13
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +135 -79
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +136 -80
- package/dist/web.module.min.js +1 -1
- package/package.json +4 -4
package/dist/web.js
CHANGED
|
@@ -104,14 +104,14 @@ var LeaferUI = (function (exports) {
|
|
|
104
104
|
const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
|
|
105
105
|
const { float } = MathHelper;
|
|
106
106
|
const tempPoint$2 = {};
|
|
107
|
-
function get$
|
|
107
|
+
function get$6() {
|
|
108
108
|
return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
|
|
109
109
|
}
|
|
110
110
|
function getWorld() {
|
|
111
|
-
return Object.assign(Object.assign({}, get$
|
|
111
|
+
return Object.assign(Object.assign({}, get$6()), { x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
|
|
112
112
|
}
|
|
113
113
|
const MatrixHelper = {
|
|
114
|
-
defaultMatrix: get$
|
|
114
|
+
defaultMatrix: get$6(),
|
|
115
115
|
defaultWorld: getWorld(),
|
|
116
116
|
tempMatrix: {},
|
|
117
117
|
set(t, a = 1, b = 0, c = 0, d = 1, e = 0, f = 0) {
|
|
@@ -122,7 +122,7 @@ var LeaferUI = (function (exports) {
|
|
|
122
122
|
t.e = e;
|
|
123
123
|
t.f = f;
|
|
124
124
|
},
|
|
125
|
-
get: get$
|
|
125
|
+
get: get$6,
|
|
126
126
|
getWorld,
|
|
127
127
|
copy(t, matrix) {
|
|
128
128
|
t.a = matrix.a;
|
|
@@ -685,7 +685,7 @@ var LeaferUI = (function (exports) {
|
|
|
685
685
|
|
|
686
686
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
687
687
|
const { toOuterPoint: toOuterPoint$1 } = MatrixHelper;
|
|
688
|
-
let right, bottom, boundsRight, boundsBottom;
|
|
688
|
+
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
689
689
|
const point = {};
|
|
690
690
|
const toPoint$1 = {};
|
|
691
691
|
const BoundsHelper = {
|
|
@@ -828,16 +828,16 @@ var LeaferUI = (function (exports) {
|
|
|
828
828
|
}
|
|
829
829
|
},
|
|
830
830
|
add(t, bounds) {
|
|
831
|
-
right = t.x + t.width;
|
|
832
|
-
bottom = t.y + t.height;
|
|
831
|
+
right$1 = t.x + t.width;
|
|
832
|
+
bottom$1 = t.y + t.height;
|
|
833
833
|
boundsRight = bounds.x + bounds.width;
|
|
834
834
|
boundsBottom = bounds.y + bounds.height;
|
|
835
|
-
right = right > boundsRight ? right : boundsRight;
|
|
836
|
-
bottom = bottom > boundsBottom ? bottom : boundsBottom;
|
|
835
|
+
right$1 = right$1 > boundsRight ? right$1 : boundsRight;
|
|
836
|
+
bottom$1 = bottom$1 > boundsBottom ? bottom$1 : boundsBottom;
|
|
837
837
|
t.x = t.x < bounds.x ? t.x : bounds.x;
|
|
838
838
|
t.y = t.y < bounds.y ? t.y : bounds.y;
|
|
839
|
-
t.width = right - t.x;
|
|
840
|
-
t.height = bottom - t.y;
|
|
839
|
+
t.width = right$1 - t.x;
|
|
840
|
+
t.height = bottom$1 - t.y;
|
|
841
841
|
},
|
|
842
842
|
addList(t, list) {
|
|
843
843
|
B.setListWithFn(t, list, undefined, true);
|
|
@@ -903,16 +903,16 @@ var LeaferUI = (function (exports) {
|
|
|
903
903
|
if (otherMatrix)
|
|
904
904
|
other = B.tempToOuterOf(other, otherMatrix);
|
|
905
905
|
let { x, y, width, height } = other;
|
|
906
|
-
right = x + width;
|
|
907
|
-
bottom = y + height;
|
|
906
|
+
right$1 = x + width;
|
|
907
|
+
bottom$1 = y + height;
|
|
908
908
|
boundsRight = t.x + t.width;
|
|
909
909
|
boundsBottom = t.y + t.height;
|
|
910
910
|
x = x > t.x ? x : t.x;
|
|
911
911
|
y = y > t.y ? y : t.y;
|
|
912
|
-
right = right < boundsRight ? right : boundsRight;
|
|
913
|
-
bottom = bottom < boundsBottom ? bottom : boundsBottom;
|
|
914
|
-
width = right - x;
|
|
915
|
-
height = bottom - y;
|
|
912
|
+
right$1 = right$1 < boundsRight ? right$1 : boundsRight;
|
|
913
|
+
bottom$1 = bottom$1 < boundsBottom ? bottom$1 : boundsBottom;
|
|
914
|
+
width = right$1 - x;
|
|
915
|
+
height = bottom$1 - y;
|
|
916
916
|
return { x, y, width, height };
|
|
917
917
|
},
|
|
918
918
|
intersect(t, other, otherMatrix) {
|
|
@@ -1056,25 +1056,55 @@ var LeaferUI = (function (exports) {
|
|
|
1056
1056
|
}
|
|
1057
1057
|
}
|
|
1058
1058
|
|
|
1059
|
-
|
|
1059
|
+
exports.Direction4 = void 0;
|
|
1060
|
+
(function (Direction4) {
|
|
1061
|
+
Direction4[Direction4["top"] = 0] = "top";
|
|
1062
|
+
Direction4[Direction4["right"] = 1] = "right";
|
|
1063
|
+
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
1064
|
+
Direction4[Direction4["left"] = 3] = "left";
|
|
1065
|
+
})(exports.Direction4 || (exports.Direction4 = {}));
|
|
1066
|
+
exports.Direction9 = void 0;
|
|
1067
|
+
(function (Direction9) {
|
|
1068
|
+
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
1069
|
+
Direction9[Direction9["top"] = 1] = "top";
|
|
1070
|
+
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
1071
|
+
Direction9[Direction9["right"] = 3] = "right";
|
|
1072
|
+
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
1073
|
+
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
1074
|
+
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
1075
|
+
Direction9[Direction9["left"] = 7] = "left";
|
|
1076
|
+
Direction9[Direction9["center"] = 8] = "center";
|
|
1077
|
+
})(exports.Direction9 || (exports.Direction9 = {}));
|
|
1078
|
+
|
|
1079
|
+
const directionData = [
|
|
1080
|
+
{ x: 0, y: 0 },
|
|
1081
|
+
{ x: 0.5, y: 0 },
|
|
1082
|
+
{ x: 1, y: 0 },
|
|
1083
|
+
{ x: 1, y: 0.5 },
|
|
1084
|
+
{ x: 1, y: 1 },
|
|
1085
|
+
{ x: 0.5, y: 1 },
|
|
1086
|
+
{ x: 0, y: 1 },
|
|
1087
|
+
{ x: 0, y: 0.5 },
|
|
1088
|
+
{ x: 0.5, y: 0.5 }
|
|
1089
|
+
];
|
|
1060
1090
|
const AroundHelper = {
|
|
1061
|
-
|
|
1091
|
+
directionData,
|
|
1062
1092
|
tempPoint: {},
|
|
1093
|
+
get: get$5,
|
|
1063
1094
|
toPoint(around, bounds, to, onlySize) {
|
|
1064
1095
|
to || (to = {});
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
break;
|
|
1069
|
-
}
|
|
1070
|
-
to.x = around.x * bounds.width;
|
|
1071
|
-
to.y = around.y * bounds.height;
|
|
1096
|
+
const point = get$5(around);
|
|
1097
|
+
to.x = point.x * bounds.width;
|
|
1098
|
+
to.y = point.y * bounds.height;
|
|
1072
1099
|
if (!onlySize) {
|
|
1073
1100
|
to.x += bounds.x;
|
|
1074
1101
|
to.y += bounds.y;
|
|
1075
1102
|
}
|
|
1076
1103
|
}
|
|
1077
1104
|
};
|
|
1105
|
+
function get$5(around) {
|
|
1106
|
+
return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
|
|
1107
|
+
}
|
|
1078
1108
|
|
|
1079
1109
|
const StringNumberMap = {
|
|
1080
1110
|
'0': 1,
|
|
@@ -3089,7 +3119,6 @@ var LeaferUI = (function (exports) {
|
|
|
3089
3119
|
break;
|
|
3090
3120
|
case G$1:
|
|
3091
3121
|
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3092
|
-
console.log('G');
|
|
3093
3122
|
i += 9;
|
|
3094
3123
|
break;
|
|
3095
3124
|
case F$1:
|
|
@@ -3804,7 +3833,7 @@ var LeaferUI = (function (exports) {
|
|
|
3804
3833
|
LayoutEvent.REQUEST = 'layout.request';
|
|
3805
3834
|
LayoutEvent.START = 'layout.start';
|
|
3806
3835
|
LayoutEvent.BEFORE = 'layout.before';
|
|
3807
|
-
LayoutEvent.LAYOUT = 'layout
|
|
3836
|
+
LayoutEvent.LAYOUT = 'layout';
|
|
3808
3837
|
LayoutEvent.AFTER = 'layout.after';
|
|
3809
3838
|
LayoutEvent.AGAIN = 'layout.again';
|
|
3810
3839
|
LayoutEvent.END = 'layout.end';
|
|
@@ -4453,13 +4482,10 @@ var LeaferUI = (function (exports) {
|
|
|
4453
4482
|
}
|
|
4454
4483
|
},
|
|
4455
4484
|
worldHittable(t) {
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
let { parent } = t;
|
|
4459
|
-
while (parent) {
|
|
4460
|
-
if (!parent.__.hittable || !parent.__.hitChildren)
|
|
4485
|
+
while (t) {
|
|
4486
|
+
if (!t.__.hittable)
|
|
4461
4487
|
return false;
|
|
4462
|
-
|
|
4488
|
+
t = t.parent;
|
|
4463
4489
|
}
|
|
4464
4490
|
return true;
|
|
4465
4491
|
},
|
|
@@ -7334,6 +7360,7 @@ var LeaferUI = (function (exports) {
|
|
|
7334
7360
|
view ? this.__createViewFrom(view) : this.__createView();
|
|
7335
7361
|
const { style } = this.view;
|
|
7336
7362
|
style.display || (style.display = 'block');
|
|
7363
|
+
style.userSelect = 'none';
|
|
7337
7364
|
this.parentView = this.view.parentElement;
|
|
7338
7365
|
if (Platform.syncDomFont && !this.parentView) {
|
|
7339
7366
|
this.view.style.display = 'none';
|
|
@@ -9188,11 +9215,12 @@ var LeaferUI = (function (exports) {
|
|
|
9188
9215
|
__updateBoxBounds() {
|
|
9189
9216
|
const data = this.__;
|
|
9190
9217
|
const layout = this.__layout;
|
|
9191
|
-
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
|
|
9218
|
+
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
9192
9219
|
const autoWidth = data.__autoWidth;
|
|
9193
9220
|
const autoHeight = data.__autoHeight;
|
|
9194
9221
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
9195
9222
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
9223
|
+
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
9196
9224
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
9197
9225
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
9198
9226
|
data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
|
|
@@ -9206,9 +9234,8 @@ var LeaferUI = (function (exports) {
|
|
|
9206
9234
|
b.y = autoHeight ? bounds.y : 0;
|
|
9207
9235
|
b.width = autoWidth ? bounds.width : data.width;
|
|
9208
9236
|
b.height = autoHeight ? bounds.height : data.height;
|
|
9209
|
-
const { padding } = data;
|
|
9210
9237
|
if (padding) {
|
|
9211
|
-
const [top, right, bottom, left] =
|
|
9238
|
+
const [top, right, bottom, left] = data.__padding;
|
|
9212
9239
|
if (autoWidth) {
|
|
9213
9240
|
b.x -= left;
|
|
9214
9241
|
b.width += (right + left);
|
|
@@ -9393,6 +9420,7 @@ var LeaferUI = (function (exports) {
|
|
|
9393
9420
|
get __tag() { return 'Leafer'; }
|
|
9394
9421
|
get isApp() { return false; }
|
|
9395
9422
|
get app() { return this.parent || this; }
|
|
9423
|
+
get imageReady() { return this.viewReady && ImageManager.isComplete; }
|
|
9396
9424
|
get layoutLocked() { return !this.layouter.running; }
|
|
9397
9425
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
9398
9426
|
constructor(userConfig, data) {
|
|
@@ -9595,23 +9623,26 @@ var LeaferUI = (function (exports) {
|
|
|
9595
9623
|
this.emitLeafer(LeaferEvent.VIEW_READY);
|
|
9596
9624
|
WaitHelper.run(this.__viewReadyWait);
|
|
9597
9625
|
}
|
|
9598
|
-
|
|
9599
|
-
if (
|
|
9600
|
-
this.
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
this.
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9626
|
+
__onAnimateFrame() {
|
|
9627
|
+
if (this.viewReady) {
|
|
9628
|
+
if (this.__nextRenderWait.length)
|
|
9629
|
+
WaitHelper.run(this.__nextRenderWait);
|
|
9630
|
+
const { imageReady } = this;
|
|
9631
|
+
if (imageReady && !this.viewCompleted)
|
|
9632
|
+
this.__checkViewCompleted();
|
|
9633
|
+
if (!imageReady)
|
|
9634
|
+
this.viewCompleted = false;
|
|
9635
|
+
}
|
|
9636
|
+
}
|
|
9637
|
+
__checkViewCompleted(emit = true) {
|
|
9638
|
+
this.nextRender(() => {
|
|
9639
|
+
if (this.imageReady) {
|
|
9640
|
+
if (emit)
|
|
9641
|
+
this.emitLeafer(LeaferEvent.VIEW_COMPLETED);
|
|
9642
|
+
WaitHelper.run(this.__viewCompletedWait);
|
|
9643
|
+
this.viewCompleted = true;
|
|
9644
|
+
}
|
|
9645
|
+
});
|
|
9615
9646
|
}
|
|
9616
9647
|
__onWatchData() {
|
|
9617
9648
|
if (this.watcher.childrenChanged && this.interaction) {
|
|
@@ -9625,22 +9656,17 @@ var LeaferUI = (function (exports) {
|
|
|
9625
9656
|
this.viewReady ? item() : this.__viewReadyWait.push(item);
|
|
9626
9657
|
}
|
|
9627
9658
|
waitViewCompleted(item) {
|
|
9659
|
+
this.__viewCompletedWait.push(item);
|
|
9628
9660
|
if (this.viewCompleted) {
|
|
9629
|
-
|
|
9661
|
+
this.__checkViewCompleted(false);
|
|
9630
9662
|
}
|
|
9631
9663
|
else {
|
|
9632
|
-
this.__viewCompletedWait.push(item);
|
|
9633
9664
|
if (!this.running)
|
|
9634
9665
|
this.start();
|
|
9635
9666
|
}
|
|
9636
9667
|
}
|
|
9637
9668
|
nextRender(item) {
|
|
9638
|
-
|
|
9639
|
-
item();
|
|
9640
|
-
}
|
|
9641
|
-
else {
|
|
9642
|
-
this.__nextRenderWait.push(item);
|
|
9643
|
-
}
|
|
9669
|
+
this.__nextRenderWait.push(item);
|
|
9644
9670
|
}
|
|
9645
9671
|
__checkUpdateLayout() {
|
|
9646
9672
|
this.__layout.update();
|
|
@@ -9653,7 +9679,8 @@ var LeaferUI = (function (exports) {
|
|
|
9653
9679
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
9654
9680
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
9655
9681
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
9656
|
-
this.
|
|
9682
|
+
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
9683
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(AnimateEvent.FRAME, this.__onAnimateFrame, this), this.on_(LayoutEvent.CHECK_UPDATE, this.__checkUpdateLayout, this));
|
|
9657
9684
|
}
|
|
9658
9685
|
__removeListenEvents() {
|
|
9659
9686
|
this.off_(this.__eventIds);
|
|
@@ -9780,9 +9807,6 @@ var LeaferUI = (function (exports) {
|
|
|
9780
9807
|
if (this.children.every(child => child.viewReady))
|
|
9781
9808
|
super.__onViewReady();
|
|
9782
9809
|
}
|
|
9783
|
-
__checkViewCompleted() {
|
|
9784
|
-
return this.children.every(item => item.viewCompleted);
|
|
9785
|
-
}
|
|
9786
9810
|
__onChildRenderEnd(e) {
|
|
9787
9811
|
this.renderer.addBlock(e.renderBounds);
|
|
9788
9812
|
if (this.viewReady)
|
|
@@ -9812,7 +9836,7 @@ var LeaferUI = (function (exports) {
|
|
|
9812
9836
|
__listenChildEvents(leafer) {
|
|
9813
9837
|
leafer.once(LayoutEvent.END, () => this.__onReady());
|
|
9814
9838
|
leafer.once(RenderEvent.START, () => this.__onCreated());
|
|
9815
|
-
leafer.once(RenderEvent.END, (
|
|
9839
|
+
leafer.once(RenderEvent.END, () => this.__onViewReady());
|
|
9816
9840
|
if (this.realCanvas)
|
|
9817
9841
|
this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
|
|
9818
9842
|
}
|
|
@@ -9878,7 +9902,7 @@ var LeaferUI = (function (exports) {
|
|
|
9878
9902
|
const { get: get$3, translate } = MatrixHelper;
|
|
9879
9903
|
function createData(leafPaint, image, paint, box) {
|
|
9880
9904
|
let { width, height } = image;
|
|
9881
|
-
const { opacity, mode, offset, scale, rotation, blendMode } = paint;
|
|
9905
|
+
const { opacity, mode, offset, scale, rotation, blendMode, repeat } = paint;
|
|
9882
9906
|
const sameBox = box.width === width && box.height === height;
|
|
9883
9907
|
if (blendMode)
|
|
9884
9908
|
leafPaint.blendMode = blendMode;
|
|
@@ -9899,6 +9923,8 @@ var LeaferUI = (function (exports) {
|
|
|
9899
9923
|
case 'repeat':
|
|
9900
9924
|
if (!sameBox || scale || rotation)
|
|
9901
9925
|
repeatMode(data, box, width, height, scale, rotation);
|
|
9926
|
+
if (!repeat)
|
|
9927
|
+
data.repeat = 'repeat';
|
|
9902
9928
|
break;
|
|
9903
9929
|
case 'fit':
|
|
9904
9930
|
case 'cover':
|
|
@@ -9910,6 +9936,8 @@ var LeaferUI = (function (exports) {
|
|
|
9910
9936
|
data.height = height;
|
|
9911
9937
|
if (opacity)
|
|
9912
9938
|
data.opacity = opacity;
|
|
9939
|
+
if (repeat)
|
|
9940
|
+
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
9913
9941
|
}
|
|
9914
9942
|
|
|
9915
9943
|
function image(ui, attrName, attrValue, box, firstUse) {
|
|
@@ -9956,11 +9984,11 @@ var LeaferUI = (function (exports) {
|
|
|
9956
9984
|
d.__naturalWidth = image.width;
|
|
9957
9985
|
d.__naturalHeight = image.height;
|
|
9958
9986
|
if (!d.__getInput('width') || !d.__getInput('height')) {
|
|
9987
|
+
ui.forceUpdate('width');
|
|
9959
9988
|
if (ui.__proxyData) {
|
|
9960
9989
|
ui.setProxyAttr('width', ui.__.width);
|
|
9961
9990
|
ui.setProxyAttr('height', ui.__.height);
|
|
9962
9991
|
}
|
|
9963
|
-
ui.forceUpdate('width');
|
|
9964
9992
|
return false;
|
|
9965
9993
|
}
|
|
9966
9994
|
}
|
|
@@ -9979,7 +10007,7 @@ var LeaferUI = (function (exports) {
|
|
|
9979
10007
|
scaleX = Math.abs(scaleX);
|
|
9980
10008
|
scaleY = Math.abs(scaleY);
|
|
9981
10009
|
const { image, data } = paint;
|
|
9982
|
-
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform,
|
|
10010
|
+
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
|
|
9983
10011
|
if (sx) {
|
|
9984
10012
|
imageMatrix = get$2();
|
|
9985
10013
|
copy$1(imageMatrix, transform);
|
|
@@ -9992,7 +10020,7 @@ var LeaferUI = (function (exports) {
|
|
|
9992
10020
|
width *= scaleX;
|
|
9993
10021
|
height *= scaleY;
|
|
9994
10022
|
const size = width * height;
|
|
9995
|
-
if (
|
|
10023
|
+
if (!repeat) {
|
|
9996
10024
|
if (size > Platform.image.maxCacheSize)
|
|
9997
10025
|
return false;
|
|
9998
10026
|
}
|
|
@@ -10022,7 +10050,7 @@ var LeaferUI = (function (exports) {
|
|
|
10022
10050
|
}
|
|
10023
10051
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10024
10052
|
}
|
|
10025
|
-
const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity),
|
|
10053
|
+
const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), repeat || (Platform.origin.noRepeat || 'no-repeat'));
|
|
10026
10054
|
try {
|
|
10027
10055
|
if (paint.transform)
|
|
10028
10056
|
paint.transform = null;
|
|
@@ -10050,7 +10078,7 @@ var LeaferUI = (function (exports) {
|
|
|
10050
10078
|
else {
|
|
10051
10079
|
const { data } = paint;
|
|
10052
10080
|
if (allowPaint) {
|
|
10053
|
-
if (data.
|
|
10081
|
+
if (!data.repeat) {
|
|
10054
10082
|
let { width, height } = data;
|
|
10055
10083
|
width *= abs(scaleX) * canvas.pixelRatio;
|
|
10056
10084
|
height *= abs(scaleY) * canvas.pixelRatio;
|
|
@@ -11050,6 +11078,7 @@ var LeaferUI = (function (exports) {
|
|
|
11050
11078
|
}
|
|
11051
11079
|
}
|
|
11052
11080
|
|
|
11081
|
+
const { top, right, bottom, left } = exports.Direction4;
|
|
11053
11082
|
const TextConvert = {
|
|
11054
11083
|
getDrawData(content, style) {
|
|
11055
11084
|
if (typeof content !== 'string')
|
|
@@ -11057,16 +11086,15 @@ var LeaferUI = (function (exports) {
|
|
|
11057
11086
|
let x = 0, y = 0;
|
|
11058
11087
|
let width = style.__getInput('width') || 0;
|
|
11059
11088
|
let height = style.__getInput('height') || 0;
|
|
11060
|
-
const { textDecoration, __font, padding } = style;
|
|
11089
|
+
const { textDecoration, __font, __padding: padding } = style;
|
|
11061
11090
|
if (padding) {
|
|
11062
|
-
const [top, right, bottom, left] = MathHelper.fourNumber(padding);
|
|
11063
11091
|
if (width) {
|
|
11064
|
-
x = left;
|
|
11065
|
-
width -= (right + left);
|
|
11092
|
+
x = padding[left];
|
|
11093
|
+
width -= (padding[right] + padding[left]);
|
|
11066
11094
|
}
|
|
11067
11095
|
if (height) {
|
|
11068
|
-
y = top;
|
|
11069
|
-
height -= (top + bottom);
|
|
11096
|
+
y = padding[top];
|
|
11097
|
+
height -= (padding[top] + padding[bottom]);
|
|
11070
11098
|
}
|
|
11071
11099
|
}
|
|
11072
11100
|
const drawData = {
|
|
@@ -11076,6 +11104,8 @@ var LeaferUI = (function (exports) {
|
|
|
11076
11104
|
font: Platform.canvas.font = __font
|
|
11077
11105
|
};
|
|
11078
11106
|
createRows(drawData, content, style);
|
|
11107
|
+
if (padding)
|
|
11108
|
+
padAutoText(padding, drawData, style, width, height);
|
|
11079
11109
|
layoutText(drawData, style);
|
|
11080
11110
|
layoutChar(drawData, style, width);
|
|
11081
11111
|
if (drawData.overflow)
|
|
@@ -11085,6 +11115,32 @@ var LeaferUI = (function (exports) {
|
|
|
11085
11115
|
return drawData;
|
|
11086
11116
|
}
|
|
11087
11117
|
};
|
|
11118
|
+
function padAutoText(padding, drawData, style, width, height) {
|
|
11119
|
+
if (!width) {
|
|
11120
|
+
switch (style.textAlign) {
|
|
11121
|
+
case 'left':
|
|
11122
|
+
offsetText(drawData, 'x', padding[left]);
|
|
11123
|
+
break;
|
|
11124
|
+
case 'right':
|
|
11125
|
+
offsetText(drawData, 'x', -padding[right]);
|
|
11126
|
+
}
|
|
11127
|
+
}
|
|
11128
|
+
if (!height) {
|
|
11129
|
+
switch (style.verticalAlign) {
|
|
11130
|
+
case 'top':
|
|
11131
|
+
offsetText(drawData, 'y', padding[top]);
|
|
11132
|
+
break;
|
|
11133
|
+
case 'bottom':
|
|
11134
|
+
offsetText(drawData, 'y', -padding[bottom]);
|
|
11135
|
+
}
|
|
11136
|
+
}
|
|
11137
|
+
}
|
|
11138
|
+
function offsetText(drawData, attrName, value) {
|
|
11139
|
+
const { bounds, rows } = drawData;
|
|
11140
|
+
bounds[attrName] += value;
|
|
11141
|
+
for (let i = 0; i < rows.length; i++)
|
|
11142
|
+
rows[i][attrName] += value;
|
|
11143
|
+
}
|
|
11088
11144
|
|
|
11089
11145
|
const ColorConvert = {
|
|
11090
11146
|
string(color, opacity) {
|