leafer-ui 1.9.4 → 1.9.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.
@@ -136,6 +136,9 @@ class LeafData {
136
136
  const {path: path} = this;
137
137
  return path && path.length === 6 && path[0] === 1;
138
138
  }
139
+ get __usePathBox() {
140
+ return this.__pathInputed;
141
+ }
139
142
  get __blendMode() {
140
143
  if (this.eraser && this.eraser !== "path") return "destination-out";
141
144
  const {blendMode: blendMode} = this;
@@ -369,7 +372,7 @@ function getMatrixData() {
369
372
 
370
373
  const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
371
374
 
372
- const {float: float$1} = MathHelper;
375
+ const {float: float$2} = MathHelper;
373
376
 
374
377
  const tempPoint$3 = {};
375
378
 
@@ -611,12 +614,12 @@ const MatrixHelper = {
611
614
  const cosR = c / scaleY;
612
615
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
613
616
  }
614
- const cosR = float$1(cos$5(rotation));
617
+ const cosR = float$2(cos$5(rotation));
615
618
  const sinR = sin$5(rotation);
616
- scaleX = float$1(scaleX), scaleY = float$1(scaleY);
617
- skewX = cosR ? float$1((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
618
- skewY = cosR ? float$1((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
619
- rotation = float$1(rotation / OneRadian);
619
+ scaleX = float$2(scaleX), scaleY = float$2(scaleY);
620
+ skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
621
+ skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
622
+ rotation = float$2(rotation / OneRadian);
620
623
  } else {
621
624
  scaleX = a;
622
625
  scaleY = d;
@@ -1134,13 +1137,13 @@ const AlignHelper = {
1134
1137
  }
1135
1138
  };
1136
1139
 
1137
- const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3} = TwoPointBoundsHelper;
1140
+ const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
1138
1141
 
1139
1142
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1140
1143
 
1141
- const {float: float, fourNumber: fourNumber} = MathHelper;
1144
+ const {float: float$1, fourNumber: fourNumber} = MathHelper;
1142
1145
 
1143
- const {floor: floor$2, ceil: ceil$1} = Math;
1146
+ const {floor: floor$2, ceil: ceil$2} = Math;
1144
1147
 
1145
1148
  let right$1, bottom$1, boundsRight, boundsBottom;
1146
1149
 
@@ -1269,7 +1272,7 @@ const BoundsHelper = {
1269
1272
  point.x = t.x;
1270
1273
  toOuterPoint$2(matrix, point, toPoint$4);
1271
1274
  addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
1272
- toBounds$3(tempPointBounds$1, to);
1275
+ toBounds$2(tempPointBounds$1, to);
1273
1276
  }
1274
1277
  },
1275
1278
  toInnerOf(t, matrix, to) {
@@ -1307,8 +1310,8 @@ const BoundsHelper = {
1307
1310
  const {x: x, y: y} = t;
1308
1311
  t.x = floor$2(t.x);
1309
1312
  t.y = floor$2(t.y);
1310
- t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
1311
- t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
1313
+ t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1314
+ t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
1312
1315
  },
1313
1316
  unsign(t) {
1314
1317
  if (t.width < 0) {
@@ -1321,10 +1324,10 @@ const BoundsHelper = {
1321
1324
  }
1322
1325
  },
1323
1326
  float(t, maxLength) {
1324
- t.x = float(t.x, maxLength);
1325
- t.y = float(t.y, maxLength);
1326
- t.width = float(t.width, maxLength);
1327
- t.height = float(t.height, maxLength);
1327
+ t.x = float$1(t.x, maxLength);
1328
+ t.y = float$1(t.y, maxLength);
1329
+ t.width = float$1(t.width, maxLength);
1330
+ t.height = float$1(t.height, maxLength);
1328
1331
  },
1329
1332
  add(t, bounds, isPoint) {
1330
1333
  right$1 = t.x + t.width;
@@ -1368,7 +1371,7 @@ const BoundsHelper = {
1368
1371
  },
1369
1372
  setPoints(t, points) {
1370
1373
  points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
1371
- toBounds$3(tempPointBounds$1, t);
1374
+ toBounds$2(tempPointBounds$1, t);
1372
1375
  },
1373
1376
  setPoint(t, point) {
1374
1377
  B.set(t, point.x, point.y);
@@ -2221,15 +2224,15 @@ class LeaferCanvasBase extends Canvas$1 {
2221
2224
  DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2222
2225
  canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2223
2226
  this.bounds = new Bounds(0, 0, this.width, this.height);
2224
- if (this.context && !this.unreal) {
2225
- this.updateViewSize();
2226
- this.smooth = this.config.smooth;
2227
- }
2227
+ this.updateViewSize();
2228
2228
  this.updateClientBounds();
2229
- if (this.context && !this.unreal && takeCanvas) {
2230
- this.clearWorld(takeCanvas.bounds);
2231
- this.copyWorld(takeCanvas);
2232
- takeCanvas.recycle();
2229
+ if (this.context) {
2230
+ this.smooth = this.config.smooth;
2231
+ if (!this.unreal && takeCanvas) {
2232
+ this.clearWorld(takeCanvas.bounds);
2233
+ this.copyWorld(takeCanvas);
2234
+ takeCanvas.recycle();
2235
+ }
2233
2236
  }
2234
2237
  }
2235
2238
  updateViewSize() {}
@@ -2543,7 +2546,7 @@ const RectHelper = {
2543
2546
  }
2544
2547
  };
2545
2548
 
2546
- const {sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2549
+ const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil$1, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2547
2550
 
2548
2551
  const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
2549
2552
 
@@ -2614,9 +2617,11 @@ const BezierHelper = {
2614
2617
  const CBy = toY - y1;
2615
2618
  let startRadian = atan2$1(BAy, BAx);
2616
2619
  let endRadian = atan2$1(CBy, CBx);
2620
+ const lenBA = hypot(BAx, BAy);
2621
+ const lenCB = hypot(CBx, CBy);
2617
2622
  let totalRadian = endRadian - startRadian;
2618
2623
  if (totalRadian < 0) totalRadian += PI2;
2619
- if (totalRadian === PI$2 || abs$2(BAx + BAy) < 1e-12 || abs$2(CBx + CBy) < 1e-12) {
2624
+ if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$2(totalRadian - PI$2) < 1e-12) {
2620
2625
  if (data) data.push(L$6, x1, y1);
2621
2626
  if (setPointBounds) {
2622
2627
  setPoint$1(setPointBounds, fromX, fromY);
@@ -2649,7 +2654,7 @@ const BezierHelper = {
2649
2654
  let totalRadian = endRadian - startRadian;
2650
2655
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2651
2656
  if (anticlockwise) totalRadian -= PI2;
2652
- const parts = ceil(abs$2(totalRadian / PI_2));
2657
+ const parts = ceil$1(abs$2(totalRadian / PI_2));
2653
2658
  const partRadian = totalRadian / parts;
2654
2659
  const partRadian4Sin = sin$3(partRadian / 4);
2655
2660
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -3208,11 +3213,7 @@ class PathCreator {
3208
3213
  this.set(path);
3209
3214
  }
3210
3215
  set(path) {
3211
- if (path) {
3212
- this.__path = isString(path) ? PathHelper.parse(path) : path;
3213
- } else {
3214
- this.__path = [];
3215
- }
3216
+ this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
3216
3217
  return this;
3217
3218
  }
3218
3219
  beginPath() {
@@ -3380,7 +3381,7 @@ const {M: M$1, L: L$2, C: C, Q: Q, Z: Z$1, N: N, D: D$1, X: X, G: G, F: F$1, O:
3380
3381
 
3381
3382
  const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
3382
3383
 
3383
- const {addPointBounds: addPointBounds, copy: copy$7, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$2} = TwoPointBoundsHelper;
3384
+ const {addPointBounds: addPointBounds, copy: copy$7, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$1} = TwoPointBoundsHelper;
3384
3385
 
3385
3386
  const debug$b = Debug.get("PathBounds");
3386
3387
 
@@ -3395,7 +3396,7 @@ const setEndPoint = {};
3395
3396
  const PathBounds = {
3396
3397
  toBounds(data, setBounds) {
3397
3398
  PathBounds.toTwoPointBounds(data, setPointBounds);
3398
- toBounds$2(setPointBounds, setBounds);
3399
+ toBounds$1(setPointBounds, setBounds);
3399
3400
  },
3400
3401
  toTwoPointBounds(data, setPointBounds) {
3401
3402
  if (!data || !data.length) return setPoint(setPointBounds, 0, 0);
@@ -3582,14 +3583,18 @@ const PathCorner = {
3582
3583
  }
3583
3584
  };
3584
3585
 
3585
- PathHelper.creator = new PathCreator;
3586
+ function path(path) {
3587
+ return new PathCreator(path);
3588
+ }
3589
+
3590
+ const pen = path();
3591
+
3592
+ PathHelper.creator = path();
3586
3593
 
3587
3594
  PathHelper.parse = PathConvert.parse;
3588
3595
 
3589
3596
  PathHelper.convertToCanvasData = PathConvert.toCanvasData;
3590
3597
 
3591
- const pen = new PathCreator;
3592
-
3593
3598
  const {drawRoundRect: drawRoundRect} = RectHelper;
3594
3599
 
3595
3600
  function roundRect(drawer) {
@@ -3954,7 +3959,7 @@ const ImageManager = {
3954
3959
  return FileHelper.alphaPixelTypes.some(item => I$1.isFormat(item, config));
3955
3960
  },
3956
3961
  isFormat(format, config) {
3957
- if (config.format === format) return true;
3962
+ if (config.format) return config.format === format;
3958
3963
  const {url: url} = config;
3959
3964
  if (url.startsWith("data:")) {
3960
3965
  if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
@@ -4048,7 +4053,7 @@ class LeaferImage {
4048
4053
  getFull(_filters) {
4049
4054
  return this.view;
4050
4055
  }
4051
- getCanvas(width, height, opacity, _filters, xGap, yGap) {
4056
+ getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
4052
4057
  width || (width = this.width);
4053
4058
  height || (height = this.height);
4054
4059
  if (this.cache) {
@@ -4064,6 +4069,7 @@ class LeaferImage {
4064
4069
  const canvas = Platform.origin.createCanvas(max$1(floor$1(width + (xGap || 0)), 1), max$1(floor$1(height + (yGap || 0)), 1));
4065
4070
  const ctx = canvas.getContext("2d");
4066
4071
  if (opacity) ctx.globalAlpha = opacity;
4072
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
4067
4073
  ctx.drawImage(this.view, 0, 0, width, height);
4068
4074
  this.cache = this.use > 1 ? {
4069
4075
  data: canvas,
@@ -4715,8 +4721,9 @@ const L = LeafHelper;
4715
4721
 
4716
4722
  const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L;
4717
4723
 
4718
- function getTempLocal(t, world) {
4719
- return t.parent ? PointHelper.tempToInnerOf(world, t.parent.scrollWorldTransform) : world;
4724
+ function getTempLocal(t, worldPoint) {
4725
+ t.updateLayout();
4726
+ return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
4720
4727
  }
4721
4728
 
4722
4729
  const LeafBoundsHelper = {
@@ -5456,6 +5463,8 @@ LeaferEvent.RESTART = "leafer.restart";
5456
5463
 
5457
5464
  LeaferEvent.END = "leafer.end";
5458
5465
 
5466
+ LeaferEvent.UPDATE_MODE = "leafer.update_mode";
5467
+
5459
5468
  LeaferEvent.TRANSFORM = "leafer.transform";
5460
5469
 
5461
5470
  LeaferEvent.MOVE = "leafer.move";
@@ -5734,7 +5743,7 @@ const {updateBounds: updateBounds$1} = BranchHelper;
5734
5743
 
5735
5744
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4} = BoundsHelper;
5736
5745
 
5737
- const {toBounds: toBounds$1} = PathBounds;
5746
+ const {toBounds: toBounds} = PathBounds;
5738
5747
 
5739
5748
  const LeafBounds = {
5740
5749
  __updateWorldBounds() {
@@ -5806,8 +5815,8 @@ const LeafBounds = {
5806
5815
  __updateBoxBounds(_secondLayout, _bounds) {
5807
5816
  const b = this.__layout.boxBounds;
5808
5817
  const data = this.__;
5809
- if (data.__pathInputed) {
5810
- toBounds$1(data.path, b);
5818
+ if (data.__usePathBox) {
5819
+ toBounds(data.path, b);
5811
5820
  } else {
5812
5821
  b.x = 0;
5813
5822
  b.y = 0;
@@ -6742,7 +6751,7 @@ class LeafLevelList {
6742
6751
  }
6743
6752
  }
6744
6753
 
6745
- const version = "1.9.4";
6754
+ const version = "1.9.6";
6746
6755
 
6747
6756
  const debug$5 = Debug.get("LeaferCanvas");
6748
6757
 
@@ -6833,10 +6842,22 @@ class LeaferCanvas extends LeaferCanvasBase {
6833
6842
  updateViewSize() {
6834
6843
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
6835
6844
  const {style: style} = this.view;
6836
- style.width = width + "px";
6837
- style.height = height + "px";
6838
- this.view.width = Math.ceil(width * pixelRatio);
6839
- this.view.height = Math.ceil(height * pixelRatio);
6845
+ if (this.unreal) {
6846
+ const {config: config, autoWidthStr: autoWidthStr, autoHeightStr: autoHeightStr} = this;
6847
+ if (config.width) {
6848
+ if (isUndefined(autoWidthStr)) this.autoWidthStr = style.width || "";
6849
+ style.width = config.width + "px";
6850
+ } else if (!isUndefined(autoWidthStr)) style.width = autoWidthStr;
6851
+ if (config.height) {
6852
+ if (isUndefined(autoHeightStr)) this.autoHeightStr = style.height || "";
6853
+ style.height = config.height + "px";
6854
+ } else if (!isUndefined(autoHeightStr)) style.height = autoHeightStr;
6855
+ } else {
6856
+ style.width = width + "px";
6857
+ style.height = height + "px";
6858
+ this.view.width = Math.ceil(width * pixelRatio);
6859
+ this.view.height = Math.ceil(height * pixelRatio);
6860
+ }
6840
6861
  }
6841
6862
  updateClientBounds() {
6842
6863
  if (this.view.parentElement) this.clientBounds = this.view.getBoundingClientRect();
@@ -6845,6 +6866,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6845
6866
  this.resizeListener = listener;
6846
6867
  if (autoBounds) {
6847
6868
  this.autoBounds = autoBounds;
6869
+ if (this.resizeObserver) return;
6848
6870
  try {
6849
6871
  this.resizeObserver = new ResizeObserver(entries => {
6850
6872
  this.updateClientBounds();
@@ -6861,18 +6883,10 @@ class LeaferCanvas extends LeaferCanvasBase {
6861
6883
  } catch (_a) {
6862
6884
  this.imitateResizeObserver();
6863
6885
  }
6886
+ this.stopListenPixelRatio();
6864
6887
  } else {
6865
- window.addEventListener("resize", this.windowListener = () => {
6866
- const pixelRatio = Platform.devicePixelRatio;
6867
- if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
6868
- const {width: width, height: height} = this;
6869
- this.emitResize({
6870
- width: width,
6871
- height: height,
6872
- pixelRatio: pixelRatio
6873
- });
6874
- }
6875
- });
6888
+ this.listenPixelRatio();
6889
+ if (this.unreal) this.updateViewSize();
6876
6890
  }
6877
6891
  }
6878
6892
  imitateResizeObserver() {
@@ -6881,6 +6895,25 @@ class LeaferCanvas extends LeaferCanvasBase {
6881
6895
  Platform.requestRender(this.imitateResizeObserver.bind(this));
6882
6896
  }
6883
6897
  }
6898
+ listenPixelRatio() {
6899
+ if (!this.windowListener) window.addEventListener("resize", this.windowListener = () => {
6900
+ const pixelRatio = Platform.devicePixelRatio;
6901
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
6902
+ const {width: width, height: height} = this;
6903
+ this.emitResize({
6904
+ width: width,
6905
+ height: height,
6906
+ pixelRatio: pixelRatio
6907
+ });
6908
+ }
6909
+ });
6910
+ }
6911
+ stopListenPixelRatio() {
6912
+ if (this.windowListener) {
6913
+ window.removeEventListener("resize", this.windowListener);
6914
+ this.windowListener = null;
6915
+ }
6916
+ }
6884
6917
  checkAutoBounds(parentSize) {
6885
6918
  const view = this.view;
6886
6919
  const {x: x, y: y, width: width, height: height} = this.autoBounds.getBoundsFrom(parentSize);
@@ -6918,10 +6951,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6918
6951
  destroy() {
6919
6952
  if (this.view) {
6920
6953
  this.stopAutoLayout();
6921
- if (this.windowListener) {
6922
- window.removeEventListener("resize", this.windowListener);
6923
- this.windowListener = null;
6924
- }
6954
+ this.stopListenPixelRatio();
6925
6955
  if (!this.unreal) {
6926
6956
  const view = this.view;
6927
6957
  if (view.parentElement) view.remove();
@@ -7350,7 +7380,7 @@ class Renderer {
7350
7380
  this.times = 0;
7351
7381
  this.config = {
7352
7382
  usePartRender: true,
7353
- maxFPS: 60
7383
+ maxFPS: 120
7354
7384
  };
7355
7385
  this.target = target;
7356
7386
  this.canvas = canvas;
@@ -7505,11 +7535,15 @@ class Renderer {
7505
7535
  if (this.requestTime || !target) return;
7506
7536
  if (target.parentApp) return target.parentApp.requestRender(false);
7507
7537
  const requestTime = this.requestTime = Date.now();
7508
- Platform.requestRender(() => {
7509
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7538
+ const render = () => {
7539
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7540
+ const {maxFPS: maxFPS} = this.config;
7541
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7542
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7510
7543
  this.requestTime = 0;
7511
7544
  this.checkRender();
7512
- });
7545
+ };
7546
+ Platform.requestRender(render);
7513
7547
  }
7514
7548
  __onResize(e) {
7515
7549
  if (this.canvas.unreal) return;
@@ -7552,7 +7586,8 @@ class Renderer {
7552
7586
  if (this.target) {
7553
7587
  this.stop();
7554
7588
  this.__removeListenEvents();
7555
- this.target = this.canvas = this.config = null;
7589
+ this.config = {};
7590
+ this.target = this.canvas = null;
7556
7591
  }
7557
7592
  }
7558
7593
  }
@@ -7648,7 +7683,7 @@ class Picker {
7648
7683
  item = path.list[i];
7649
7684
  if (!item.__.hittable) break;
7650
7685
  hittablePath.addAt(item, 0);
7651
- if (!item.__.hitChildren) break;
7686
+ if (!item.__.hitChildren || item.isLeafer && item.mode === "draw") break;
7652
7687
  }
7653
7688
  return hittablePath;
7654
7689
  }
@@ -8043,7 +8078,11 @@ class LeaferData extends GroupData {
8043
8078
 
8044
8079
  class FrameData extends BoxData {}
8045
8080
 
8046
- class LineData extends UIData {}
8081
+ class LineData extends UIData {
8082
+ get __usePathBox() {
8083
+ return this.points || this.__pathInputed;
8084
+ }
8085
+ }
8047
8086
 
8048
8087
  class RectData extends UIData {
8049
8088
  get __boxStroke() {
@@ -8057,7 +8096,7 @@ class EllipseData extends UIData {
8057
8096
  }
8058
8097
  }
8059
8098
 
8060
- class PolygonData extends UIData {}
8099
+ class PolygonData extends LineData {}
8061
8100
 
8062
8101
  class StarData extends UIData {}
8063
8102
 
@@ -8101,8 +8140,6 @@ class TextData extends UIData {
8101
8140
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
8102
8141
  box.set(value);
8103
8142
  if (boxLayout.strokeChanged) layout.strokeChange();
8104
- if (boxLayout.renderChanged) layout.renderChange();
8105
- box.__updateChange();
8106
8143
  } else if (box) {
8107
8144
  t.__box = box.parent = null;
8108
8145
  box.destroy();
@@ -8172,7 +8209,7 @@ const UIBounds = {
8172
8209
  __updateRenderSpread() {
8173
8210
  let width = 0;
8174
8211
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
8175
- if (shadow) 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));
8212
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
8176
8213
  if (blur) width = Math.max(width, blur);
8177
8214
  if (filter) width += Filter.getSpread(filter);
8178
8215
  if (renderSpread) width += renderSpread;
@@ -8185,36 +8222,69 @@ const UIBounds = {
8185
8222
  }
8186
8223
  };
8187
8224
 
8225
+ const {float: float} = MathHelper;
8226
+
8227
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
8228
+
8188
8229
  const DragBoundsHelper = {
8230
+ limitMove(leaf, move) {
8231
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8232
+ if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
8233
+ D.axisMove(leaf, move);
8234
+ },
8235
+ limitScaleOf(leaf, origin, scale) {
8236
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8237
+ if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
8238
+ },
8239
+ axisMove(leaf, move) {
8240
+ const {draggable: draggable} = leaf;
8241
+ if (draggable === "x") move.y = 0;
8242
+ if (draggable === "y") move.x = 0;
8243
+ },
8244
+ getDragBounds(leaf) {
8245
+ const {dragBounds: dragBounds} = leaf;
8246
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
8247
+ },
8248
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
8249
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
8250
+ },
8189
8251
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
8190
8252
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
8191
8253
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8192
8254
  if (!change) move = Object.assign({}, move);
8193
- const isBiggerWidth = content.width > dragBounds.width;
8194
- const isBiggerHeight = content.height > dragBounds.height;
8195
- if (isBiggerWidth && dragBoundsType !== "outer") {
8255
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
8196
8256
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
8197
8257
  } else {
8198
8258
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
8199
8259
  }
8200
- if (isBiggerHeight && dragBoundsType !== "outer") {
8260
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
8201
8261
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
8202
8262
  } else {
8203
8263
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
8204
8264
  }
8205
- move.x = MathHelper.float(move.x);
8206
- move.y = MathHelper.float(move.y);
8265
+ move.x = float(move.x);
8266
+ move.y = float(move.y);
8207
8267
  return move;
8208
8268
  },
8209
- axisMove(leaf, move) {
8210
- const {draggable: draggable} = leaf;
8211
- if (draggable === "x") move.y = 0;
8212
- if (draggable === "y") move.x = 0;
8213
- },
8214
- limitMove(leaf, move) {
8215
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8216
- if (dragBounds) D.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
8217
- D.axisMove(leaf, move);
8269
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
8270
+ if (!change) scale = Object.assign({}, scale);
8271
+ let fitScaleX, fitScaleY;
8272
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
8273
+ tempMerge.set(tempContent).add(dragBounds);
8274
+ tempIntersect.set(tempContent).intersect(dragBounds);
8275
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
8276
+ fitScaleX = tempMerge.width / tempContent.width;
8277
+ } else {
8278
+ fitScaleX = tempIntersect.width / tempContent.width;
8279
+ }
8280
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
8281
+ fitScaleY = tempMerge.height / tempContent.height;
8282
+ } else {
8283
+ fitScaleY = tempIntersect.height / tempContent.height;
8284
+ }
8285
+ scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
8286
+ scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
8287
+ return scale;
8218
8288
  }
8219
8289
  };
8220
8290
 
@@ -8232,7 +8302,7 @@ const UIRender = {
8232
8302
  }
8233
8303
  if (data.__useEffect) {
8234
8304
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
8235
- stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
8305
+ stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !Effect.isTransformShadow(shadow[0]) && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
8236
8306
  data.__useEffect = !!(shadow || otherEffect);
8237
8307
  }
8238
8308
  data.__checkSingle();
@@ -8367,20 +8437,9 @@ let UI = UI_1 = class UI extends Leaf {
8367
8437
  if (!path) this.__drawPathByBox(pen);
8368
8438
  return pen;
8369
8439
  }
8370
- constructor(data) {
8371
- super(data);
8372
- }
8373
8440
  reset(_data) {}
8374
- set(data, transition) {
8375
- if (data) {
8376
- if (transition) {
8377
- if (transition === "temp") {
8378
- this.lockNormalStyle = true;
8379
- Object.assign(this, data);
8380
- this.lockNormalStyle = false;
8381
- } else this.animate(data, transition);
8382
- } else Object.assign(this, data);
8383
- }
8441
+ set(data, _transition) {
8442
+ if (data) Object.assign(this, data);
8384
8443
  }
8385
8444
  get(name) {
8386
8445
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -8426,7 +8485,7 @@ let UI = UI_1 = class UI extends Leaf {
8426
8485
  const data = this.__;
8427
8486
  if (data.path) {
8428
8487
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8429
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8488
+ if (data.__useArrow) PathArrow.addArrows(this);
8430
8489
  } else data.__pathForRender && (data.__pathForRender = undefined);
8431
8490
  }
8432
8491
  __drawRenderPath(canvas) {
@@ -8450,7 +8509,8 @@ let UI = UI_1 = class UI extends Leaf {
8450
8509
  drawImagePlaceholder(canvas, _image) {
8451
8510
  Paint.fill(this.__.placeholderColor, this, canvas);
8452
8511
  }
8453
- animate(_keyframe, _options, _type, _isTemp) {
8512
+ animate(keyframe, _options, _type, _isTemp) {
8513
+ this.set(keyframe);
8454
8514
  return Plugin.need("animate");
8455
8515
  }
8456
8516
  killAnimate(_type, _nextStyle) {}
@@ -8639,9 +8699,6 @@ let Group = class Group extends UI {
8639
8699
  get isBranch() {
8640
8700
  return true;
8641
8701
  }
8642
- constructor(data) {
8643
- super(data);
8644
- }
8645
8702
  reset(data) {
8646
8703
  this.__setBranch();
8647
8704
  super.reset(data);
@@ -8766,7 +8823,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8766
8823
  const canvas = this.canvas = Creator.canvas(config);
8767
8824
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8768
8825
  if (this.isApp) this.__setApp();
8769
- this.__checkAutoLayout(config, parentApp);
8826
+ this.__checkAutoLayout();
8770
8827
  this.view = canvas.view;
8771
8828
  if (!parentApp) {
8772
8829
  this.selector = Creator.selector(this);
@@ -8865,7 +8922,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8865
8922
  this.leafer = leafer;
8866
8923
  this.__level = 1;
8867
8924
  }
8868
- __checkAutoLayout(config, parentApp) {
8925
+ __checkAutoLayout() {
8926
+ const {config: config, parentApp: parentApp} = this;
8869
8927
  if (!parentApp) {
8870
8928
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8871
8929
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8882,7 +8940,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8882
8940
  } else if (attrName === "zIndex") {
8883
8941
  this.canvas.zIndex = newValue;
8884
8942
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
8885
- }
8943
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
8944
+ mode: newValue
8945
+ });
8886
8946
  }
8887
8947
  return super.__setAttr(attrName, newValue);
8888
8948
  }
@@ -8891,9 +8951,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8891
8951
  return super.__getAttr(attrName);
8892
8952
  }
8893
8953
  __changeCanvasSize(attrName, newValue) {
8894
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8895
- data[attrName] = this.config[attrName] = newValue;
8896
- if (newValue) this.canvas.stopAutoLayout();
8954
+ const {config: config, canvas: canvas} = this;
8955
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8956
+ data[attrName] = config[attrName] = newValue;
8957
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8897
8958
  this.__doResize(data);
8898
8959
  }
8899
8960
  __changeFill(newValue) {
@@ -9040,9 +9101,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
9040
9101
  if (!this.parent) {
9041
9102
  if (this.selector) this.selector.destroy();
9042
9103
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
9043
- this.canvasManager.destroy();
9104
+ if (this.canvasManager) this.canvasManager.destroy();
9044
9105
  }
9045
- this.canvas.destroy();
9106
+ if (this.canvas) this.canvas.destroy();
9046
9107
  this.config.view = this.view = this.parentApp = null;
9047
9108
  if (this.userConfig) this.userConfig.view = null;
9048
9109
  super.destroy();
@@ -9064,15 +9125,14 @@ __decorate([ dataProcessor(LeaferData) ], Leafer.prototype, "__", void 0);
9064
9125
 
9065
9126
  __decorate([ boundsType() ], Leafer.prototype, "pixelRatio", void 0);
9066
9127
 
9128
+ __decorate([ dataType("normal") ], Leafer.prototype, "mode", void 0);
9129
+
9067
9130
  Leafer = Leafer_1 = __decorate([ registerUI() ], Leafer);
9068
9131
 
9069
9132
  let Rect = class Rect extends UI {
9070
9133
  get __tag() {
9071
9134
  return "Rect";
9072
9135
  }
9073
- constructor(data) {
9074
- super(data);
9075
- }
9076
9136
  };
9077
9137
 
9078
9138
  __decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
@@ -9204,9 +9264,6 @@ let Frame = class Frame extends Box {
9204
9264
  get isFrame() {
9205
9265
  return true;
9206
9266
  }
9207
- constructor(data) {
9208
- super(data);
9209
- }
9210
9267
  };
9211
9268
 
9212
9269
  __decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
@@ -9223,9 +9280,6 @@ let Ellipse = class Ellipse extends UI {
9223
9280
  get __tag() {
9224
9281
  return "Ellipse";
9225
9282
  }
9226
- constructor(data) {
9227
- super(data);
9228
- }
9229
9283
  __updatePath() {
9230
9284
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9231
9285
  const rx = width / 2, ry = height / 2;
@@ -9265,98 +9319,29 @@ __decorate([ pathType(0) ], Ellipse.prototype, "endAngle", void 0);
9265
9319
 
9266
9320
  Ellipse = __decorate([ registerUI() ], Ellipse);
9267
9321
 
9268
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
9269
-
9270
- const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
9271
-
9272
- const {toBounds: toBounds} = PathBounds;
9273
-
9274
- let Line = class Line extends UI {
9275
- get __tag() {
9276
- return "Line";
9277
- }
9278
- get toPoint() {
9279
- const {width: width, rotation: rotation} = this.__;
9280
- const to = getPointData();
9281
- if (width) to.x = width;
9282
- if (rotation) rotate$1(to, rotation);
9283
- return to;
9284
- }
9285
- set toPoint(value) {
9286
- this.width = getDistance$2(defaultPoint, value);
9287
- this.rotation = getAngle$1(defaultPoint, value);
9288
- if (this.height) this.height = 0;
9289
- }
9290
- constructor(data) {
9291
- super(data);
9292
- }
9293
- __updatePath() {
9294
- const data = this.__;
9295
- const path = data.path = [];
9296
- if (data.points) {
9297
- drawPoints$1(path, data.points, false, data.closed);
9298
- } else {
9299
- moveTo$2(path, 0, 0);
9300
- lineTo$2(path, this.width, 0);
9301
- }
9302
- }
9303
- __updateRenderPath() {
9304
- const data = this.__;
9305
- if (!this.pathInputed && data.points && data.curve) {
9306
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
9307
- if (data.__useArrow) PathArrow.addArrows(this, false);
9308
- } else super.__updateRenderPath();
9309
- }
9310
- __updateBoxBounds() {
9311
- if (this.points) {
9312
- toBounds(this.__.__pathForRender, this.__layout.boxBounds);
9313
- } else super.__updateBoxBounds();
9314
- }
9315
- };
9316
-
9317
- __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9318
-
9319
- __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9320
-
9321
- __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9322
-
9323
- __decorate([ pathType() ], Line.prototype, "points", void 0);
9324
-
9325
- __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9326
-
9327
- __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9328
-
9329
- Line = __decorate([ registerUI() ], Line);
9330
-
9331
9322
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
9332
9323
 
9333
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
9334
-
9335
- const line = Line.prototype;
9324
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
9336
9325
 
9337
9326
  let Polygon = class Polygon extends UI {
9338
9327
  get __tag() {
9339
9328
  return "Polygon";
9340
9329
  }
9341
- constructor(data) {
9342
- super(data);
9343
- }
9344
9330
  __updatePath() {
9345
- const path = this.__.path = [];
9346
- if (this.__.points) {
9347
- drawPoints(path, this.__.points, false, true);
9331
+ const data = this.__;
9332
+ const path = data.path = [];
9333
+ if (data.points) {
9334
+ drawPoints$1(path, data.points, data.curve, true);
9348
9335
  } else {
9349
- const {width: width, height: height, sides: sides} = this.__;
9336
+ const {width: width, height: height, sides: sides} = data;
9350
9337
  const rx = width / 2, ry = height / 2;
9351
- moveTo$1(path, rx, 0);
9338
+ moveTo$2(path, rx, 0);
9352
9339
  for (let i = 1; i < sides; i++) {
9353
- lineTo$1(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
9340
+ lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
9354
9341
  }
9355
9342
  closePath$1(path);
9356
9343
  }
9357
9344
  }
9358
- __updateRenderPath() {}
9359
- __updateBoxBounds() {}
9360
9345
  };
9361
9346
 
9362
9347
  __decorate([ dataProcessor(PolygonData) ], Polygon.prototype, "__", void 0);
@@ -9367,30 +9352,23 @@ __decorate([ pathType() ], Polygon.prototype, "points", void 0);
9367
9352
 
9368
9353
  __decorate([ pathType(0) ], Polygon.prototype, "curve", void 0);
9369
9354
 
9370
- __decorate([ rewrite(line.__updateRenderPath) ], Polygon.prototype, "__updateRenderPath", null);
9371
-
9372
- __decorate([ rewrite(line.__updateBoxBounds) ], Polygon.prototype, "__updateBoxBounds", null);
9373
-
9374
9355
  Polygon = __decorate([ rewriteAble(), registerUI() ], Polygon);
9375
9356
 
9376
9357
  const {sin: sin, cos: cos, PI: PI} = Math;
9377
9358
 
9378
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
9359
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
9379
9360
 
9380
9361
  let Star = class Star extends UI {
9381
9362
  get __tag() {
9382
9363
  return "Star";
9383
9364
  }
9384
- constructor(data) {
9385
- super(data);
9386
- }
9387
9365
  __updatePath() {
9388
9366
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9389
9367
  const rx = width / 2, ry = height / 2;
9390
9368
  const path = this.__.path = [];
9391
- moveTo(path, rx, 0);
9369
+ moveTo$1(path, rx, 0);
9392
9370
  for (let i = 1; i < corners * 2; i++) {
9393
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
9371
+ lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
9394
9372
  }
9395
9373
  closePath(path);
9396
9374
  }
@@ -9404,6 +9382,52 @@ __decorate([ pathType(.382) ], Star.prototype, "innerRadius", void 0);
9404
9382
 
9405
9383
  Star = __decorate([ registerUI() ], Star);
9406
9384
 
9385
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
9386
+
9387
+ const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
9388
+
9389
+ let Line = class Line extends UI {
9390
+ get __tag() {
9391
+ return "Line";
9392
+ }
9393
+ get toPoint() {
9394
+ const {width: width, rotation: rotation} = this.__;
9395
+ const to = getPointData();
9396
+ if (width) to.x = width;
9397
+ if (rotation) rotate$1(to, rotation);
9398
+ return to;
9399
+ }
9400
+ set toPoint(value) {
9401
+ this.width = getDistance$2(defaultPoint, value);
9402
+ this.rotation = getAngle$1(defaultPoint, value);
9403
+ if (this.height) this.height = 0;
9404
+ }
9405
+ __updatePath() {
9406
+ const data = this.__;
9407
+ const path = data.path = [];
9408
+ if (data.points) {
9409
+ drawPoints(path, data.points, data.curve, data.closed);
9410
+ } else {
9411
+ moveTo(path, 0, 0);
9412
+ lineTo(path, this.width, 0);
9413
+ }
9414
+ }
9415
+ };
9416
+
9417
+ __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9418
+
9419
+ __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9420
+
9421
+ __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9422
+
9423
+ __decorate([ pathType() ], Line.prototype, "points", void 0);
9424
+
9425
+ __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9426
+
9427
+ __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9428
+
9429
+ Line = __decorate([ registerUI() ], Line);
9430
+
9407
9431
  let Image$1 = class Image extends Rect {
9408
9432
  get __tag() {
9409
9433
  return "Image";
@@ -9416,9 +9440,6 @@ let Image$1 = class Image extends Rect {
9416
9440
  const {fill: fill} = this.__;
9417
9441
  return isArray(fill) && fill[0].image;
9418
9442
  }
9419
- constructor(data) {
9420
- super(data);
9421
- }
9422
9443
  };
9423
9444
 
9424
9445
  __decorate([ dataProcessor(ImageData) ], Image$1.prototype, "__", void 0);
@@ -9518,9 +9539,6 @@ let Text = class Text extends UI {
9518
9539
  this.updateLayout();
9519
9540
  return this.__.__textDrawData;
9520
9541
  }
9521
- constructor(data) {
9522
- super(data);
9523
- }
9524
9542
  __updateTextDrawData() {
9525
9543
  const data = this.__;
9526
9544
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -9557,10 +9575,6 @@ let Text = class Text extends UI {
9557
9575
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9558
9576
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9559
9577
  }
9560
- __onUpdateSize() {
9561
- if (this.__box) this.__box.__onUpdateSize();
9562
- super.__onUpdateSize();
9563
- }
9564
9578
  __updateRenderSpread() {
9565
9579
  let width = super.__updateRenderSpread();
9566
9580
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -9571,6 +9585,11 @@ let Text = class Text extends UI {
9571
9585
  copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
9572
9586
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
9573
9587
  }
9588
+ __updateChange() {
9589
+ super.__updateChange();
9590
+ const box = this.__box;
9591
+ if (box) box.__onUpdateSize(), box.__updateChange();
9592
+ }
9574
9593
  __drawRenderPath(canvas) {
9575
9594
  canvas.font = this.__.__font;
9576
9595
  }
@@ -9653,9 +9672,6 @@ let Path = class Path extends UI {
9653
9672
  get __tag() {
9654
9673
  return "Path";
9655
9674
  }
9656
- constructor(data) {
9657
- super(data);
9658
- }
9659
9675
  };
9660
9676
 
9661
9677
  __decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
@@ -9668,9 +9684,6 @@ let Pen = class Pen extends Group {
9668
9684
  get __tag() {
9669
9685
  return "Pen";
9670
9686
  }
9671
- constructor(data) {
9672
- super(data);
9673
- }
9674
9687
  setStyle(data) {
9675
9688
  const path = this.pathElement = new Path(data);
9676
9689
  this.pathStyle = data;
@@ -11135,10 +11148,10 @@ canvas.hitPixel = function(radiusPoint, offset, scale = 1) {
11135
11148
 
11136
11149
  const PointerEventHelper = {
11137
11150
  convert(e, local) {
11138
- const base = InteractionHelper.getBase(e);
11151
+ const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
11139
11152
  const data = Object.assign(Object.assign({}, base), {
11140
- x: local.x,
11141
- y: local.y,
11153
+ x: x,
11154
+ y: y,
11142
11155
  width: e.width,
11143
11156
  height: e.height,
11144
11157
  pointerType: e.pointerType,
@@ -11153,10 +11166,10 @@ const PointerEventHelper = {
11153
11166
  return data;
11154
11167
  },
11155
11168
  convertMouse(e, local) {
11156
- const base = InteractionHelper.getBase(e);
11169
+ const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
11157
11170
  return Object.assign(Object.assign({}, base), {
11158
- x: local.x,
11159
- y: local.y,
11171
+ x: x,
11172
+ y: y,
11160
11173
  width: 1,
11161
11174
  height: 1,
11162
11175
  pointerType: "mouse",
@@ -11165,10 +11178,10 @@ const PointerEventHelper = {
11165
11178
  },
11166
11179
  convertTouch(e, local) {
11167
11180
  const touch = PointerEventHelper.getTouch(e);
11168
- const base = InteractionHelper.getBase(e);
11181
+ const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
11169
11182
  return Object.assign(Object.assign({}, base), {
11170
- x: local.x,
11171
- y: local.y,
11183
+ x: x,
11184
+ y: y,
11172
11185
  width: 1,
11173
11186
  height: 1,
11174
11187
  pointerType: "touch",
@@ -12083,7 +12096,7 @@ function ignoreRender(ui, value) {
12083
12096
 
12084
12097
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
12085
12098
 
12086
- const {floor: floor, max: max, abs: abs} = Math;
12099
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
12087
12100
 
12088
12101
  function createPattern(ui, paint, pixelRatio) {
12089
12102
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -12093,8 +12106,6 @@ function createPattern(ui, paint, pixelRatio) {
12093
12106
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
12094
12107
  scaleX *= pixelRatio;
12095
12108
  scaleY *= pixelRatio;
12096
- const xGap = gap && gap.x * scaleX;
12097
- const yGap = gap && gap.y * scaleY;
12098
12109
  if (sx) {
12099
12110
  sx = abs(sx);
12100
12111
  sy = abs(sy);
@@ -12111,7 +12122,10 @@ function createPattern(ui, paint, pixelRatio) {
12111
12122
  if (size > Platform.image.maxCacheSize) return false;
12112
12123
  }
12113
12124
  let maxSize = Platform.image.maxPatternSize;
12114
- if (!image.isSVG) {
12125
+ if (image.isSVG) {
12126
+ const ws = width / image.width;
12127
+ if (ws > 1) imageScale = ws / ceil(ws);
12128
+ } else {
12115
12129
  const imageSize = image.width * image.height;
12116
12130
  if (maxSize > imageSize) maxSize = imageSize;
12117
12131
  }
@@ -12126,18 +12140,20 @@ function createPattern(ui, paint, pixelRatio) {
12126
12140
  scaleX /= sx;
12127
12141
  scaleY /= sy;
12128
12142
  }
12143
+ const xGap = gap && gap.x * scaleX;
12144
+ const yGap = gap && gap.y * scaleY;
12129
12145
  if (transform || scaleX !== 1 || scaleY !== 1) {
12146
+ const canvasWidth = width + (xGap || 0);
12147
+ const canvasHeight = height + (yGap || 0);
12148
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
12149
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
12130
12150
  if (!imageMatrix) {
12131
12151
  imageMatrix = get$1();
12132
12152
  if (transform) copy$1(imageMatrix, transform);
12133
12153
  }
12134
12154
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
12135
12155
  }
12136
- if (imageMatrix) {
12137
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
12138
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
12139
- }
12140
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
12156
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
12141
12157
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
12142
12158
  paint.style = pattern;
12143
12159
  paint.patternId = id;
@@ -12379,12 +12395,18 @@ function shadow(ui, current, shape) {
12379
12395
  }
12380
12396
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
12381
12397
  }
12382
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
12398
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
12383
12399
  if (end && index < end) other.clearWorld(copyBounds);
12384
12400
  });
12385
12401
  other.recycle(copyBounds);
12386
12402
  }
12387
12403
 
12404
+ function getShadowSpread(_ui, shadow) {
12405
+ let width = 0;
12406
+ 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));
12407
+ return width;
12408
+ }
12409
+
12388
12410
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
12389
12411
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
12390
12412
  if (Platform.fullImageShadow) {
@@ -12462,7 +12484,11 @@ const EffectModule = {
12462
12484
  shadow: shadow,
12463
12485
  innerShadow: innerShadow,
12464
12486
  blur: blur,
12465
- backgroundBlur: backgroundBlur
12487
+ backgroundBlur: backgroundBlur,
12488
+ getShadowSpread: getShadowSpread,
12489
+ isTransformShadow(_shadow) {
12490
+ return undefined;
12491
+ }
12466
12492
  };
12467
12493
 
12468
12494
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -12970,16 +12996,17 @@ function toTextChar(row) {
12970
12996
  }
12971
12997
 
12972
12998
  function decorationText(drawData, style) {
12973
- let type;
12999
+ let type, offset = 0;
12974
13000
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
12975
13001
  drawData.decorationHeight = fontSize / 11;
12976
13002
  if (isObject(textDecoration)) {
12977
13003
  type = textDecoration.type;
12978
13004
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
13005
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
12979
13006
  } else type = textDecoration;
12980
13007
  switch (type) {
12981
13008
  case "under":
12982
- drawData.decorationY = [ fontSize * .15 ];
13009
+ drawData.decorationY = [ fontSize * .15 + offset ];
12983
13010
  break;
12984
13011
 
12985
13012
  case "delete":
@@ -12987,7 +13014,7 @@ function decorationText(drawData, style) {
12987
13014
  break;
12988
13015
 
12989
13016
  case "under-delete":
12990
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
13017
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
12991
13018
  }
12992
13019
  }
12993
13020
 
@@ -13091,4 +13118,4 @@ Object.assign(Creator, {
13091
13118
 
13092
13119
  useCanvas();
13093
13120
 
13094
- export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
13121
+ export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };