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