leafer-ui 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/web.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$8 = Debug.get('setAttr');
4934
4935
  const LeafDataProxy = {
4935
4936
  __setAttr(name, newValue, checkFiniteNumber) {
4936
- if (this.leafer && this.leafer.created) {
4937
+ if (this.leaferIsCreated) {
4937
4938
  const oldValue = this.__.__getInput(name);
4938
4939
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4939
4940
  debug$8.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$2, copy: copy$5 } = BoundsHelper;
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.__pathForRender, b);
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.leafer && this.leafer.ready)
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$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
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$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);
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.animationOut)
5702
- 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
+ }
5703
5711
  else
5704
- this.__remove(child, destroy);
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.4";
5930
+ const version = "1.0.5";
5923
5931
 
5924
5932
  const debug$7 = Debug.get('LeaferCanvas');
5925
5933
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6561,6 +6569,7 @@ var LeaferUI = (function (exports) {
6561
6569
  this.totalBounds = new Bounds();
6562
6570
  debug$5.log(target.innerName, '--->');
6563
6571
  try {
6572
+ target.app.emit(RenderEvent.CHILD_START, target);
6564
6573
  this.emitRender(RenderEvent.START);
6565
6574
  this.renderOnce(callback);
6566
6575
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6858,7 +6867,7 @@ var LeaferUI = (function (exports) {
6858
6867
  if (child.isBranch) {
6859
6868
  if (hit || child.__ignoreHitWorld) {
6860
6869
  this.eachFind(child.children, child.__onlyHitMask);
6861
- if (child.isBranchLeaf && !this.findList.length)
6870
+ if (child.isBranchLeaf)
6862
6871
  this.hitChild(child, point);
6863
6872
  }
6864
6873
  }
@@ -7568,12 +7577,7 @@ var LeaferUI = (function (exports) {
7568
7577
  this.__drawPathByData(canvas, this.__.path);
7569
7578
  }
7570
7579
  __drawPathByData(drawer, data) {
7571
- if (data) {
7572
- PathDrawer.drawPathByData(drawer, data);
7573
- }
7574
- else {
7575
- this.__drawPathByBox(drawer);
7576
- }
7580
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
7577
7581
  }
7578
7582
  __drawPathByBox(drawer) {
7579
7583
  const { x, y, width, height } = this.__layout.boxBounds;
@@ -7581,9 +7585,8 @@ var LeaferUI = (function (exports) {
7581
7585
  const { cornerRadius } = this.__;
7582
7586
  drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7583
7587
  }
7584
- else {
7588
+ else
7585
7589
  drawer.rect(x, y, width, height);
7586
- }
7587
7590
  }
7588
7591
  animate(_keyframe, _options, _type, _isTemp) {
7589
7592
  return needPlugin('animate');
@@ -8266,10 +8269,9 @@ var LeaferUI = (function (exports) {
8266
8269
  registerUI()
8267
8270
  ], exports.Rect);
8268
8271
 
8269
- const rect$1 = exports.Rect.prototype;
8270
- const group$1 = exports.Group.prototype;
8272
+ const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
8273
+ const rect$1 = exports.Rect.prototype, group$1 = exports.Group.prototype;
8271
8274
  const childrenRenderBounds = {};
8272
- const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
8273
8275
  exports.Box = class Box extends exports.Group {
8274
8276
  get __tag() { return 'Box'; }
8275
8277
  get isBranchLeaf() { return true; }
@@ -8283,29 +8285,27 @@ var LeaferUI = (function (exports) {
8283
8285
  return this.__updateRectRenderSpread() || -1;
8284
8286
  }
8285
8287
  __updateRectBoxBounds() { }
8286
- __updateBoxBounds(secondLayout) {
8288
+ __updateBoxBounds(_secondLayout) {
8287
8289
  const data = this.__;
8288
8290
  if (this.children.length) {
8289
8291
  if (data.__autoSide) {
8290
- if (this.leafer && this.leafer.ready)
8291
- this.leafer.layouter.addExtra(this);
8292
8292
  super.__updateBoxBounds();
8293
8293
  const { boxBounds } = this.__layout;
8294
8294
  if (!data.__autoSize) {
8295
- if (data.__autoWidth)
8296
- boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
8297
- else
8298
- boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
8295
+ if (data.__autoWidth) {
8296
+ boxBounds.width += boxBounds.x, boxBounds.x = 0;
8297
+ boxBounds.height = data.height, boxBounds.y = 0;
8298
+ }
8299
+ else {
8300
+ boxBounds.height += boxBounds.y, boxBounds.y = 0;
8301
+ boxBounds.width = data.width, boxBounds.x = 0;
8302
+ }
8299
8303
  }
8300
- if (secondLayout && data.flow && data.padding)
8301
- copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
8302
8304
  this.__updateNaturalSize();
8303
8305
  }
8304
8306
  else {
8305
8307
  this.__updateRectBoxBounds();
8306
8308
  }
8307
- if (data.flow)
8308
- this.__updateContentBounds();
8309
8309
  }
8310
8310
  else {
8311
8311
  this.__updateRectBoxBounds();
@@ -8371,6 +8371,9 @@ var LeaferUI = (function (exports) {
8371
8371
  __decorate([
8372
8372
  dataType(false)
8373
8373
  ], exports.Box.prototype, "resizeChildren", void 0);
8374
+ __decorate([
8375
+ dataType(false)
8376
+ ], exports.Box.prototype, "textBox", void 0);
8374
8377
  __decorate([
8375
8378
  affectRenderBoundsType('show')
8376
8379
  ], exports.Box.prototype, "overflow", void 0);
@@ -8900,6 +8903,9 @@ var LeaferUI = (function (exports) {
8900
8903
  __decorate([
8901
8904
  boundsType('top')
8902
8905
  ], exports.Text.prototype, "verticalAlign", void 0);
8906
+ __decorate([
8907
+ boundsType(true)
8908
+ ], exports.Text.prototype, "autoSizeAlign", void 0);
8903
8909
  __decorate([
8904
8910
  boundsType('normal')
8905
8911
  ], exports.Text.prototype, "textWrap", void 0);
@@ -9620,9 +9626,10 @@ var LeaferUI = (function (exports) {
9620
9626
  this.dragData = getDragEventData(data, data, data);
9621
9627
  this.canAnimate = this.canDragOut = true;
9622
9628
  }
9623
- getList() {
9629
+ getList(realDraggable, hover) {
9624
9630
  const { proxy } = this.interaction.selector;
9625
- return this.dragging && (!proxy || !proxy.list.length) ? (exports.DragEvent.list || this.dragableList || emptyList) : emptyList;
9631
+ const hasProxyList = proxy && proxy.list.length, dragList = exports.DragEvent.list || this.draggableList || emptyList;
9632
+ return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
9626
9633
  }
9627
9634
  checkDrag(data, canDrag) {
9628
9635
  const { interaction } = this;
@@ -9647,8 +9654,8 @@ var LeaferUI = (function (exports) {
9647
9654
  this.dragging = canDrag && PointerButton.left(data);
9648
9655
  if (this.dragging) {
9649
9656
  this.interaction.emit(exports.DragEvent.START, this.dragData);
9650
- this.getDragableList(this.dragData.path);
9651
- this.setDragStartPoints(this.realDragableList = this.getList());
9657
+ this.getDraggableList(this.dragData.path);
9658
+ this.setDragStartPoints(this.realDraggableList = this.getList(true));
9652
9659
  }
9653
9660
  }
9654
9661
  }
@@ -9656,12 +9663,12 @@ var LeaferUI = (function (exports) {
9656
9663
  this.dragStartPoints = {};
9657
9664
  list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9658
9665
  }
9659
- getDragableList(path) {
9666
+ getDraggableList(path) {
9660
9667
  let leaf;
9661
9668
  for (let i = 0, len = path.length; i < len; i++) {
9662
9669
  leaf = path.list[i];
9663
- if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
9664
- this.dragableList = new LeafList(leaf);
9670
+ if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
9671
+ this.draggableList = new LeafList(leaf);
9665
9672
  break;
9666
9673
  }
9667
9674
  }
@@ -9686,7 +9693,7 @@ var LeaferUI = (function (exports) {
9686
9693
  }
9687
9694
  dragReal() {
9688
9695
  const { running } = this.interaction;
9689
- const list = this.realDragableList;
9696
+ const list = this.realDraggableList;
9690
9697
  if (list.length && running) {
9691
9698
  const { totalX, totalY } = this.dragData;
9692
9699
  list.forEach(leaf => leaf.draggable && leaf.move(exports.DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
@@ -9775,7 +9782,7 @@ var LeaferUI = (function (exports) {
9775
9782
  this.interaction.emit(exports.DragEvent.LEAVE, data, dragEnterPath);
9776
9783
  }
9777
9784
  dragReset() {
9778
- exports.DragEvent.list = exports.DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9785
+ exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9779
9786
  }
9780
9787
  checkDragOut(data) {
9781
9788
  const { interaction } = this;
@@ -9916,6 +9923,7 @@ var LeaferUI = (function (exports) {
9916
9923
  touch: {
9917
9924
  preventDefault: true
9918
9925
  },
9926
+ multiTouch: {},
9919
9927
  cursor: true,
9920
9928
  keyEvent: true
9921
9929
  };
@@ -10042,6 +10050,8 @@ var LeaferUI = (function (exports) {
10042
10050
  this.pointerUp(data);
10043
10051
  }
10044
10052
  multiTouch(data, list) {
10053
+ if (this.config.multiTouch.disabled)
10054
+ return;
10045
10055
  const { move, angle, scale, center } = MultiTouchHelper.getData(list);
10046
10056
  this.rotate(getRotateEventData$1(center, angle, data));
10047
10057
  this.zoom(getZoomEventData$1(center, scale, data));
@@ -10231,7 +10241,7 @@ var LeaferUI = (function (exports) {
10231
10241
  data = this.hoverData;
10232
10242
  if (!data)
10233
10243
  return;
10234
- this.findPath(data, { exclude: this.dragger.getList(), name: exports.PointerEvent.MOVE });
10244
+ this.findPath(data, { exclude: this.dragger.getList(false, true), name: exports.PointerEvent.MOVE });
10235
10245
  this.hoverData = data;
10236
10246
  }
10237
10247
  updateCursor(data) {
@@ -10253,7 +10263,7 @@ var LeaferUI = (function (exports) {
10253
10263
  const { path } = data;
10254
10264
  for (let i = 0, len = path.length; i < len; i++) {
10255
10265
  leaf = path.list[i];
10256
- cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
10266
+ cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
10257
10267
  if (cursor)
10258
10268
  break;
10259
10269
  }
@@ -10435,7 +10445,7 @@ var LeaferUI = (function (exports) {
10435
10445
  if (isHitPixel) {
10436
10446
  const { renderBounds } = this.__layout;
10437
10447
  const size = Platform.image.hitCanvasSize;
10438
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds, 0.5).a;
10448
+ const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10439
10449
  const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
10440
10450
  h.resize({ width, height, pixelRatio: 1 });
10441
10451
  h.clear();
@@ -10491,15 +10501,14 @@ var LeaferUI = (function (exports) {
10491
10501
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10492
10502
  };
10493
10503
 
10494
- const ui$1 = new exports.UI();
10495
- const rect = exports.Rect.prototype;
10496
- rect.__updateHitCanvas = function () {
10504
+ const ui$1 = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
10505
+ rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
10497
10506
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10498
10507
  ui$1.__updateHitCanvas.call(this);
10499
10508
  else if (this.__hitCanvas)
10500
10509
  this.__hitCanvas = null;
10501
10510
  };
10502
- rect.__hitFill = function (inner) {
10511
+ rect.__hitFill = box$1.__hitFill = function (inner) {
10503
10512
  return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10504
10513
  };
10505
10514
 
@@ -11350,9 +11359,10 @@ var LeaferUI = (function (exports) {
11350
11359
  onLoadError(ui, event, image.error);
11351
11360
  }
11352
11361
  else {
11353
- ignoreRender(ui, true);
11354
- if (firstUse)
11362
+ if (firstUse) {
11363
+ ignoreRender(ui, true);
11355
11364
  onLoad(ui, event);
11365
+ }
11356
11366
  leafPaint.loadId = image.load(() => {
11357
11367
  ignoreRender(ui, false);
11358
11368
  if (!ui.destroyed) {
@@ -11964,11 +11974,12 @@ var LeaferUI = (function (exports) {
11964
11974
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11965
11975
  let word, row, wordWidth, rowWidth, realWidth;
11966
11976
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11967
- let textDrawData, rows = [], bounds;
11977
+ let textDrawData, rows = [], bounds, findMaxWidth;
11968
11978
  function createRows(drawData, content, style) {
11969
11979
  textDrawData = drawData;
11970
11980
  rows = drawData.rows;
11971
11981
  bounds = drawData.bounds;
11982
+ findMaxWidth = !bounds.width && !style.autoSizeAlign;
11972
11983
  const { __letterSpacing, paraIndent, textCase } = style;
11973
11984
  const { canvas } = Platform;
11974
11985
  const { width, height } = bounds;
@@ -12053,7 +12064,10 @@ var LeaferUI = (function (exports) {
12053
12064
  else {
12054
12065
  content.split('\n').forEach(content => {
12055
12066
  textDrawData.paraNumber++;
12056
- rows.push({ x: paraIndent || 0, text: content, width: canvas.measureText(content).width, paraStart: true });
12067
+ rowWidth = canvas.measureText(content).width;
12068
+ rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
12069
+ if (findMaxWidth)
12070
+ setMaxWidth();
12057
12071
  });
12058
12072
  }
12059
12073
  }
@@ -12084,10 +12098,16 @@ var LeaferUI = (function (exports) {
12084
12098
  row.width = rowWidth;
12085
12099
  if (bounds.width)
12086
12100
  trimRight(row);
12101
+ else if (findMaxWidth)
12102
+ setMaxWidth();
12087
12103
  rows.push(row);
12088
12104
  row = { words: [] };
12089
12105
  rowWidth = 0;
12090
12106
  }
12107
+ function setMaxWidth() {
12108
+ if (rowWidth > (textDrawData.maxWidth || 0))
12109
+ textDrawData.maxWidth = rowWidth;
12110
+ }
12091
12111
 
12092
12112
  const CharMode = 0;
12093
12113
  const WordMode = 1;
@@ -12159,34 +12179,32 @@ var LeaferUI = (function (exports) {
12159
12179
 
12160
12180
  function layoutText(drawData, style) {
12161
12181
  const { rows, bounds } = drawData;
12162
- const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
12182
+ const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
12163
12183
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
12164
12184
  let starY = __baseLine;
12165
12185
  if (__clipText && realHeight > height) {
12166
12186
  realHeight = Math.max(height, __lineHeight);
12167
12187
  drawData.overflow = rows.length;
12168
12188
  }
12169
- else {
12189
+ else if (height || autoSizeAlign) {
12170
12190
  switch (verticalAlign) {
12171
12191
  case 'middle':
12172
12192
  y += (height - realHeight) / 2;
12173
12193
  break;
12174
- case 'bottom':
12175
- y += (height - realHeight);
12194
+ case 'bottom': y += (height - realHeight);
12176
12195
  }
12177
12196
  }
12178
12197
  starY += y;
12179
- let row, rowX, rowWidth;
12198
+ let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
12180
12199
  for (let i = 0, len = rows.length; i < len; i++) {
12181
12200
  row = rows[i];
12182
12201
  row.x = x;
12183
12202
  if (row.width < width || (row.width > width && !__clipText)) {
12184
12203
  switch (textAlign) {
12185
12204
  case 'center':
12186
- row.x += (width - row.width) / 2;
12205
+ row.x += (layoutWidth - row.width) / 2;
12187
12206
  break;
12188
- case 'right':
12189
- row.x += width - row.width;
12207
+ case 'right': row.x += layoutWidth - row.width;
12190
12208
  }
12191
12209
  }
12192
12210
  if (row.paraStart && paraSpacing && i > 0)
@@ -12291,14 +12309,14 @@ var LeaferUI = (function (exports) {
12291
12309
  let height = style.__getInput('height') || 0;
12292
12310
  const { textDecoration, __font, __padding: padding } = style;
12293
12311
  if (padding) {
12294
- if (width) {
12312
+ if (width)
12313
+ x = padding[left], width -= (padding[right] + padding[left]);
12314
+ else if (!style.autoSizeAlign)
12295
12315
  x = padding[left];
12296
- width -= (padding[right] + padding[left]);
12297
- }
12298
- if (height) {
12316
+ if (height)
12317
+ y = padding[top], height -= (padding[top] + padding[bottom]);
12318
+ else if (!style.autoSizeAlign)
12299
12319
  y = padding[top];
12300
- height -= (padding[top] + padding[bottom]);
12301
- }
12302
12320
  }
12303
12321
  const drawData = {
12304
12322
  bounds: { x, y, width, height },
@@ -12318,22 +12336,20 @@ var LeaferUI = (function (exports) {
12318
12336
  return drawData;
12319
12337
  }
12320
12338
  function padAutoText(padding, drawData, style, width, height) {
12321
- if (!width) {
12339
+ if (!width && style.autoSizeAlign) {
12322
12340
  switch (style.textAlign) {
12323
12341
  case 'left':
12324
12342
  offsetText(drawData, 'x', padding[left]);
12325
12343
  break;
12326
- case 'right':
12327
- offsetText(drawData, 'x', -padding[right]);
12344
+ case 'right': offsetText(drawData, 'x', -padding[right]);
12328
12345
  }
12329
12346
  }
12330
- if (!height) {
12347
+ if (!height && style.autoSizeAlign) {
12331
12348
  switch (style.verticalAlign) {
12332
12349
  case 'top':
12333
12350
  offsetText(drawData, 'y', padding[top]);
12334
12351
  break;
12335
- case 'bottom':
12336
- offsetText(drawData, 'y', -padding[bottom]);
12352
+ case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
12337
12353
  }
12338
12354
  }
12339
12355
  }