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.module.js
CHANGED
|
@@ -101,14 +101,14 @@ const PI_2 = PI$4 / 2;
|
|
|
101
101
|
const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
|
|
102
102
|
const { float } = MathHelper;
|
|
103
103
|
const tempPoint$2 = {};
|
|
104
|
-
function get$
|
|
104
|
+
function get$6() {
|
|
105
105
|
return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
|
|
106
106
|
}
|
|
107
107
|
function getWorld() {
|
|
108
|
-
return Object.assign(Object.assign({}, get$
|
|
108
|
+
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 });
|
|
109
109
|
}
|
|
110
110
|
const MatrixHelper = {
|
|
111
|
-
defaultMatrix: get$
|
|
111
|
+
defaultMatrix: get$6(),
|
|
112
112
|
defaultWorld: getWorld(),
|
|
113
113
|
tempMatrix: {},
|
|
114
114
|
set(t, a = 1, b = 0, c = 0, d = 1, e = 0, f = 0) {
|
|
@@ -119,7 +119,7 @@ const MatrixHelper = {
|
|
|
119
119
|
t.e = e;
|
|
120
120
|
t.f = f;
|
|
121
121
|
},
|
|
122
|
-
get: get$
|
|
122
|
+
get: get$6,
|
|
123
123
|
getWorld,
|
|
124
124
|
copy(t, matrix) {
|
|
125
125
|
t.a = matrix.a;
|
|
@@ -682,7 +682,7 @@ const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
|
|
|
682
682
|
|
|
683
683
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
684
684
|
const { toOuterPoint: toOuterPoint$1 } = MatrixHelper;
|
|
685
|
-
let right, bottom, boundsRight, boundsBottom;
|
|
685
|
+
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
686
686
|
const point = {};
|
|
687
687
|
const toPoint$1 = {};
|
|
688
688
|
const BoundsHelper = {
|
|
@@ -825,16 +825,16 @@ const BoundsHelper = {
|
|
|
825
825
|
}
|
|
826
826
|
},
|
|
827
827
|
add(t, bounds) {
|
|
828
|
-
right = t.x + t.width;
|
|
829
|
-
bottom = t.y + t.height;
|
|
828
|
+
right$1 = t.x + t.width;
|
|
829
|
+
bottom$1 = t.y + t.height;
|
|
830
830
|
boundsRight = bounds.x + bounds.width;
|
|
831
831
|
boundsBottom = bounds.y + bounds.height;
|
|
832
|
-
right = right > boundsRight ? right : boundsRight;
|
|
833
|
-
bottom = bottom > boundsBottom ? bottom : boundsBottom;
|
|
832
|
+
right$1 = right$1 > boundsRight ? right$1 : boundsRight;
|
|
833
|
+
bottom$1 = bottom$1 > boundsBottom ? bottom$1 : boundsBottom;
|
|
834
834
|
t.x = t.x < bounds.x ? t.x : bounds.x;
|
|
835
835
|
t.y = t.y < bounds.y ? t.y : bounds.y;
|
|
836
|
-
t.width = right - t.x;
|
|
837
|
-
t.height = bottom - t.y;
|
|
836
|
+
t.width = right$1 - t.x;
|
|
837
|
+
t.height = bottom$1 - t.y;
|
|
838
838
|
},
|
|
839
839
|
addList(t, list) {
|
|
840
840
|
B.setListWithFn(t, list, undefined, true);
|
|
@@ -900,16 +900,16 @@ const BoundsHelper = {
|
|
|
900
900
|
if (otherMatrix)
|
|
901
901
|
other = B.tempToOuterOf(other, otherMatrix);
|
|
902
902
|
let { x, y, width, height } = other;
|
|
903
|
-
right = x + width;
|
|
904
|
-
bottom = y + height;
|
|
903
|
+
right$1 = x + width;
|
|
904
|
+
bottom$1 = y + height;
|
|
905
905
|
boundsRight = t.x + t.width;
|
|
906
906
|
boundsBottom = t.y + t.height;
|
|
907
907
|
x = x > t.x ? x : t.x;
|
|
908
908
|
y = y > t.y ? y : t.y;
|
|
909
|
-
right = right < boundsRight ? right : boundsRight;
|
|
910
|
-
bottom = bottom < boundsBottom ? bottom : boundsBottom;
|
|
911
|
-
width = right - x;
|
|
912
|
-
height = bottom - y;
|
|
909
|
+
right$1 = right$1 < boundsRight ? right$1 : boundsRight;
|
|
910
|
+
bottom$1 = bottom$1 < boundsBottom ? bottom$1 : boundsBottom;
|
|
911
|
+
width = right$1 - x;
|
|
912
|
+
height = bottom$1 - y;
|
|
913
913
|
return { x, y, width, height };
|
|
914
914
|
},
|
|
915
915
|
intersect(t, other, otherMatrix) {
|
|
@@ -1053,25 +1053,55 @@ class AutoBounds {
|
|
|
1053
1053
|
}
|
|
1054
1054
|
}
|
|
1055
1055
|
|
|
1056
|
-
|
|
1056
|
+
var Direction4;
|
|
1057
|
+
(function (Direction4) {
|
|
1058
|
+
Direction4[Direction4["top"] = 0] = "top";
|
|
1059
|
+
Direction4[Direction4["right"] = 1] = "right";
|
|
1060
|
+
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
1061
|
+
Direction4[Direction4["left"] = 3] = "left";
|
|
1062
|
+
})(Direction4 || (Direction4 = {}));
|
|
1063
|
+
var Direction9;
|
|
1064
|
+
(function (Direction9) {
|
|
1065
|
+
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
1066
|
+
Direction9[Direction9["top"] = 1] = "top";
|
|
1067
|
+
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
1068
|
+
Direction9[Direction9["right"] = 3] = "right";
|
|
1069
|
+
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
1070
|
+
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
1071
|
+
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
1072
|
+
Direction9[Direction9["left"] = 7] = "left";
|
|
1073
|
+
Direction9[Direction9["center"] = 8] = "center";
|
|
1074
|
+
})(Direction9 || (Direction9 = {}));
|
|
1075
|
+
|
|
1076
|
+
const directionData = [
|
|
1077
|
+
{ x: 0, y: 0 },
|
|
1078
|
+
{ x: 0.5, y: 0 },
|
|
1079
|
+
{ x: 1, y: 0 },
|
|
1080
|
+
{ x: 1, y: 0.5 },
|
|
1081
|
+
{ x: 1, y: 1 },
|
|
1082
|
+
{ x: 0.5, y: 1 },
|
|
1083
|
+
{ x: 0, y: 1 },
|
|
1084
|
+
{ x: 0, y: 0.5 },
|
|
1085
|
+
{ x: 0.5, y: 0.5 }
|
|
1086
|
+
];
|
|
1057
1087
|
const AroundHelper = {
|
|
1058
|
-
|
|
1088
|
+
directionData,
|
|
1059
1089
|
tempPoint: {},
|
|
1090
|
+
get: get$5,
|
|
1060
1091
|
toPoint(around, bounds, to, onlySize) {
|
|
1061
1092
|
to || (to = {});
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
break;
|
|
1066
|
-
}
|
|
1067
|
-
to.x = around.x * bounds.width;
|
|
1068
|
-
to.y = around.y * bounds.height;
|
|
1093
|
+
const point = get$5(around);
|
|
1094
|
+
to.x = point.x * bounds.width;
|
|
1095
|
+
to.y = point.y * bounds.height;
|
|
1069
1096
|
if (!onlySize) {
|
|
1070
1097
|
to.x += bounds.x;
|
|
1071
1098
|
to.y += bounds.y;
|
|
1072
1099
|
}
|
|
1073
1100
|
}
|
|
1074
1101
|
};
|
|
1102
|
+
function get$5(around) {
|
|
1103
|
+
return typeof around === 'string' ? directionData[Direction9[around]] : around;
|
|
1104
|
+
}
|
|
1075
1105
|
|
|
1076
1106
|
const StringNumberMap = {
|
|
1077
1107
|
'0': 1,
|
|
@@ -3086,7 +3116,6 @@ const PathScaler = {
|
|
|
3086
3116
|
break;
|
|
3087
3117
|
case G$1:
|
|
3088
3118
|
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3089
|
-
console.log('G');
|
|
3090
3119
|
i += 9;
|
|
3091
3120
|
break;
|
|
3092
3121
|
case F$1:
|
|
@@ -3801,7 +3830,7 @@ LayoutEvent.CHECK_UPDATE = 'layout.check_update';
|
|
|
3801
3830
|
LayoutEvent.REQUEST = 'layout.request';
|
|
3802
3831
|
LayoutEvent.START = 'layout.start';
|
|
3803
3832
|
LayoutEvent.BEFORE = 'layout.before';
|
|
3804
|
-
LayoutEvent.LAYOUT = 'layout
|
|
3833
|
+
LayoutEvent.LAYOUT = 'layout';
|
|
3805
3834
|
LayoutEvent.AFTER = 'layout.after';
|
|
3806
3835
|
LayoutEvent.AGAIN = 'layout.again';
|
|
3807
3836
|
LayoutEvent.END = 'layout.end';
|
|
@@ -4450,13 +4479,10 @@ const LeafHelper = {
|
|
|
4450
4479
|
}
|
|
4451
4480
|
},
|
|
4452
4481
|
worldHittable(t) {
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
let { parent } = t;
|
|
4456
|
-
while (parent) {
|
|
4457
|
-
if (!parent.__.hittable || !parent.__.hitChildren)
|
|
4482
|
+
while (t) {
|
|
4483
|
+
if (!t.__.hittable)
|
|
4458
4484
|
return false;
|
|
4459
|
-
|
|
4485
|
+
t = t.parent;
|
|
4460
4486
|
}
|
|
4461
4487
|
return true;
|
|
4462
4488
|
},
|
|
@@ -7331,6 +7357,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
7331
7357
|
view ? this.__createViewFrom(view) : this.__createView();
|
|
7332
7358
|
const { style } = this.view;
|
|
7333
7359
|
style.display || (style.display = 'block');
|
|
7360
|
+
style.userSelect = 'none';
|
|
7334
7361
|
this.parentView = this.view.parentElement;
|
|
7335
7362
|
if (Platform.syncDomFont && !this.parentView) {
|
|
7336
7363
|
this.view.style.display = 'none';
|
|
@@ -9185,11 +9212,12 @@ let Text = class Text extends UI {
|
|
|
9185
9212
|
__updateBoxBounds() {
|
|
9186
9213
|
const data = this.__;
|
|
9187
9214
|
const layout = this.__layout;
|
|
9188
|
-
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
|
|
9215
|
+
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
9189
9216
|
const autoWidth = data.__autoWidth;
|
|
9190
9217
|
const autoHeight = data.__autoHeight;
|
|
9191
9218
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
9192
9219
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
9220
|
+
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
9193
9221
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
9194
9222
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
9195
9223
|
data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
|
|
@@ -9203,9 +9231,8 @@ let Text = class Text extends UI {
|
|
|
9203
9231
|
b.y = autoHeight ? bounds.y : 0;
|
|
9204
9232
|
b.width = autoWidth ? bounds.width : data.width;
|
|
9205
9233
|
b.height = autoHeight ? bounds.height : data.height;
|
|
9206
|
-
const { padding } = data;
|
|
9207
9234
|
if (padding) {
|
|
9208
|
-
const [top, right, bottom, left] =
|
|
9235
|
+
const [top, right, bottom, left] = data.__padding;
|
|
9209
9236
|
if (autoWidth) {
|
|
9210
9237
|
b.x -= left;
|
|
9211
9238
|
b.width += (right + left);
|
|
@@ -9390,6 +9417,7 @@ let Leafer = class Leafer extends Group {
|
|
|
9390
9417
|
get __tag() { return 'Leafer'; }
|
|
9391
9418
|
get isApp() { return false; }
|
|
9392
9419
|
get app() { return this.parent || this; }
|
|
9420
|
+
get imageReady() { return this.viewReady && ImageManager.isComplete; }
|
|
9393
9421
|
get layoutLocked() { return !this.layouter.running; }
|
|
9394
9422
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
9395
9423
|
constructor(userConfig, data) {
|
|
@@ -9592,23 +9620,26 @@ let Leafer = class Leafer extends Group {
|
|
|
9592
9620
|
this.emitLeafer(LeaferEvent.VIEW_READY);
|
|
9593
9621
|
WaitHelper.run(this.__viewReadyWait);
|
|
9594
9622
|
}
|
|
9595
|
-
|
|
9596
|
-
if (
|
|
9597
|
-
this.
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
this.
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9623
|
+
__onAnimateFrame() {
|
|
9624
|
+
if (this.viewReady) {
|
|
9625
|
+
if (this.__nextRenderWait.length)
|
|
9626
|
+
WaitHelper.run(this.__nextRenderWait);
|
|
9627
|
+
const { imageReady } = this;
|
|
9628
|
+
if (imageReady && !this.viewCompleted)
|
|
9629
|
+
this.__checkViewCompleted();
|
|
9630
|
+
if (!imageReady)
|
|
9631
|
+
this.viewCompleted = false;
|
|
9632
|
+
}
|
|
9633
|
+
}
|
|
9634
|
+
__checkViewCompleted(emit = true) {
|
|
9635
|
+
this.nextRender(() => {
|
|
9636
|
+
if (this.imageReady) {
|
|
9637
|
+
if (emit)
|
|
9638
|
+
this.emitLeafer(LeaferEvent.VIEW_COMPLETED);
|
|
9639
|
+
WaitHelper.run(this.__viewCompletedWait);
|
|
9640
|
+
this.viewCompleted = true;
|
|
9641
|
+
}
|
|
9642
|
+
});
|
|
9612
9643
|
}
|
|
9613
9644
|
__onWatchData() {
|
|
9614
9645
|
if (this.watcher.childrenChanged && this.interaction) {
|
|
@@ -9622,22 +9653,17 @@ let Leafer = class Leafer extends Group {
|
|
|
9622
9653
|
this.viewReady ? item() : this.__viewReadyWait.push(item);
|
|
9623
9654
|
}
|
|
9624
9655
|
waitViewCompleted(item) {
|
|
9656
|
+
this.__viewCompletedWait.push(item);
|
|
9625
9657
|
if (this.viewCompleted) {
|
|
9626
|
-
|
|
9658
|
+
this.__checkViewCompleted(false);
|
|
9627
9659
|
}
|
|
9628
9660
|
else {
|
|
9629
|
-
this.__viewCompletedWait.push(item);
|
|
9630
9661
|
if (!this.running)
|
|
9631
9662
|
this.start();
|
|
9632
9663
|
}
|
|
9633
9664
|
}
|
|
9634
9665
|
nextRender(item) {
|
|
9635
|
-
|
|
9636
|
-
item();
|
|
9637
|
-
}
|
|
9638
|
-
else {
|
|
9639
|
-
this.__nextRenderWait.push(item);
|
|
9640
|
-
}
|
|
9666
|
+
this.__nextRenderWait.push(item);
|
|
9641
9667
|
}
|
|
9642
9668
|
__checkUpdateLayout() {
|
|
9643
9669
|
this.__layout.update();
|
|
@@ -9650,7 +9676,8 @@ let Leafer = class Leafer extends Group {
|
|
|
9650
9676
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
9651
9677
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
9652
9678
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
9653
|
-
this.
|
|
9679
|
+
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
9680
|
+
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));
|
|
9654
9681
|
}
|
|
9655
9682
|
__removeListenEvents() {
|
|
9656
9683
|
this.off_(this.__eventIds);
|
|
@@ -9777,9 +9804,6 @@ let App = class App extends Leafer {
|
|
|
9777
9804
|
if (this.children.every(child => child.viewReady))
|
|
9778
9805
|
super.__onViewReady();
|
|
9779
9806
|
}
|
|
9780
|
-
__checkViewCompleted() {
|
|
9781
|
-
return this.children.every(item => item.viewCompleted);
|
|
9782
|
-
}
|
|
9783
9807
|
__onChildRenderEnd(e) {
|
|
9784
9808
|
this.renderer.addBlock(e.renderBounds);
|
|
9785
9809
|
if (this.viewReady)
|
|
@@ -9809,7 +9833,7 @@ let App = class App extends Leafer {
|
|
|
9809
9833
|
__listenChildEvents(leafer) {
|
|
9810
9834
|
leafer.once(LayoutEvent.END, () => this.__onReady());
|
|
9811
9835
|
leafer.once(RenderEvent.START, () => this.__onCreated());
|
|
9812
|
-
leafer.once(RenderEvent.END, (
|
|
9836
|
+
leafer.once(RenderEvent.END, () => this.__onViewReady());
|
|
9813
9837
|
if (this.realCanvas)
|
|
9814
9838
|
this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
|
|
9815
9839
|
}
|
|
@@ -9875,7 +9899,7 @@ function repeatMode(data, box, width, height, scale, rotation) {
|
|
|
9875
9899
|
const { get: get$3, translate } = MatrixHelper;
|
|
9876
9900
|
function createData(leafPaint, image, paint, box) {
|
|
9877
9901
|
let { width, height } = image;
|
|
9878
|
-
const { opacity, mode, offset, scale, rotation, blendMode } = paint;
|
|
9902
|
+
const { opacity, mode, offset, scale, rotation, blendMode, repeat } = paint;
|
|
9879
9903
|
const sameBox = box.width === width && box.height === height;
|
|
9880
9904
|
if (blendMode)
|
|
9881
9905
|
leafPaint.blendMode = blendMode;
|
|
@@ -9896,6 +9920,8 @@ function createData(leafPaint, image, paint, box) {
|
|
|
9896
9920
|
case 'repeat':
|
|
9897
9921
|
if (!sameBox || scale || rotation)
|
|
9898
9922
|
repeatMode(data, box, width, height, scale, rotation);
|
|
9923
|
+
if (!repeat)
|
|
9924
|
+
data.repeat = 'repeat';
|
|
9899
9925
|
break;
|
|
9900
9926
|
case 'fit':
|
|
9901
9927
|
case 'cover':
|
|
@@ -9907,6 +9933,8 @@ function createData(leafPaint, image, paint, box) {
|
|
|
9907
9933
|
data.height = height;
|
|
9908
9934
|
if (opacity)
|
|
9909
9935
|
data.opacity = opacity;
|
|
9936
|
+
if (repeat)
|
|
9937
|
+
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
9910
9938
|
}
|
|
9911
9939
|
|
|
9912
9940
|
function image(ui, attrName, attrValue, box, firstUse) {
|
|
@@ -9953,11 +9981,11 @@ function hasNaturalSize(ui, attrName, image) {
|
|
|
9953
9981
|
d.__naturalWidth = image.width;
|
|
9954
9982
|
d.__naturalHeight = image.height;
|
|
9955
9983
|
if (!d.__getInput('width') || !d.__getInput('height')) {
|
|
9984
|
+
ui.forceUpdate('width');
|
|
9956
9985
|
if (ui.__proxyData) {
|
|
9957
9986
|
ui.setProxyAttr('width', ui.__.width);
|
|
9958
9987
|
ui.setProxyAttr('height', ui.__.height);
|
|
9959
9988
|
}
|
|
9960
|
-
ui.forceUpdate('width');
|
|
9961
9989
|
return false;
|
|
9962
9990
|
}
|
|
9963
9991
|
}
|
|
@@ -9976,7 +10004,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
9976
10004
|
scaleX = Math.abs(scaleX);
|
|
9977
10005
|
scaleY = Math.abs(scaleY);
|
|
9978
10006
|
const { image, data } = paint;
|
|
9979
|
-
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform,
|
|
10007
|
+
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
|
|
9980
10008
|
if (sx) {
|
|
9981
10009
|
imageMatrix = get$2();
|
|
9982
10010
|
copy$1(imageMatrix, transform);
|
|
@@ -9989,7 +10017,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
9989
10017
|
width *= scaleX;
|
|
9990
10018
|
height *= scaleY;
|
|
9991
10019
|
const size = width * height;
|
|
9992
|
-
if (
|
|
10020
|
+
if (!repeat) {
|
|
9993
10021
|
if (size > Platform.image.maxCacheSize)
|
|
9994
10022
|
return false;
|
|
9995
10023
|
}
|
|
@@ -10019,7 +10047,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
10019
10047
|
}
|
|
10020
10048
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10021
10049
|
}
|
|
10022
|
-
const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity),
|
|
10050
|
+
const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), repeat || (Platform.origin.noRepeat || 'no-repeat'));
|
|
10023
10051
|
try {
|
|
10024
10052
|
if (paint.transform)
|
|
10025
10053
|
paint.transform = null;
|
|
@@ -10047,7 +10075,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
10047
10075
|
else {
|
|
10048
10076
|
const { data } = paint;
|
|
10049
10077
|
if (allowPaint) {
|
|
10050
|
-
if (data.
|
|
10078
|
+
if (!data.repeat) {
|
|
10051
10079
|
let { width, height } = data;
|
|
10052
10080
|
width *= abs(scaleX) * canvas.pixelRatio;
|
|
10053
10081
|
height *= abs(scaleY) * canvas.pixelRatio;
|
|
@@ -11047,6 +11075,7 @@ function decorationText(drawData, style) {
|
|
|
11047
11075
|
}
|
|
11048
11076
|
}
|
|
11049
11077
|
|
|
11078
|
+
const { top, right, bottom, left } = Direction4;
|
|
11050
11079
|
const TextConvert = {
|
|
11051
11080
|
getDrawData(content, style) {
|
|
11052
11081
|
if (typeof content !== 'string')
|
|
@@ -11054,16 +11083,15 @@ const TextConvert = {
|
|
|
11054
11083
|
let x = 0, y = 0;
|
|
11055
11084
|
let width = style.__getInput('width') || 0;
|
|
11056
11085
|
let height = style.__getInput('height') || 0;
|
|
11057
|
-
const { textDecoration, __font, padding } = style;
|
|
11086
|
+
const { textDecoration, __font, __padding: padding } = style;
|
|
11058
11087
|
if (padding) {
|
|
11059
|
-
const [top, right, bottom, left] = MathHelper.fourNumber(padding);
|
|
11060
11088
|
if (width) {
|
|
11061
|
-
x = left;
|
|
11062
|
-
width -= (right + left);
|
|
11089
|
+
x = padding[left];
|
|
11090
|
+
width -= (padding[right] + padding[left]);
|
|
11063
11091
|
}
|
|
11064
11092
|
if (height) {
|
|
11065
|
-
y = top;
|
|
11066
|
-
height -= (top + bottom);
|
|
11093
|
+
y = padding[top];
|
|
11094
|
+
height -= (padding[top] + padding[bottom]);
|
|
11067
11095
|
}
|
|
11068
11096
|
}
|
|
11069
11097
|
const drawData = {
|
|
@@ -11073,6 +11101,8 @@ const TextConvert = {
|
|
|
11073
11101
|
font: Platform.canvas.font = __font
|
|
11074
11102
|
};
|
|
11075
11103
|
createRows(drawData, content, style);
|
|
11104
|
+
if (padding)
|
|
11105
|
+
padAutoText(padding, drawData, style, width, height);
|
|
11076
11106
|
layoutText(drawData, style);
|
|
11077
11107
|
layoutChar(drawData, style, width);
|
|
11078
11108
|
if (drawData.overflow)
|
|
@@ -11082,6 +11112,32 @@ const TextConvert = {
|
|
|
11082
11112
|
return drawData;
|
|
11083
11113
|
}
|
|
11084
11114
|
};
|
|
11115
|
+
function padAutoText(padding, drawData, style, width, height) {
|
|
11116
|
+
if (!width) {
|
|
11117
|
+
switch (style.textAlign) {
|
|
11118
|
+
case 'left':
|
|
11119
|
+
offsetText(drawData, 'x', padding[left]);
|
|
11120
|
+
break;
|
|
11121
|
+
case 'right':
|
|
11122
|
+
offsetText(drawData, 'x', -padding[right]);
|
|
11123
|
+
}
|
|
11124
|
+
}
|
|
11125
|
+
if (!height) {
|
|
11126
|
+
switch (style.verticalAlign) {
|
|
11127
|
+
case 'top':
|
|
11128
|
+
offsetText(drawData, 'y', padding[top]);
|
|
11129
|
+
break;
|
|
11130
|
+
case 'bottom':
|
|
11131
|
+
offsetText(drawData, 'y', -padding[bottom]);
|
|
11132
|
+
}
|
|
11133
|
+
}
|
|
11134
|
+
}
|
|
11135
|
+
function offsetText(drawData, attrName, value) {
|
|
11136
|
+
const { bounds, rows } = drawData;
|
|
11137
|
+
bounds[attrName] += value;
|
|
11138
|
+
for (let i = 0; i < rows.length; i++)
|
|
11139
|
+
rows[i][attrName] += value;
|
|
11140
|
+
}
|
|
11085
11141
|
|
|
11086
11142
|
const ColorConvert = {
|
|
11087
11143
|
string(color, opacity) {
|
|
@@ -11165,4 +11221,4 @@ Object.assign(Export$1, Export);
|
|
|
11165
11221
|
|
|
11166
11222
|
useCanvas();
|
|
11167
11223
|
|
|
11168
|
-
export { Animate, AnimateEvent, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIHit, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useCanvas, useModule, usePlugin };
|
|
11224
|
+
export { Animate, AnimateEvent, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIHit, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useCanvas, useModule, usePlugin };
|