@leafer-ui/worker 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.cjs +33 -25
- package/dist/worker.esm.js +33 -25
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +89 -73
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +89 -73
- package/dist/worker.module.min.js +1 -1
- package/package.json +12 -12
package/dist/worker.js
CHANGED
|
@@ -4758,6 +4758,7 @@ var LeaferUI = (function (exports) {
|
|
|
4758
4758
|
}
|
|
4759
4759
|
}
|
|
4760
4760
|
RenderEvent.REQUEST = 'render.request';
|
|
4761
|
+
RenderEvent.CHILD_START = 'render.child_start';
|
|
4761
4762
|
RenderEvent.START = 'render.start';
|
|
4762
4763
|
RenderEvent.BEFORE = 'render.before';
|
|
4763
4764
|
RenderEvent.RENDER = 'render';
|
|
@@ -4933,7 +4934,7 @@ var LeaferUI = (function (exports) {
|
|
|
4933
4934
|
const debug$7 = Debug.get('setAttr');
|
|
4934
4935
|
const LeafDataProxy = {
|
|
4935
4936
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4936
|
-
if (this.
|
|
4937
|
+
if (this.leaferIsCreated) {
|
|
4937
4938
|
const oldValue = this.__.__getInput(name);
|
|
4938
4939
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4939
4940
|
debug$7.warn(this.innerName, name, newValue);
|
|
@@ -5005,7 +5006,7 @@ var LeaferUI = (function (exports) {
|
|
|
5005
5006
|
|
|
5006
5007
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5007
5008
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5008
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
5009
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
|
|
5009
5010
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
5010
5011
|
const LeafBounds = {
|
|
5011
5012
|
__updateWorldBounds() {
|
|
@@ -5088,7 +5089,7 @@ var LeaferUI = (function (exports) {
|
|
|
5088
5089
|
const b = this.__layout.boxBounds;
|
|
5089
5090
|
const data = this.__;
|
|
5090
5091
|
if (data.__pathInputed) {
|
|
5091
|
-
toBounds$2(data.
|
|
5092
|
+
toBounds$2(data.path, b);
|
|
5092
5093
|
}
|
|
5093
5094
|
else {
|
|
5094
5095
|
b.x = 0;
|
|
@@ -5100,7 +5101,7 @@ var LeaferUI = (function (exports) {
|
|
|
5100
5101
|
__updateAutoLayout() {
|
|
5101
5102
|
this.__layout.matrixChanged = true;
|
|
5102
5103
|
if (this.isBranch) {
|
|
5103
|
-
if (this.
|
|
5104
|
+
if (this.leaferIsReady)
|
|
5104
5105
|
this.leafer.layouter.addExtra(this);
|
|
5105
5106
|
if (this.__.flow) {
|
|
5106
5107
|
if (this.__layout.boxChanged)
|
|
@@ -5126,11 +5127,11 @@ var LeaferUI = (function (exports) {
|
|
|
5126
5127
|
},
|
|
5127
5128
|
__updateStrokeBounds() {
|
|
5128
5129
|
const layout = this.__layout;
|
|
5129
|
-
copyAndSpread$
|
|
5130
|
+
copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5130
5131
|
},
|
|
5131
5132
|
__updateRenderBounds() {
|
|
5132
5133
|
const layout = this.__layout;
|
|
5133
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5134
|
+
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5134
5135
|
}
|
|
5135
5136
|
};
|
|
5136
5137
|
|
|
@@ -5235,6 +5236,8 @@ var LeaferUI = (function (exports) {
|
|
|
5235
5236
|
get innerName() { return this.__.name || this.tag + this.innerId; }
|
|
5236
5237
|
get __DataProcessor() { return LeafData; }
|
|
5237
5238
|
get __LayoutProcessor() { return LeafLayout; }
|
|
5239
|
+
get leaferIsCreated() { return this.leafer && this.leafer.created; }
|
|
5240
|
+
get leaferIsReady() { return this.leafer && this.leafer.ready; }
|
|
5238
5241
|
get isLeafer() { return false; }
|
|
5239
5242
|
get isBranch() { return false; }
|
|
5240
5243
|
get isBranchLeaf() { return false; }
|
|
@@ -5676,6 +5679,7 @@ var LeaferUI = (function (exports) {
|
|
|
5676
5679
|
add(child, index) {
|
|
5677
5680
|
if (child === this)
|
|
5678
5681
|
return;
|
|
5682
|
+
child.__ || (child = UICreator.get(child.tag, child));
|
|
5679
5683
|
if (child.parent)
|
|
5680
5684
|
child.parent.remove(child);
|
|
5681
5685
|
child.parent = this;
|
|
@@ -5698,10 +5702,14 @@ var LeaferUI = (function (exports) {
|
|
|
5698
5702
|
}
|
|
5699
5703
|
remove(child, destroy) {
|
|
5700
5704
|
if (child) {
|
|
5701
|
-
if (child.
|
|
5702
|
-
|
|
5705
|
+
if (child.__) {
|
|
5706
|
+
if (child.animationOut)
|
|
5707
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5708
|
+
else
|
|
5709
|
+
this.__remove(child, destroy);
|
|
5710
|
+
}
|
|
5703
5711
|
else
|
|
5704
|
-
this.
|
|
5712
|
+
this.find(child).forEach(item => this.remove(item, destroy));
|
|
5705
5713
|
}
|
|
5706
5714
|
else if (child === undefined) {
|
|
5707
5715
|
super.remove(null, destroy);
|
|
@@ -5919,7 +5927,7 @@ var LeaferUI = (function (exports) {
|
|
|
5919
5927
|
}
|
|
5920
5928
|
}
|
|
5921
5929
|
|
|
5922
|
-
const version = "1.0.
|
|
5930
|
+
const version = "1.0.5";
|
|
5923
5931
|
|
|
5924
5932
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5925
5933
|
get allowBackgroundColor() { return true; }
|
|
@@ -6388,6 +6396,7 @@ var LeaferUI = (function (exports) {
|
|
|
6388
6396
|
this.totalBounds = new Bounds();
|
|
6389
6397
|
debug$5.log(target.innerName, '--->');
|
|
6390
6398
|
try {
|
|
6399
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6391
6400
|
this.emitRender(RenderEvent.START);
|
|
6392
6401
|
this.renderOnce(callback);
|
|
6393
6402
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6685,7 +6694,7 @@ var LeaferUI = (function (exports) {
|
|
|
6685
6694
|
if (child.isBranch) {
|
|
6686
6695
|
if (hit || child.__ignoreHitWorld) {
|
|
6687
6696
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
6688
|
-
if (child.isBranchLeaf
|
|
6697
|
+
if (child.isBranchLeaf)
|
|
6689
6698
|
this.hitChild(child, point);
|
|
6690
6699
|
}
|
|
6691
6700
|
}
|
|
@@ -7395,12 +7404,7 @@ var LeaferUI = (function (exports) {
|
|
|
7395
7404
|
this.__drawPathByData(canvas, this.__.path);
|
|
7396
7405
|
}
|
|
7397
7406
|
__drawPathByData(drawer, data) {
|
|
7398
|
-
|
|
7399
|
-
PathDrawer.drawPathByData(drawer, data);
|
|
7400
|
-
}
|
|
7401
|
-
else {
|
|
7402
|
-
this.__drawPathByBox(drawer);
|
|
7403
|
-
}
|
|
7407
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
7404
7408
|
}
|
|
7405
7409
|
__drawPathByBox(drawer) {
|
|
7406
7410
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
@@ -7408,9 +7412,8 @@ var LeaferUI = (function (exports) {
|
|
|
7408
7412
|
const { cornerRadius } = this.__;
|
|
7409
7413
|
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
7410
7414
|
}
|
|
7411
|
-
else
|
|
7415
|
+
else
|
|
7412
7416
|
drawer.rect(x, y, width, height);
|
|
7413
|
-
}
|
|
7414
7417
|
}
|
|
7415
7418
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7416
7419
|
return needPlugin('animate');
|
|
@@ -8093,10 +8096,9 @@ var LeaferUI = (function (exports) {
|
|
|
8093
8096
|
registerUI()
|
|
8094
8097
|
], exports.Rect);
|
|
8095
8098
|
|
|
8096
|
-
const
|
|
8097
|
-
const group$1 = exports.Group.prototype;
|
|
8099
|
+
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8100
|
+
const rect$1 = exports.Rect.prototype, group$1 = exports.Group.prototype;
|
|
8098
8101
|
const childrenRenderBounds = {};
|
|
8099
|
-
const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8100
8102
|
exports.Box = class Box extends exports.Group {
|
|
8101
8103
|
get __tag() { return 'Box'; }
|
|
8102
8104
|
get isBranchLeaf() { return true; }
|
|
@@ -8110,29 +8112,27 @@ var LeaferUI = (function (exports) {
|
|
|
8110
8112
|
return this.__updateRectRenderSpread() || -1;
|
|
8111
8113
|
}
|
|
8112
8114
|
__updateRectBoxBounds() { }
|
|
8113
|
-
__updateBoxBounds(
|
|
8115
|
+
__updateBoxBounds(_secondLayout) {
|
|
8114
8116
|
const data = this.__;
|
|
8115
8117
|
if (this.children.length) {
|
|
8116
8118
|
if (data.__autoSide) {
|
|
8117
|
-
if (this.leafer && this.leafer.ready)
|
|
8118
|
-
this.leafer.layouter.addExtra(this);
|
|
8119
8119
|
super.__updateBoxBounds();
|
|
8120
8120
|
const { boxBounds } = this.__layout;
|
|
8121
8121
|
if (!data.__autoSize) {
|
|
8122
|
-
if (data.__autoWidth)
|
|
8123
|
-
boxBounds.width += boxBounds.x, boxBounds.
|
|
8124
|
-
|
|
8125
|
-
|
|
8122
|
+
if (data.__autoWidth) {
|
|
8123
|
+
boxBounds.width += boxBounds.x, boxBounds.x = 0;
|
|
8124
|
+
boxBounds.height = data.height, boxBounds.y = 0;
|
|
8125
|
+
}
|
|
8126
|
+
else {
|
|
8127
|
+
boxBounds.height += boxBounds.y, boxBounds.y = 0;
|
|
8128
|
+
boxBounds.width = data.width, boxBounds.x = 0;
|
|
8129
|
+
}
|
|
8126
8130
|
}
|
|
8127
|
-
if (secondLayout && data.flow && data.padding)
|
|
8128
|
-
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8129
8131
|
this.__updateNaturalSize();
|
|
8130
8132
|
}
|
|
8131
8133
|
else {
|
|
8132
8134
|
this.__updateRectBoxBounds();
|
|
8133
8135
|
}
|
|
8134
|
-
if (data.flow)
|
|
8135
|
-
this.__updateContentBounds();
|
|
8136
8136
|
}
|
|
8137
8137
|
else {
|
|
8138
8138
|
this.__updateRectBoxBounds();
|
|
@@ -8198,6 +8198,9 @@ var LeaferUI = (function (exports) {
|
|
|
8198
8198
|
__decorate([
|
|
8199
8199
|
dataType(false)
|
|
8200
8200
|
], exports.Box.prototype, "resizeChildren", void 0);
|
|
8201
|
+
__decorate([
|
|
8202
|
+
dataType(false)
|
|
8203
|
+
], exports.Box.prototype, "textBox", void 0);
|
|
8201
8204
|
__decorate([
|
|
8202
8205
|
affectRenderBoundsType('show')
|
|
8203
8206
|
], exports.Box.prototype, "overflow", void 0);
|
|
@@ -8727,6 +8730,9 @@ var LeaferUI = (function (exports) {
|
|
|
8727
8730
|
__decorate([
|
|
8728
8731
|
boundsType('top')
|
|
8729
8732
|
], exports.Text.prototype, "verticalAlign", void 0);
|
|
8733
|
+
__decorate([
|
|
8734
|
+
boundsType(true)
|
|
8735
|
+
], exports.Text.prototype, "autoSizeAlign", void 0);
|
|
8730
8736
|
__decorate([
|
|
8731
8737
|
boundsType('normal')
|
|
8732
8738
|
], exports.Text.prototype, "textWrap", void 0);
|
|
@@ -9447,9 +9453,10 @@ var LeaferUI = (function (exports) {
|
|
|
9447
9453
|
this.dragData = getDragEventData(data, data, data);
|
|
9448
9454
|
this.canAnimate = this.canDragOut = true;
|
|
9449
9455
|
}
|
|
9450
|
-
getList() {
|
|
9456
|
+
getList(realDraggable, hover) {
|
|
9451
9457
|
const { proxy } = this.interaction.selector;
|
|
9452
|
-
|
|
9458
|
+
const hasProxyList = proxy && proxy.list.length, dragList = exports.DragEvent.list || this.draggableList || emptyList;
|
|
9459
|
+
return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
|
|
9453
9460
|
}
|
|
9454
9461
|
checkDrag(data, canDrag) {
|
|
9455
9462
|
const { interaction } = this;
|
|
@@ -9474,8 +9481,8 @@ var LeaferUI = (function (exports) {
|
|
|
9474
9481
|
this.dragging = canDrag && PointerButton.left(data);
|
|
9475
9482
|
if (this.dragging) {
|
|
9476
9483
|
this.interaction.emit(exports.DragEvent.START, this.dragData);
|
|
9477
|
-
this.
|
|
9478
|
-
this.setDragStartPoints(this.
|
|
9484
|
+
this.getDraggableList(this.dragData.path);
|
|
9485
|
+
this.setDragStartPoints(this.realDraggableList = this.getList(true));
|
|
9479
9486
|
}
|
|
9480
9487
|
}
|
|
9481
9488
|
}
|
|
@@ -9483,12 +9490,12 @@ var LeaferUI = (function (exports) {
|
|
|
9483
9490
|
this.dragStartPoints = {};
|
|
9484
9491
|
list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
|
|
9485
9492
|
}
|
|
9486
|
-
|
|
9493
|
+
getDraggableList(path) {
|
|
9487
9494
|
let leaf;
|
|
9488
9495
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
9489
9496
|
leaf = path.list[i];
|
|
9490
|
-
if ((leaf.
|
|
9491
|
-
this.
|
|
9497
|
+
if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
|
|
9498
|
+
this.draggableList = new LeafList(leaf);
|
|
9492
9499
|
break;
|
|
9493
9500
|
}
|
|
9494
9501
|
}
|
|
@@ -9513,7 +9520,7 @@ var LeaferUI = (function (exports) {
|
|
|
9513
9520
|
}
|
|
9514
9521
|
dragReal() {
|
|
9515
9522
|
const { running } = this.interaction;
|
|
9516
|
-
const list = this.
|
|
9523
|
+
const list = this.realDraggableList;
|
|
9517
9524
|
if (list.length && running) {
|
|
9518
9525
|
const { totalX, totalY } = this.dragData;
|
|
9519
9526
|
list.forEach(leaf => leaf.draggable && leaf.move(exports.DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
|
|
@@ -9602,7 +9609,7 @@ var LeaferUI = (function (exports) {
|
|
|
9602
9609
|
this.interaction.emit(exports.DragEvent.LEAVE, data, dragEnterPath);
|
|
9603
9610
|
}
|
|
9604
9611
|
dragReset() {
|
|
9605
|
-
exports.DragEvent.list = exports.DragEvent.data = this.
|
|
9612
|
+
exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
9606
9613
|
}
|
|
9607
9614
|
checkDragOut(data) {
|
|
9608
9615
|
const { interaction } = this;
|
|
@@ -9743,6 +9750,7 @@ var LeaferUI = (function (exports) {
|
|
|
9743
9750
|
touch: {
|
|
9744
9751
|
preventDefault: true
|
|
9745
9752
|
},
|
|
9753
|
+
multiTouch: {},
|
|
9746
9754
|
cursor: true,
|
|
9747
9755
|
keyEvent: true
|
|
9748
9756
|
};
|
|
@@ -9869,6 +9877,8 @@ var LeaferUI = (function (exports) {
|
|
|
9869
9877
|
this.pointerUp(data);
|
|
9870
9878
|
}
|
|
9871
9879
|
multiTouch(data, list) {
|
|
9880
|
+
if (this.config.multiTouch.disabled)
|
|
9881
|
+
return;
|
|
9872
9882
|
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
9873
9883
|
this.rotate(getRotateEventData(center, angle, data));
|
|
9874
9884
|
this.zoom(getZoomEventData(center, scale, data));
|
|
@@ -10058,7 +10068,7 @@ var LeaferUI = (function (exports) {
|
|
|
10058
10068
|
data = this.hoverData;
|
|
10059
10069
|
if (!data)
|
|
10060
10070
|
return;
|
|
10061
|
-
this.findPath(data, { exclude: this.dragger.getList(), name: exports.PointerEvent.MOVE });
|
|
10071
|
+
this.findPath(data, { exclude: this.dragger.getList(false, true), name: exports.PointerEvent.MOVE });
|
|
10062
10072
|
this.hoverData = data;
|
|
10063
10073
|
}
|
|
10064
10074
|
updateCursor(data) {
|
|
@@ -10080,7 +10090,7 @@ var LeaferUI = (function (exports) {
|
|
|
10080
10090
|
const { path } = data;
|
|
10081
10091
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
10082
10092
|
leaf = path.list[i];
|
|
10083
|
-
cursor = leaf.syncEventer
|
|
10093
|
+
cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
|
|
10084
10094
|
if (cursor)
|
|
10085
10095
|
break;
|
|
10086
10096
|
}
|
|
@@ -10262,7 +10272,7 @@ var LeaferUI = (function (exports) {
|
|
|
10262
10272
|
if (isHitPixel) {
|
|
10263
10273
|
const { renderBounds } = this.__layout;
|
|
10264
10274
|
const size = Platform.image.hitCanvasSize;
|
|
10265
|
-
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds
|
|
10275
|
+
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
10266
10276
|
const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
|
|
10267
10277
|
h.resize({ width, height, pixelRatio: 1 });
|
|
10268
10278
|
h.clear();
|
|
@@ -10318,15 +10328,14 @@ var LeaferUI = (function (exports) {
|
|
|
10318
10328
|
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
10319
10329
|
};
|
|
10320
10330
|
|
|
10321
|
-
const ui$1 =
|
|
10322
|
-
|
|
10323
|
-
rect.__updateHitCanvas = function () {
|
|
10331
|
+
const ui$1 = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
|
|
10332
|
+
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
10324
10333
|
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10325
10334
|
ui$1.__updateHitCanvas.call(this);
|
|
10326
10335
|
else if (this.__hitCanvas)
|
|
10327
10336
|
this.__hitCanvas = null;
|
|
10328
10337
|
};
|
|
10329
|
-
rect.__hitFill = function (inner) {
|
|
10338
|
+
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
10330
10339
|
return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10331
10340
|
};
|
|
10332
10341
|
|
|
@@ -10825,9 +10834,10 @@ var LeaferUI = (function (exports) {
|
|
|
10825
10834
|
onLoadError(ui, event, image.error);
|
|
10826
10835
|
}
|
|
10827
10836
|
else {
|
|
10828
|
-
|
|
10829
|
-
|
|
10837
|
+
if (firstUse) {
|
|
10838
|
+
ignoreRender(ui, true);
|
|
10830
10839
|
onLoad(ui, event);
|
|
10840
|
+
}
|
|
10831
10841
|
leafPaint.loadId = image.load(() => {
|
|
10832
10842
|
ignoreRender(ui, false);
|
|
10833
10843
|
if (!ui.destroyed) {
|
|
@@ -11439,11 +11449,12 @@ var LeaferUI = (function (exports) {
|
|
|
11439
11449
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
11440
11450
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
11441
11451
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
11442
|
-
let textDrawData, rows = [], bounds;
|
|
11452
|
+
let textDrawData, rows = [], bounds, findMaxWidth;
|
|
11443
11453
|
function createRows(drawData, content, style) {
|
|
11444
11454
|
textDrawData = drawData;
|
|
11445
11455
|
rows = drawData.rows;
|
|
11446
11456
|
bounds = drawData.bounds;
|
|
11457
|
+
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
11447
11458
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
11448
11459
|
const { canvas } = Platform;
|
|
11449
11460
|
const { width, height } = bounds;
|
|
@@ -11528,7 +11539,10 @@ var LeaferUI = (function (exports) {
|
|
|
11528
11539
|
else {
|
|
11529
11540
|
content.split('\n').forEach(content => {
|
|
11530
11541
|
textDrawData.paraNumber++;
|
|
11531
|
-
|
|
11542
|
+
rowWidth = canvas.measureText(content).width;
|
|
11543
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
11544
|
+
if (findMaxWidth)
|
|
11545
|
+
setMaxWidth();
|
|
11532
11546
|
});
|
|
11533
11547
|
}
|
|
11534
11548
|
}
|
|
@@ -11559,10 +11573,16 @@ var LeaferUI = (function (exports) {
|
|
|
11559
11573
|
row.width = rowWidth;
|
|
11560
11574
|
if (bounds.width)
|
|
11561
11575
|
trimRight(row);
|
|
11576
|
+
else if (findMaxWidth)
|
|
11577
|
+
setMaxWidth();
|
|
11562
11578
|
rows.push(row);
|
|
11563
11579
|
row = { words: [] };
|
|
11564
11580
|
rowWidth = 0;
|
|
11565
11581
|
}
|
|
11582
|
+
function setMaxWidth() {
|
|
11583
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
11584
|
+
textDrawData.maxWidth = rowWidth;
|
|
11585
|
+
}
|
|
11566
11586
|
|
|
11567
11587
|
const CharMode = 0;
|
|
11568
11588
|
const WordMode = 1;
|
|
@@ -11634,34 +11654,32 @@ var LeaferUI = (function (exports) {
|
|
|
11634
11654
|
|
|
11635
11655
|
function layoutText(drawData, style) {
|
|
11636
11656
|
const { rows, bounds } = drawData;
|
|
11637
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
11657
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
11638
11658
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
11639
11659
|
let starY = __baseLine;
|
|
11640
11660
|
if (__clipText && realHeight > height) {
|
|
11641
11661
|
realHeight = Math.max(height, __lineHeight);
|
|
11642
11662
|
drawData.overflow = rows.length;
|
|
11643
11663
|
}
|
|
11644
|
-
else {
|
|
11664
|
+
else if (height || autoSizeAlign) {
|
|
11645
11665
|
switch (verticalAlign) {
|
|
11646
11666
|
case 'middle':
|
|
11647
11667
|
y += (height - realHeight) / 2;
|
|
11648
11668
|
break;
|
|
11649
|
-
case 'bottom':
|
|
11650
|
-
y += (height - realHeight);
|
|
11669
|
+
case 'bottom': y += (height - realHeight);
|
|
11651
11670
|
}
|
|
11652
11671
|
}
|
|
11653
11672
|
starY += y;
|
|
11654
|
-
let row, rowX, rowWidth;
|
|
11673
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
11655
11674
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11656
11675
|
row = rows[i];
|
|
11657
11676
|
row.x = x;
|
|
11658
11677
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
11659
11678
|
switch (textAlign) {
|
|
11660
11679
|
case 'center':
|
|
11661
|
-
row.x += (
|
|
11680
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
11662
11681
|
break;
|
|
11663
|
-
case 'right':
|
|
11664
|
-
row.x += width - row.width;
|
|
11682
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
11665
11683
|
}
|
|
11666
11684
|
}
|
|
11667
11685
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -11766,14 +11784,14 @@ var LeaferUI = (function (exports) {
|
|
|
11766
11784
|
let height = style.__getInput('height') || 0;
|
|
11767
11785
|
const { textDecoration, __font, __padding: padding } = style;
|
|
11768
11786
|
if (padding) {
|
|
11769
|
-
if (width)
|
|
11787
|
+
if (width)
|
|
11788
|
+
x = padding[left], width -= (padding[right] + padding[left]);
|
|
11789
|
+
else if (!style.autoSizeAlign)
|
|
11770
11790
|
x = padding[left];
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
if (
|
|
11791
|
+
if (height)
|
|
11792
|
+
y = padding[top], height -= (padding[top] + padding[bottom]);
|
|
11793
|
+
else if (!style.autoSizeAlign)
|
|
11774
11794
|
y = padding[top];
|
|
11775
|
-
height -= (padding[top] + padding[bottom]);
|
|
11776
|
-
}
|
|
11777
11795
|
}
|
|
11778
11796
|
const drawData = {
|
|
11779
11797
|
bounds: { x, y, width, height },
|
|
@@ -11793,22 +11811,20 @@ var LeaferUI = (function (exports) {
|
|
|
11793
11811
|
return drawData;
|
|
11794
11812
|
}
|
|
11795
11813
|
function padAutoText(padding, drawData, style, width, height) {
|
|
11796
|
-
if (!width) {
|
|
11814
|
+
if (!width && style.autoSizeAlign) {
|
|
11797
11815
|
switch (style.textAlign) {
|
|
11798
11816
|
case 'left':
|
|
11799
11817
|
offsetText(drawData, 'x', padding[left]);
|
|
11800
11818
|
break;
|
|
11801
|
-
case 'right':
|
|
11802
|
-
offsetText(drawData, 'x', -padding[right]);
|
|
11819
|
+
case 'right': offsetText(drawData, 'x', -padding[right]);
|
|
11803
11820
|
}
|
|
11804
11821
|
}
|
|
11805
|
-
if (!height) {
|
|
11822
|
+
if (!height && style.autoSizeAlign) {
|
|
11806
11823
|
switch (style.verticalAlign) {
|
|
11807
11824
|
case 'top':
|
|
11808
11825
|
offsetText(drawData, 'y', padding[top]);
|
|
11809
11826
|
break;
|
|
11810
|
-
case 'bottom':
|
|
11811
|
-
offsetText(drawData, 'y', -padding[bottom]);
|
|
11827
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
|
|
11812
11828
|
}
|
|
11813
11829
|
}
|
|
11814
11830
|
}
|