leafer-ui 1.0.4 → 1.0.6

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
@@ -555,6 +555,12 @@ var LeaferUI = (function (exports) {
555
555
  to.y = t.y + sin$4(r) * distance;
556
556
  return to;
557
557
  },
558
+ toNumberPoints(originPoints) {
559
+ let points = originPoints;
560
+ if (typeof originPoints[0] === 'object')
561
+ points = [], originPoints.forEach(p => points.push(p.x, p.y));
562
+ return points;
563
+ },
558
564
  reset(t) {
559
565
  P$5.reset(t);
560
566
  }
@@ -1545,7 +1551,10 @@ var LeaferUI = (function (exports) {
1545
1551
 
1546
1552
  class LeafData {
1547
1553
  get __useNaturalRatio() { return true; }
1548
- get __isLinePath() { return this.path && this.path.length === 6; }
1554
+ get __isLinePath() {
1555
+ const { path } = this;
1556
+ return path && path.length === 6 && path[0] === 1;
1557
+ }
1549
1558
  get __blendMode() {
1550
1559
  if (this.eraser && this.eraser !== 'path')
1551
1560
  return 'destination-out';
@@ -2308,11 +2317,12 @@ var LeaferUI = (function (exports) {
2308
2317
 
2309
2318
  const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2310
2319
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2311
- const { set } = PointHelper;
2320
+ const { set, toNumberPoints } = PointHelper;
2312
2321
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2313
2322
  const tempPoint$2 = {};
2314
2323
  const BezierHelper = {
2315
- points(data, points, curve, close) {
2324
+ points(data, originPoints, curve, close) {
2325
+ let points = toNumberPoints(originPoints);
2316
2326
  data.push(M$5, points[0], points[1]);
2317
2327
  if (curve && points.length > 5) {
2318
2328
  let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
@@ -2821,6 +2831,27 @@ var LeaferUI = (function (exports) {
2821
2831
  }
2822
2832
  return data;
2823
2833
  },
2834
+ objectToCanvasData(list) {
2835
+ const data = [];
2836
+ list.forEach(item => {
2837
+ switch (item.name) {
2838
+ case 'M':
2839
+ data.push(M$4, item.x, item.y);
2840
+ break;
2841
+ case 'L':
2842
+ data.push(L$5, item.x, item.y);
2843
+ break;
2844
+ case 'C':
2845
+ data.push(C$4, item.x1, item.y1, item.x2, item.y2, item.x, item.y);
2846
+ break;
2847
+ case 'Q':
2848
+ data.push(Q$3, item.x1, item.y1, item.x, item.y);
2849
+ break;
2850
+ case 'Z': data.push(Z$4);
2851
+ }
2852
+ });
2853
+ return data;
2854
+ },
2824
2855
  copyData(data, old, index, count) {
2825
2856
  for (let i = index, end = index + count; i < end; i++) {
2826
2857
  data.push(old[i]);
@@ -4758,6 +4789,7 @@ var LeaferUI = (function (exports) {
4758
4789
  }
4759
4790
  }
4760
4791
  RenderEvent.REQUEST = 'render.request';
4792
+ RenderEvent.CHILD_START = 'render.child_start';
4761
4793
  RenderEvent.START = 'render.start';
4762
4794
  RenderEvent.BEFORE = 'render.before';
4763
4795
  RenderEvent.RENDER = 'render';
@@ -4933,7 +4965,7 @@ var LeaferUI = (function (exports) {
4933
4965
  const debug$8 = Debug.get('setAttr');
4934
4966
  const LeafDataProxy = {
4935
4967
  __setAttr(name, newValue, checkFiniteNumber) {
4936
- if (this.leafer && this.leafer.created) {
4968
+ if (this.leaferIsCreated) {
4937
4969
  const oldValue = this.__.__getInput(name);
4938
4970
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4939
4971
  debug$8.warn(this.innerName, name, newValue);
@@ -5005,7 +5037,7 @@ var LeaferUI = (function (exports) {
5005
5037
 
5006
5038
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5007
5039
  const { updateBounds: updateBounds$1 } = BranchHelper;
5008
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
5040
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
5009
5041
  const { toBounds: toBounds$2 } = PathBounds;
5010
5042
  const LeafBounds = {
5011
5043
  __updateWorldBounds() {
@@ -5088,7 +5120,7 @@ var LeaferUI = (function (exports) {
5088
5120
  const b = this.__layout.boxBounds;
5089
5121
  const data = this.__;
5090
5122
  if (data.__pathInputed) {
5091
- toBounds$2(data.__pathForRender, b);
5123
+ toBounds$2(data.path, b);
5092
5124
  }
5093
5125
  else {
5094
5126
  b.x = 0;
@@ -5100,7 +5132,7 @@ var LeaferUI = (function (exports) {
5100
5132
  __updateAutoLayout() {
5101
5133
  this.__layout.matrixChanged = true;
5102
5134
  if (this.isBranch) {
5103
- if (this.leafer && this.leafer.ready)
5135
+ if (this.leaferIsReady)
5104
5136
  this.leafer.layouter.addExtra(this);
5105
5137
  if (this.__.flow) {
5106
5138
  if (this.__layout.boxChanged)
@@ -5126,11 +5158,11 @@ var LeaferUI = (function (exports) {
5126
5158
  },
5127
5159
  __updateStrokeBounds() {
5128
5160
  const layout = this.__layout;
5129
- copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5161
+ copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5130
5162
  },
5131
5163
  __updateRenderBounds() {
5132
5164
  const layout = this.__layout;
5133
- layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5165
+ layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5134
5166
  }
5135
5167
  };
5136
5168
 
@@ -5161,7 +5193,7 @@ var LeaferUI = (function (exports) {
5161
5193
  if (this.__worldOpacity) {
5162
5194
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5163
5195
  this.__drawRenderPath(canvas);
5164
- this.__.windingRule ? canvas.clip(this.__.windingRule) : canvas.clip();
5196
+ this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
5165
5197
  }
5166
5198
  },
5167
5199
  __updateWorldOpacity() {
@@ -5235,6 +5267,8 @@ var LeaferUI = (function (exports) {
5235
5267
  get innerName() { return this.__.name || this.tag + this.innerId; }
5236
5268
  get __DataProcessor() { return LeafData; }
5237
5269
  get __LayoutProcessor() { return LeafLayout; }
5270
+ get leaferIsCreated() { return this.leafer && this.leafer.created; }
5271
+ get leaferIsReady() { return this.leafer && this.leafer.ready; }
5238
5272
  get isLeafer() { return false; }
5239
5273
  get isBranch() { return false; }
5240
5274
  get isBranchLeaf() { return false; }
@@ -5676,10 +5710,17 @@ var LeaferUI = (function (exports) {
5676
5710
  add(child, index) {
5677
5711
  if (child === this)
5678
5712
  return;
5713
+ const noIndex = index === undefined;
5714
+ if (!child.__) {
5715
+ if (child instanceof Array)
5716
+ return child.forEach(item => { this.add(item, index); noIndex || index++; });
5717
+ else
5718
+ child = UICreator.get(child.tag, child);
5719
+ }
5679
5720
  if (child.parent)
5680
5721
  child.parent.remove(child);
5681
5722
  child.parent = this;
5682
- index === undefined ? this.children.push(child) : this.children.splice(index, 0, child);
5723
+ noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
5683
5724
  if (child.isBranch)
5684
5725
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5685
5726
  child.__layout.boxChanged || child.__layout.boxChange();
@@ -5693,15 +5734,17 @@ var LeaferUI = (function (exports) {
5693
5734
  }
5694
5735
  this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
5695
5736
  }
5696
- addMany(...children) {
5697
- children.forEach(child => this.add(child));
5698
- }
5737
+ addMany(...children) { this.add(children); }
5699
5738
  remove(child, destroy) {
5700
5739
  if (child) {
5701
- if (child.animationOut)
5702
- child.__runAnimation('out', () => this.__remove(child, destroy));
5740
+ if (child.__) {
5741
+ if (child.animationOut)
5742
+ child.__runAnimation('out', () => this.__remove(child, destroy));
5743
+ else
5744
+ this.__remove(child, destroy);
5745
+ }
5703
5746
  else
5704
- this.__remove(child, destroy);
5747
+ this.find(child).forEach(item => this.remove(item, destroy));
5705
5748
  }
5706
5749
  else if (child === undefined) {
5707
5750
  super.remove(null, destroy);
@@ -5919,7 +5962,7 @@ var LeaferUI = (function (exports) {
5919
5962
  }
5920
5963
  }
5921
5964
 
5922
- const version = "1.0.4";
5965
+ const version = "1.0.6";
5923
5966
 
5924
5967
  const debug$7 = Debug.get('LeaferCanvas');
5925
5968
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6077,7 +6120,7 @@ var LeaferUI = (function (exports) {
6077
6120
  const oldSize = {};
6078
6121
  DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
6079
6122
  this.resize(size);
6080
- if (this.width !== undefined)
6123
+ if (this.resizeListener && this.width !== undefined)
6081
6124
  this.resizeListener(new ResizeEvent(size, oldSize));
6082
6125
  }
6083
6126
  unrealCanvas() {
@@ -6561,6 +6604,7 @@ var LeaferUI = (function (exports) {
6561
6604
  this.totalBounds = new Bounds();
6562
6605
  debug$5.log(target.innerName, '--->');
6563
6606
  try {
6607
+ target.app.emit(RenderEvent.CHILD_START, target);
6564
6608
  this.emitRender(RenderEvent.START);
6565
6609
  this.renderOnce(callback);
6566
6610
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6858,7 +6902,7 @@ var LeaferUI = (function (exports) {
6858
6902
  if (child.isBranch) {
6859
6903
  if (hit || child.__ignoreHitWorld) {
6860
6904
  this.eachFind(child.children, child.__onlyHitMask);
6861
- if (child.isBranchLeaf && !this.findList.length)
6905
+ if (child.isBranchLeaf)
6862
6906
  this.hitChild(child, point);
6863
6907
  }
6864
6908
  }
@@ -7071,6 +7115,13 @@ var LeaferUI = (function (exports) {
7071
7115
 
7072
7116
  const TextConvert = {};
7073
7117
  const ColorConvert = {};
7118
+ const UnitConvert = {
7119
+ number(value, percentRefer) {
7120
+ if (typeof value === 'object')
7121
+ return value.type === 'percent' ? value.value * percentRefer : value.value;
7122
+ return value;
7123
+ }
7124
+ };
7074
7125
  const PathArrow = {};
7075
7126
  const Paint = {};
7076
7127
  const PaintImage = {};
@@ -7091,7 +7142,7 @@ var LeaferUI = (function (exports) {
7091
7142
  }
7092
7143
  };
7093
7144
 
7094
- const { parse } = PathConvert;
7145
+ const { parse, objectToCanvasData } = PathConvert;
7095
7146
  const emptyPaint = {};
7096
7147
  const debug$4 = Debug.get('UIData');
7097
7148
  class UIData extends LeafData {
@@ -7105,10 +7156,11 @@ var LeaferUI = (function (exports) {
7105
7156
  scaleX = -scaleX;
7106
7157
  return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
7107
7158
  }
7108
- else {
7159
+ else
7109
7160
  return strokeWidth;
7110
- }
7111
7161
  }
7162
+ get __hasStroke() { return this.stroke && this.strokeWidth; }
7163
+ get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
7112
7164
  get __autoWidth() { return !this._width; }
7113
7165
  get __autoHeight() { return !this._height; }
7114
7166
  get __autoSide() { return !this._width || !this._height; }
@@ -7125,9 +7177,8 @@ var LeaferUI = (function (exports) {
7125
7177
  this.__leaf.scaleX *= -1;
7126
7178
  debug$4.warn('width < 0, instead -scaleX ', this);
7127
7179
  }
7128
- else {
7180
+ else
7129
7181
  this._width = value;
7130
- }
7131
7182
  }
7132
7183
  setHeight(value) {
7133
7184
  if (value < 0) {
@@ -7135,9 +7186,8 @@ var LeaferUI = (function (exports) {
7135
7186
  this.__leaf.scaleY *= -1;
7136
7187
  debug$4.warn('height < 0, instead -scaleY', this);
7137
7188
  }
7138
- else {
7189
+ else
7139
7190
  this._height = value;
7140
- }
7141
7191
  }
7142
7192
  setFill(value) {
7143
7193
  if (this.__naturalWidth)
@@ -7178,9 +7228,10 @@ var LeaferUI = (function (exports) {
7178
7228
  }
7179
7229
  }
7180
7230
  setPath(value) {
7181
- if (typeof value === 'string') {
7231
+ const isString = typeof value === 'string';
7232
+ if (isString || (value && typeof value[0] === 'object')) {
7182
7233
  this.__setInput('path', value);
7183
- this._path = parse(value);
7234
+ this._path = isString ? parse(value) : objectToCanvasData(value);
7184
7235
  }
7185
7236
  else {
7186
7237
  if (this.__input)
@@ -7195,12 +7246,8 @@ var LeaferUI = (function (exports) {
7195
7246
  value = value.filter((item) => item.visible !== false);
7196
7247
  this._shadow = value.length ? value : null;
7197
7248
  }
7198
- else if (value) {
7199
- this._shadow = value.visible === false ? null : [value];
7200
- }
7201
- else {
7202
- this._shadow = null;
7203
- }
7249
+ else
7250
+ this._shadow = value && value.visible !== false ? [value] : null;
7204
7251
  }
7205
7252
  setInnerShadow(value) {
7206
7253
  this.__setInput('innerShadow', value);
@@ -7209,12 +7256,8 @@ var LeaferUI = (function (exports) {
7209
7256
  value = value.filter((item) => item.visible !== false);
7210
7257
  this._innerShadow = value.length ? value : null;
7211
7258
  }
7212
- else if (value) {
7213
- this._innerShadow = value.visible === false ? null : [value];
7214
- }
7215
- else {
7216
- this._innerShadow = null;
7217
- }
7259
+ else
7260
+ this._innerShadow = value && value.visible !== false ? [value] : null;
7218
7261
  }
7219
7262
  __computePaint() {
7220
7263
  const { fill, stroke } = this.__input;
@@ -7225,24 +7268,19 @@ var LeaferUI = (function (exports) {
7225
7268
  this.__needComputePaint = false;
7226
7269
  }
7227
7270
  }
7228
- const UnitConvert = {
7229
- number(value, percentRefer) {
7230
- if (typeof value === 'object')
7231
- return value.type === 'percent' ? value.value * percentRefer : value.value;
7232
- return value;
7233
- }
7234
- };
7235
7271
 
7236
7272
  class GroupData extends UIData {
7237
7273
  }
7238
7274
 
7239
7275
  class BoxData extends GroupData {
7240
7276
  get __boxStroke() { return !this.__pathInputed; }
7277
+ get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
7278
+ get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7241
7279
  }
7242
7280
 
7243
7281
  class LeaferData extends GroupData {
7244
- __getInputData() {
7245
- const data = super.__getInputData();
7282
+ __getInputData(names, options) {
7283
+ const data = super.__getInputData(names, options);
7246
7284
  canvasSizeAttrs.forEach(key => delete data[key]);
7247
7285
  return data;
7248
7286
  }
@@ -7269,6 +7307,7 @@ var LeaferUI = (function (exports) {
7269
7307
  }
7270
7308
 
7271
7309
  class PathData extends UIData {
7310
+ get __pathInputed() { return 2; }
7272
7311
  }
7273
7312
 
7274
7313
  class PenData extends GroupData {
@@ -7315,16 +7354,18 @@ var LeaferUI = (function (exports) {
7315
7354
  delete data.fill;
7316
7355
  return data;
7317
7356
  }
7318
- __getInputData() {
7319
- const data = super.__getInputData();
7357
+ __getInputData(names, options) {
7358
+ const data = super.__getInputData(names, options);
7320
7359
  delete data.fill;
7321
7360
  return data;
7322
7361
  }
7323
7362
  }
7324
7363
 
7325
7364
  class CanvasData extends RectData {
7326
- __getInputData() {
7327
- const data = super.__getInputData();
7365
+ get __isCanvas() { return true; }
7366
+ get __drawAfterFill() { return true; }
7367
+ __getInputData(names, options) {
7368
+ const data = super.__getInputData(names, options);
7328
7369
  data.url = this.__leaf.canvas.toDataURL('image/png');
7329
7370
  return data;
7330
7371
  }
@@ -7351,16 +7392,12 @@ var LeaferUI = (function (exports) {
7351
7392
  let width = 0;
7352
7393
  const { shadow, innerShadow, blur, backgroundBlur } = this.__;
7353
7394
  if (shadow)
7354
- shadow.forEach(item => {
7355
- width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5);
7356
- });
7395
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
7357
7396
  if (blur)
7358
7397
  width = Math.max(width, blur);
7359
7398
  let shapeWidth = width = Math.ceil(width);
7360
7399
  if (innerShadow)
7361
- innerShadow.forEach(item => {
7362
- shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5);
7363
- });
7400
+ innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
7364
7401
  if (backgroundBlur)
7365
7402
  shapeWidth = Math.max(shapeWidth, backgroundBlur);
7366
7403
  this.__layout.renderShapeSpread = shapeWidth;
@@ -7442,6 +7479,16 @@ var LeaferUI = (function (exports) {
7442
7479
  if (stroke && !ignoreStroke)
7443
7480
  this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7444
7481
  }
7482
+ },
7483
+ __drawAfterFill(canvas, options) {
7484
+ if (this.__.__clipAfterFill) {
7485
+ canvas.save();
7486
+ this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
7487
+ this.__drawContent(canvas, options);
7488
+ canvas.restore();
7489
+ }
7490
+ else
7491
+ this.__drawContent(canvas, options);
7445
7492
  }
7446
7493
  };
7447
7494
  function drawFast(ui, canvas, options) {
@@ -7508,8 +7555,8 @@ var LeaferUI = (function (exports) {
7508
7555
  return pen;
7509
7556
  }
7510
7557
  get editConfig() { return undefined; }
7511
- get editOuter() { return this.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }
7512
- get editInner() { return 'PathEditor'; }
7558
+ get editOuter() { return ''; }
7559
+ get editInner() { return ''; }
7513
7560
  constructor(data) {
7514
7561
  super(data);
7515
7562
  }
@@ -7520,9 +7567,8 @@ var LeaferUI = (function (exports) {
7520
7567
  Object.assign(this, data);
7521
7568
  this.lockNormalStyle = false;
7522
7569
  }
7523
- else {
7570
+ else
7524
7571
  Object.assign(this, data);
7525
- }
7526
7572
  }
7527
7573
  get(name) {
7528
7574
  return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -7568,12 +7614,7 @@ var LeaferUI = (function (exports) {
7568
7614
  this.__drawPathByData(canvas, this.__.path);
7569
7615
  }
7570
7616
  __drawPathByData(drawer, data) {
7571
- if (data) {
7572
- PathDrawer.drawPathByData(drawer, data);
7573
- }
7574
- else {
7575
- this.__drawPathByBox(drawer);
7576
- }
7617
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
7577
7618
  }
7578
7619
  __drawPathByBox(drawer) {
7579
7620
  const { x, y, width, height } = this.__layout.boxBounds;
@@ -7581,9 +7622,8 @@ var LeaferUI = (function (exports) {
7581
7622
  const { cornerRadius } = this.__;
7582
7623
  drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7583
7624
  }
7584
- else {
7625
+ else
7585
7626
  drawer.rect(x, y, width, height);
7586
- }
7587
7627
  }
7588
7628
  animate(_keyframe, _options, _type, _isTemp) {
7589
7629
  return needPlugin('animate');
@@ -7830,23 +7870,13 @@ var LeaferUI = (function (exports) {
7830
7870
  if (data.children) {
7831
7871
  const { children } = data;
7832
7872
  delete data.children;
7833
- if (!this.children) {
7834
- this.__setBranch();
7835
- }
7836
- else {
7837
- this.clear();
7838
- }
7873
+ this.children ? this.clear() : this.__setBranch();
7839
7874
  super.set(data, isTemp);
7840
- let child;
7841
- children.forEach(childData => {
7842
- child = childData.__ ? childData : UICreator.get(childData.tag, childData);
7843
- this.add(child);
7844
- });
7875
+ children.forEach(child => this.add(child));
7845
7876
  data.children = children;
7846
7877
  }
7847
- else {
7878
+ else
7848
7879
  super.set(data, isTemp);
7849
- }
7850
7880
  }
7851
7881
  toJSON(options) {
7852
7882
  const data = super.toJSON(options);
@@ -8266,10 +8296,9 @@ var LeaferUI = (function (exports) {
8266
8296
  registerUI()
8267
8297
  ], exports.Rect);
8268
8298
 
8269
- const rect$1 = exports.Rect.prototype;
8270
- const group$1 = exports.Group.prototype;
8299
+ const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
8300
+ const rect$1 = exports.Rect.prototype, group$1 = exports.Group.prototype;
8271
8301
  const childrenRenderBounds = {};
8272
- const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
8273
8302
  exports.Box = class Box extends exports.Group {
8274
8303
  get __tag() { return 'Box'; }
8275
8304
  get isBranchLeaf() { return true; }
@@ -8279,37 +8308,31 @@ var LeaferUI = (function (exports) {
8279
8308
  }
8280
8309
  __updateStrokeSpread() { return 0; }
8281
8310
  __updateRectRenderSpread() { return 0; }
8282
- __updateRenderSpread() {
8283
- return this.__updateRectRenderSpread() || -1;
8284
- }
8311
+ __updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
8285
8312
  __updateRectBoxBounds() { }
8286
- __updateBoxBounds(secondLayout) {
8313
+ __updateBoxBounds(_secondLayout) {
8287
8314
  const data = this.__;
8288
8315
  if (this.children.length) {
8289
8316
  if (data.__autoSide) {
8290
- if (this.leafer && this.leafer.ready)
8291
- this.leafer.layouter.addExtra(this);
8292
8317
  super.__updateBoxBounds();
8293
8318
  const { boxBounds } = this.__layout;
8294
8319
  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;
8320
+ if (data.__autoWidth) {
8321
+ boxBounds.width += boxBounds.x, boxBounds.x = 0;
8322
+ boxBounds.height = data.height, boxBounds.y = 0;
8323
+ }
8324
+ else {
8325
+ boxBounds.height += boxBounds.y, boxBounds.y = 0;
8326
+ boxBounds.width = data.width, boxBounds.x = 0;
8327
+ }
8299
8328
  }
8300
- if (secondLayout && data.flow && data.padding)
8301
- copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
8302
8329
  this.__updateNaturalSize();
8303
8330
  }
8304
- else {
8331
+ else
8305
8332
  this.__updateRectBoxBounds();
8306
- }
8307
- if (data.flow)
8308
- this.__updateContentBounds();
8309
8333
  }
8310
- else {
8334
+ else
8311
8335
  this.__updateRectBoxBounds();
8312
- }
8313
8336
  }
8314
8337
  __updateStrokeBounds() { }
8315
8338
  __updateRenderBounds() {
@@ -8319,14 +8342,13 @@ var LeaferUI = (function (exports) {
8319
8342
  super.__updateRenderBounds();
8320
8343
  copy$3(childrenRenderBounds, renderBounds);
8321
8344
  this.__updateRectRenderBounds();
8322
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
8345
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8346
+ if (isOverflow && this.__.overflow !== 'hide')
8347
+ add(renderBounds, childrenRenderBounds);
8323
8348
  }
8324
- else {
8349
+ else
8325
8350
  this.__updateRectRenderBounds();
8326
- }
8327
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8328
- if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
8329
- add(renderBounds, childrenRenderBounds);
8351
+ !this.isOverflow !== !isOverflow && (this.isOverflow = isOverflow);
8330
8352
  }
8331
8353
  __updateRectRenderBounds() { }
8332
8354
  __updateRectChange() { }
@@ -8346,20 +8368,9 @@ var LeaferUI = (function (exports) {
8346
8368
  this.__renderGroup(canvas, options);
8347
8369
  }
8348
8370
  }
8349
- __drawAfterFill(canvas, options) {
8350
- const { length } = this.children;
8351
- if (this.isOverflow) {
8352
- canvas.save();
8353
- canvas.clip();
8354
- if (length)
8355
- this.__renderGroup(canvas, options);
8356
- canvas.restore();
8357
- }
8358
- else {
8359
- if (length)
8360
- this.__renderGroup(canvas, options);
8361
- }
8362
- if (this.__.stroke && length) {
8371
+ __drawContent(canvas, options) {
8372
+ this.__renderGroup(canvas, options);
8373
+ if (this.__.__hasStroke) {
8363
8374
  canvas.setWorld(this.__nowWorld);
8364
8375
  this.__drawRenderPath(canvas);
8365
8376
  }
@@ -8371,6 +8382,9 @@ var LeaferUI = (function (exports) {
8371
8382
  __decorate([
8372
8383
  dataType(false)
8373
8384
  ], exports.Box.prototype, "resizeChildren", void 0);
8385
+ __decorate([
8386
+ dataType(false)
8387
+ ], exports.Box.prototype, "textBox", void 0);
8374
8388
  __decorate([
8375
8389
  affectRenderBoundsType('show')
8376
8390
  ], exports.Box.prototype, "overflow", void 0);
@@ -8520,17 +8534,15 @@ var LeaferUI = (function (exports) {
8520
8534
  if (data.__useArrow)
8521
8535
  PathArrow.addArrows(this, false);
8522
8536
  }
8523
- else {
8537
+ else
8524
8538
  super.__updateRenderPath();
8525
- }
8526
8539
  }
8527
8540
  __updateBoxBounds() {
8528
8541
  if (this.points) {
8529
8542
  toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8530
8543
  }
8531
- else {
8544
+ else
8532
8545
  super.__updateBoxBounds();
8533
- }
8534
8546
  }
8535
8547
  };
8536
8548
  __decorate([
@@ -8668,7 +8680,6 @@ var LeaferUI = (function (exports) {
8668
8680
  super(data);
8669
8681
  this.canvas = Creator.canvas(this.__);
8670
8682
  this.context = this.canvas.context;
8671
- this.__.__isCanvas = this.__.__drawAfterFill = true;
8672
8683
  if (data && data.url)
8673
8684
  this.drawImage(data.url);
8674
8685
  }
@@ -8681,8 +8692,7 @@ var LeaferUI = (function (exports) {
8681
8692
  });
8682
8693
  }
8683
8694
  draw(ui, offset, scale, rotation) {
8684
- ui.__layout.update();
8685
- const matrix = new Matrix(ui.__world).invert();
8695
+ const matrix = new Matrix(ui.worldTransform).invert();
8686
8696
  const m = new Matrix();
8687
8697
  if (offset)
8688
8698
  m.translate(offset.x, offset.y);
@@ -8697,17 +8707,9 @@ var LeaferUI = (function (exports) {
8697
8707
  paint() {
8698
8708
  this.forceRender();
8699
8709
  }
8700
- __drawAfterFill(canvas, _options) {
8701
- const { width, height, cornerRadius } = this.__, { view } = this.canvas;
8702
- if (cornerRadius || this.pathInputed) {
8703
- canvas.save();
8704
- canvas.clip();
8705
- canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
8706
- canvas.restore();
8707
- }
8708
- else {
8709
- canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
8710
- }
8710
+ __drawContent(canvas, _options) {
8711
+ const { width, height } = this.__, { view } = this.canvas;
8712
+ canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
8711
8713
  }
8712
8714
  __updateSize() {
8713
8715
  const { canvas } = this;
@@ -8751,7 +8753,6 @@ var LeaferUI = (function (exports) {
8751
8753
  const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
8752
8754
  exports.Text = class Text extends exports.UI {
8753
8755
  get __tag() { return 'Text'; }
8754
- get editInner() { return 'TextEditor'; }
8755
8756
  get textDrawData() {
8756
8757
  this.__layout.update();
8757
8758
  return this.__.__textDrawData;
@@ -8900,6 +8901,9 @@ var LeaferUI = (function (exports) {
8900
8901
  __decorate([
8901
8902
  boundsType('top')
8902
8903
  ], exports.Text.prototype, "verticalAlign", void 0);
8904
+ __decorate([
8905
+ boundsType(true)
8906
+ ], exports.Text.prototype, "autoSizeAlign", void 0);
8903
8907
  __decorate([
8904
8908
  boundsType('normal')
8905
8909
  ], exports.Text.prototype, "textWrap", void 0);
@@ -8914,7 +8918,6 @@ var LeaferUI = (function (exports) {
8914
8918
  get __tag() { return 'Path'; }
8915
8919
  constructor(data) {
8916
8920
  super(data);
8917
- this.__.__pathInputed = 2;
8918
8921
  }
8919
8922
  };
8920
8923
  __decorate([
@@ -8997,21 +9000,17 @@ var LeaferUI = (function (exports) {
8997
9000
  this.tree = this.addLeafer(tree);
8998
9001
  if (sky || editor)
8999
9002
  this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
9000
- if (editor) {
9001
- this.editor = Creator.editor(editor);
9002
- this.sky.add(this.editor);
9003
- }
9003
+ if (editor)
9004
+ this.sky.add(this.editor = Creator.editor(editor));
9004
9005
  }
9005
9006
  }
9006
9007
  __setApp() {
9007
9008
  const { canvas } = this;
9008
9009
  const { realCanvas, view } = this.config;
9009
- if (realCanvas || view === this.canvas.view || !canvas.parentView) {
9010
+ if (realCanvas || view === this.canvas.view || !canvas.parentView)
9010
9011
  this.realCanvas = true;
9011
- }
9012
- else {
9012
+ else
9013
9013
  canvas.unrealCanvas();
9014
- }
9015
9014
  this.leafer = this;
9016
9015
  this.watcher.disable();
9017
9016
  this.layouter.disable();
@@ -9417,10 +9416,7 @@ var LeaferUI = (function (exports) {
9417
9416
  leafer.getValidMove = function (moveX, moveY) {
9418
9417
  const { scroll, disabled } = this.app.config.move;
9419
9418
  if (scroll) {
9420
- if (Math.abs(moveX) > Math.abs(moveY))
9421
- moveY = 0;
9422
- else
9423
- moveX = 0;
9419
+ Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
9424
9420
  if (scroll === 'limit') {
9425
9421
  const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
9426
9422
  const right = x + width - this.width, bottom = y + height - this.height;
@@ -9620,9 +9616,10 @@ var LeaferUI = (function (exports) {
9620
9616
  this.dragData = getDragEventData(data, data, data);
9621
9617
  this.canAnimate = this.canDragOut = true;
9622
9618
  }
9623
- getList() {
9619
+ getList(realDraggable, hover) {
9624
9620
  const { proxy } = this.interaction.selector;
9625
- return this.dragging && (!proxy || !proxy.list.length) ? (exports.DragEvent.list || this.dragableList || emptyList) : emptyList;
9621
+ const hasProxyList = proxy && proxy.list.length, dragList = exports.DragEvent.list || this.draggableList || emptyList;
9622
+ return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
9626
9623
  }
9627
9624
  checkDrag(data, canDrag) {
9628
9625
  const { interaction } = this;
@@ -9647,8 +9644,8 @@ var LeaferUI = (function (exports) {
9647
9644
  this.dragging = canDrag && PointerButton.left(data);
9648
9645
  if (this.dragging) {
9649
9646
  this.interaction.emit(exports.DragEvent.START, this.dragData);
9650
- this.getDragableList(this.dragData.path);
9651
- this.setDragStartPoints(this.realDragableList = this.getList());
9647
+ this.getDraggableList(this.dragData.path);
9648
+ this.setDragStartPoints(this.realDraggableList = this.getList(true));
9652
9649
  }
9653
9650
  }
9654
9651
  }
@@ -9656,12 +9653,12 @@ var LeaferUI = (function (exports) {
9656
9653
  this.dragStartPoints = {};
9657
9654
  list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9658
9655
  }
9659
- getDragableList(path) {
9656
+ getDraggableList(path) {
9660
9657
  let leaf;
9661
9658
  for (let i = 0, len = path.length; i < len; i++) {
9662
9659
  leaf = path.list[i];
9663
- if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
9664
- this.dragableList = new LeafList(leaf);
9660
+ if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
9661
+ this.draggableList = new LeafList(leaf);
9665
9662
  break;
9666
9663
  }
9667
9664
  }
@@ -9686,7 +9683,7 @@ var LeaferUI = (function (exports) {
9686
9683
  }
9687
9684
  dragReal() {
9688
9685
  const { running } = this.interaction;
9689
- const list = this.realDragableList;
9686
+ const list = this.realDraggableList;
9690
9687
  if (list.length && running) {
9691
9688
  const { totalX, totalY } = this.dragData;
9692
9689
  list.forEach(leaf => leaf.draggable && leaf.move(exports.DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
@@ -9775,7 +9772,7 @@ var LeaferUI = (function (exports) {
9775
9772
  this.interaction.emit(exports.DragEvent.LEAVE, data, dragEnterPath);
9776
9773
  }
9777
9774
  dragReset() {
9778
- exports.DragEvent.list = exports.DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9775
+ exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9779
9776
  }
9780
9777
  checkDragOut(data) {
9781
9778
  const { interaction } = this;
@@ -9916,6 +9913,7 @@ var LeaferUI = (function (exports) {
9916
9913
  touch: {
9917
9914
  preventDefault: true
9918
9915
  },
9916
+ multiTouch: {},
9919
9917
  cursor: true,
9920
9918
  keyEvent: true
9921
9919
  };
@@ -10042,6 +10040,8 @@ var LeaferUI = (function (exports) {
10042
10040
  this.pointerUp(data);
10043
10041
  }
10044
10042
  multiTouch(data, list) {
10043
+ if (this.config.multiTouch.disabled)
10044
+ return;
10045
10045
  const { move, angle, scale, center } = MultiTouchHelper.getData(list);
10046
10046
  this.rotate(getRotateEventData$1(center, angle, data));
10047
10047
  this.zoom(getZoomEventData$1(center, scale, data));
@@ -10231,7 +10231,7 @@ var LeaferUI = (function (exports) {
10231
10231
  data = this.hoverData;
10232
10232
  if (!data)
10233
10233
  return;
10234
- this.findPath(data, { exclude: this.dragger.getList(), name: exports.PointerEvent.MOVE });
10234
+ this.findPath(data, { exclude: this.dragger.getList(false, true), name: exports.PointerEvent.MOVE });
10235
10235
  this.hoverData = data;
10236
10236
  }
10237
10237
  updateCursor(data) {
@@ -10253,7 +10253,7 @@ var LeaferUI = (function (exports) {
10253
10253
  const { path } = data;
10254
10254
  for (let i = 0, len = path.length; i < len; i++) {
10255
10255
  leaf = path.list[i];
10256
- cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
10256
+ cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
10257
10257
  if (cursor)
10258
10258
  break;
10259
10259
  }
@@ -10435,7 +10435,7 @@ var LeaferUI = (function (exports) {
10435
10435
  if (isHitPixel) {
10436
10436
  const { renderBounds } = this.__layout;
10437
10437
  const size = Platform.image.hitCanvasSize;
10438
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds, 0.5).a;
10438
+ const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10439
10439
  const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
10440
10440
  h.resize({ width, height, pixelRatio: 1 });
10441
10441
  h.clear();
@@ -10491,15 +10491,14 @@ var LeaferUI = (function (exports) {
10491
10491
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10492
10492
  };
10493
10493
 
10494
- const ui$1 = new exports.UI();
10495
- const rect = exports.Rect.prototype;
10496
- rect.__updateHitCanvas = function () {
10494
+ const ui$1 = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
10495
+ rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
10497
10496
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10498
10497
  ui$1.__updateHitCanvas.call(this);
10499
10498
  else if (this.__hitCanvas)
10500
10499
  this.__hitCanvas = null;
10501
10500
  };
10502
- rect.__hitFill = function (inner) {
10501
+ rect.__hitFill = box$1.__hitFill = function (inner) {
10503
10502
  return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10504
10503
  };
10505
10504
 
@@ -11350,9 +11349,10 @@ var LeaferUI = (function (exports) {
11350
11349
  onLoadError(ui, event, image.error);
11351
11350
  }
11352
11351
  else {
11353
- ignoreRender(ui, true);
11354
- if (firstUse)
11352
+ if (firstUse) {
11353
+ ignoreRender(ui, true);
11355
11354
  onLoad(ui, event);
11355
+ }
11356
11356
  leafPaint.loadId = image.load(() => {
11357
11357
  ignoreRender(ui, false);
11358
11358
  if (!ui.destroyed) {
@@ -11500,7 +11500,7 @@ var LeaferUI = (function (exports) {
11500
11500
  }
11501
11501
  if (allowPaint) {
11502
11502
  canvas.save();
11503
- canvas.clip();
11503
+ ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
11504
11504
  if (paint.blendMode)
11505
11505
  canvas.blendMode = paint.blendMode;
11506
11506
  if (data.opacity)
@@ -11964,11 +11964,12 @@ var LeaferUI = (function (exports) {
11964
11964
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11965
11965
  let word, row, wordWidth, rowWidth, realWidth;
11966
11966
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11967
- let textDrawData, rows = [], bounds;
11967
+ let textDrawData, rows = [], bounds, findMaxWidth;
11968
11968
  function createRows(drawData, content, style) {
11969
11969
  textDrawData = drawData;
11970
11970
  rows = drawData.rows;
11971
11971
  bounds = drawData.bounds;
11972
+ findMaxWidth = !bounds.width && !style.autoSizeAlign;
11972
11973
  const { __letterSpacing, paraIndent, textCase } = style;
11973
11974
  const { canvas } = Platform;
11974
11975
  const { width, height } = bounds;
@@ -12053,7 +12054,10 @@ var LeaferUI = (function (exports) {
12053
12054
  else {
12054
12055
  content.split('\n').forEach(content => {
12055
12056
  textDrawData.paraNumber++;
12056
- rows.push({ x: paraIndent || 0, text: content, width: canvas.measureText(content).width, paraStart: true });
12057
+ rowWidth = canvas.measureText(content).width;
12058
+ rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
12059
+ if (findMaxWidth)
12060
+ setMaxWidth();
12057
12061
  });
12058
12062
  }
12059
12063
  }
@@ -12084,10 +12088,16 @@ var LeaferUI = (function (exports) {
12084
12088
  row.width = rowWidth;
12085
12089
  if (bounds.width)
12086
12090
  trimRight(row);
12091
+ else if (findMaxWidth)
12092
+ setMaxWidth();
12087
12093
  rows.push(row);
12088
12094
  row = { words: [] };
12089
12095
  rowWidth = 0;
12090
12096
  }
12097
+ function setMaxWidth() {
12098
+ if (rowWidth > (textDrawData.maxWidth || 0))
12099
+ textDrawData.maxWidth = rowWidth;
12100
+ }
12091
12101
 
12092
12102
  const CharMode = 0;
12093
12103
  const WordMode = 1;
@@ -12159,34 +12169,32 @@ var LeaferUI = (function (exports) {
12159
12169
 
12160
12170
  function layoutText(drawData, style) {
12161
12171
  const { rows, bounds } = drawData;
12162
- const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
12172
+ const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
12163
12173
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
12164
12174
  let starY = __baseLine;
12165
12175
  if (__clipText && realHeight > height) {
12166
12176
  realHeight = Math.max(height, __lineHeight);
12167
12177
  drawData.overflow = rows.length;
12168
12178
  }
12169
- else {
12179
+ else if (height || autoSizeAlign) {
12170
12180
  switch (verticalAlign) {
12171
12181
  case 'middle':
12172
12182
  y += (height - realHeight) / 2;
12173
12183
  break;
12174
- case 'bottom':
12175
- y += (height - realHeight);
12184
+ case 'bottom': y += (height - realHeight);
12176
12185
  }
12177
12186
  }
12178
12187
  starY += y;
12179
- let row, rowX, rowWidth;
12188
+ let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
12180
12189
  for (let i = 0, len = rows.length; i < len; i++) {
12181
12190
  row = rows[i];
12182
12191
  row.x = x;
12183
12192
  if (row.width < width || (row.width > width && !__clipText)) {
12184
12193
  switch (textAlign) {
12185
12194
  case 'center':
12186
- row.x += (width - row.width) / 2;
12195
+ row.x += (layoutWidth - row.width) / 2;
12187
12196
  break;
12188
- case 'right':
12189
- row.x += width - row.width;
12197
+ case 'right': row.x += layoutWidth - row.width;
12190
12198
  }
12191
12199
  }
12192
12200
  if (row.paraStart && paraSpacing && i > 0)
@@ -12291,14 +12299,14 @@ var LeaferUI = (function (exports) {
12291
12299
  let height = style.__getInput('height') || 0;
12292
12300
  const { textDecoration, __font, __padding: padding } = style;
12293
12301
  if (padding) {
12294
- if (width) {
12302
+ if (width)
12303
+ x = padding[left], width -= (padding[right] + padding[left]);
12304
+ else if (!style.autoSizeAlign)
12295
12305
  x = padding[left];
12296
- width -= (padding[right] + padding[left]);
12297
- }
12298
- if (height) {
12306
+ if (height)
12307
+ y = padding[top], height -= (padding[top] + padding[bottom]);
12308
+ else if (!style.autoSizeAlign)
12299
12309
  y = padding[top];
12300
- height -= (padding[top] + padding[bottom]);
12301
- }
12302
12310
  }
12303
12311
  const drawData = {
12304
12312
  bounds: { x, y, width, height },
@@ -12318,22 +12326,20 @@ var LeaferUI = (function (exports) {
12318
12326
  return drawData;
12319
12327
  }
12320
12328
  function padAutoText(padding, drawData, style, width, height) {
12321
- if (!width) {
12329
+ if (!width && style.autoSizeAlign) {
12322
12330
  switch (style.textAlign) {
12323
12331
  case 'left':
12324
12332
  offsetText(drawData, 'x', padding[left]);
12325
12333
  break;
12326
- case 'right':
12327
- offsetText(drawData, 'x', -padding[right]);
12334
+ case 'right': offsetText(drawData, 'x', -padding[right]);
12328
12335
  }
12329
12336
  }
12330
- if (!height) {
12337
+ if (!height && style.autoSizeAlign) {
12331
12338
  switch (style.verticalAlign) {
12332
12339
  case 'top':
12333
12340
  offsetText(drawData, 'y', padding[top]);
12334
12341
  break;
12335
- case 'bottom':
12336
- offsetText(drawData, 'y', -padding[bottom]);
12342
+ case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
12337
12343
  }
12338
12344
  }
12339
12345
  }