@leafer-ui/worker 1.9.8 → 1.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -230,7 +230,7 @@ var LeaferUI = function(exports) {
230
230
  }
231
231
  }
232
232
  let tempA, tempB, tempTo;
233
- const {max: max$4} = Math, tempFour = [ 0, 0, 0, 0 ];
233
+ const {max: max$5} = Math, tempFour = [ 0, 0, 0, 0 ];
234
234
  const FourNumberHelper = {
235
235
  zero: [ ...tempFour ],
236
236
  tempFour: tempFour,
@@ -243,7 +243,7 @@ var LeaferUI = function(exports) {
243
243
  return to;
244
244
  },
245
245
  setTemp(top, right, bottom, left) {
246
- return set$1(tempFour, top, right, bottom, left);
246
+ return set$2(tempFour, top, right, bottom, left);
247
247
  },
248
248
  toTempAB(a, b, change) {
249
249
  tempTo = change ? isNumber(a) ? b : a : [];
@@ -281,23 +281,23 @@ var LeaferUI = function(exports) {
281
281
  return data;
282
282
  },
283
283
  max(t, other, change) {
284
- if (isNumber(t) && isNumber(other)) return max$4(t, other);
284
+ if (isNumber(t) && isNumber(other)) return max$5(t, other);
285
285
  toTempAB(t, other, change);
286
- return set$1(tempTo, max$4(tempA[0], tempB[0]), max$4(tempA[1], tempB[1]), max$4(tempA[2], tempB[2]), max$4(tempA[3], tempB[3]));
286
+ return set$2(tempTo, max$5(tempA[0], tempB[0]), max$5(tempA[1], tempB[1]), max$5(tempA[2], tempB[2]), max$5(tempA[3], tempB[3]));
287
287
  },
288
288
  add(t, other, change) {
289
289
  if (isNumber(t) && isNumber(other)) return t + other;
290
290
  toTempAB(t, other, change);
291
- return set$1(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
291
+ return set$2(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
292
292
  },
293
293
  swapAndScale(t, scaleX, scaleY, change) {
294
294
  if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
295
295
  const to = change ? t : [];
296
296
  const [top, right, bottom, left] = t.length === 4 ? t : get$5(t);
297
- return set$1(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
297
+ return set$2(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
298
298
  }
299
299
  };
300
- const {set: set$1, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
300
+ const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
301
301
  const {round: round$3, pow: pow$1, PI: PI$3} = Math;
302
302
  const MathHelper = {
303
303
  within(value, min, max) {
@@ -682,7 +682,7 @@ var LeaferUI = function(exports) {
682
682
  };
683
683
  const M$6 = MatrixHelper;
684
684
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
685
- const {sin: sin$4, cos: cos$4, abs: abs$3, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2} = Math;
685
+ const {sin: sin$4, cos: cos$4, abs: abs$5, sqrt: sqrt$2, atan2: atan2$2, min: min$2, round: round$2} = Math;
686
686
  const PointHelper = {
687
687
  defaultPoint: getPointData(),
688
688
  tempPoint: {},
@@ -774,12 +774,12 @@ var LeaferUI = function(exports) {
774
774
  return getDistanceFrom(t.x, t.y, point.x, point.y);
775
775
  },
776
776
  getDistanceFrom(x1, y1, x2, y2) {
777
- const x = abs$3(x2 - x1);
778
- const y = abs$3(y2 - y1);
777
+ const x = abs$5(x2 - x1);
778
+ const y = abs$5(y2 - y1);
779
779
  return sqrt$2(x * x + y * y);
780
780
  },
781
781
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
782
- return min$1(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
782
+ return min$2(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
783
783
  },
784
784
  getAngle(t, to) {
785
785
  return getAtan2(t, to) / OneRadian;
@@ -2417,9 +2417,9 @@ var LeaferUI = function(exports) {
2417
2417
  data[0] ? drawer.arcTo(x, y, right, y, data[0]) : drawer.lineTo(x, y);
2418
2418
  }
2419
2419
  };
2420
- 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;
2420
+ const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil$1, abs: abs$4, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2421
2421
  const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
2422
- const {set: set, toNumberPoints: toNumberPoints} = PointHelper;
2422
+ const {set: set$1, toNumberPoints: toNumberPoints} = PointHelper;
2423
2423
  const {M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5} = PathCommandMap;
2424
2424
  const tempPoint$1 = {};
2425
2425
  const BezierHelper = {
@@ -2487,14 +2487,14 @@ var LeaferUI = function(exports) {
2487
2487
  const lenCB = hypot(CBx, CBy);
2488
2488
  let totalRadian = endRadian - startRadian;
2489
2489
  if (totalRadian < 0) totalRadian += PI2;
2490
- if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$2(totalRadian - PI$2) < 1e-12) {
2490
+ if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$4(totalRadian - PI$2) < 1e-12) {
2491
2491
  if (data) data.push(L$6, x1, y1);
2492
2492
  if (setPointBounds) {
2493
2493
  setPoint$1(setPointBounds, fromX, fromY);
2494
2494
  addPoint$1(setPointBounds, x1, y1);
2495
2495
  }
2496
- if (setStartPoint) set(setStartPoint, fromX, fromY);
2497
- if (setEndPoint) set(setEndPoint, x1, y1);
2496
+ if (setStartPoint) set$1(setStartPoint, fromX, fromY);
2497
+ if (setEndPoint) set$1(setEndPoint, x1, y1);
2498
2498
  return;
2499
2499
  }
2500
2500
  const anticlockwise = BAx * CBy - CBx * BAy < 0;
@@ -2520,7 +2520,7 @@ var LeaferUI = function(exports) {
2520
2520
  let totalRadian = endRadian - startRadian;
2521
2521
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2522
2522
  if (anticlockwise) totalRadian -= PI2;
2523
- const parts = ceil$1(abs$2(totalRadian / PI_2));
2523
+ const parts = ceil$1(abs$4(totalRadian / PI_2));
2524
2524
  const partRadian = totalRadian / parts;
2525
2525
  const partRadian4Sin = sin$3(partRadian / 4);
2526
2526
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -2534,7 +2534,7 @@ var LeaferUI = function(exports) {
2534
2534
  let fromX = cx + x, fromY = cy + y;
2535
2535
  if (data) data.push(data.length ? L$6 : M$5, fromX, fromY);
2536
2536
  if (setPointBounds) setPoint$1(setPointBounds, fromX, fromY);
2537
- if (setStartPoint) set(setStartPoint, fromX, fromY);
2537
+ if (setStartPoint) set$1(setStartPoint, fromX, fromY);
2538
2538
  for (let i = 0; i < parts; i++) {
2539
2539
  endCos = cos$3(endRadian);
2540
2540
  endSin = sin$3(endRadian);
@@ -2553,7 +2553,7 @@ var LeaferUI = function(exports) {
2553
2553
  startRadian = endRadian;
2554
2554
  endRadian += partRadian;
2555
2555
  }
2556
- if (setEndPoint) set(setEndPoint, cx + x, cy + y);
2556
+ if (setEndPoint) set$1(setEndPoint, cx + x, cy + y);
2557
2557
  },
2558
2558
  quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
2559
2559
  data.push(C$4, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
@@ -2973,7 +2973,7 @@ var LeaferUI = function(exports) {
2973
2973
  const {current: current, pushData: pushData, copyData: copyData} = PathConvert;
2974
2974
  const {M: M$3, L: L$4, C: C$2, Q: Q$2, Z: Z$3, N: N$2, D: D$3, X: X$2, G: G$2, F: F$3, O: O$2, P: P$2, U: U$2} = PathCommandMap;
2975
2975
  const {getMinDistanceFrom: getMinDistanceFrom, getRadianFrom: getRadianFrom} = PointHelper;
2976
- const {tan: tan, min: min, abs: abs$1} = Math;
2976
+ const {tan: tan, min: min$1, abs: abs$3} = Math;
2977
2977
  const startPoint = {};
2978
2978
  const PathCommandDataHelper = {
2979
2979
  beginPath(data) {
@@ -3029,7 +3029,7 @@ var LeaferUI = function(exports) {
3029
3029
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3030
3030
  if (!isUndefined(lastX)) {
3031
3031
  const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3032
- radius = min(radius, min(d / 2, d / 2 * abs$1(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3032
+ radius = min$1(radius, min$1(d / 2, d / 2 * abs$3(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3033
3033
  }
3034
3034
  data.push(U$2, x1, y1, x2, y2, radius);
3035
3035
  },
@@ -3787,7 +3787,7 @@ var LeaferUI = function(exports) {
3787
3787
  };
3788
3788
  const I$1 = ImageManager;
3789
3789
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3790
- const {floor: floor$1, max: max$3} = Math;
3790
+ const {floor: floor$1, max: max$4} = Math;
3791
3791
  class LeaferImage {
3792
3792
  get url() {
3793
3793
  return this.config.url;
@@ -3875,7 +3875,7 @@ var LeaferUI = function(exports) {
3875
3875
  }
3876
3876
  if (data) return data;
3877
3877
  }
3878
- const canvas = Platform.origin.createCanvas(max$3(floor$1(width + (xGap || 0)), 1), max$3(floor$1(height + (yGap || 0)), 1));
3878
+ const canvas = Platform.origin.createCanvas(max$4(floor$1(width + (xGap || 0)), 1), max$4(floor$1(height + (yGap || 0)), 1));
3879
3879
  const ctx = canvas.getContext("2d");
3880
3880
  if (opacity) ctx.globalAlpha = opacity;
3881
3881
  ctx.imageSmoothingEnabled = smooth === false ? false : true;
@@ -6409,7 +6409,7 @@ var LeaferUI = function(exports) {
6409
6409
  this.levelMap = null;
6410
6410
  }
6411
6411
  }
6412
- const version = "1.9.8";
6412
+ const version = "1.9.10";
6413
6413
  class LeaferCanvas extends LeaferCanvasBase {
6414
6414
  get allowBackgroundColor() {
6415
6415
  return true;
@@ -7045,7 +7045,7 @@ var LeaferUI = function(exports) {
7045
7045
  children: [ target ]
7046
7046
  } : target);
7047
7047
  const {list: list} = this.findList;
7048
- const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
7048
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable, !!options.findList);
7049
7049
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
7050
7050
  this.clear();
7051
7051
  return through ? {
@@ -7060,7 +7060,7 @@ var LeaferUI = function(exports) {
7060
7060
  hitPoint(hitPoint, hitRadius, options) {
7061
7061
  return !!this.getByPoint(hitPoint, hitRadius, options).target;
7062
7062
  }
7063
- getBestMatchLeaf(list, bottomList, ignoreHittable) {
7063
+ getBestMatchLeaf(list, bottomList, ignoreHittable, allowNull) {
7064
7064
  const findList = this.findList = new LeafList;
7065
7065
  if (list.length) {
7066
7066
  let find;
@@ -7091,15 +7091,27 @@ var LeaferUI = function(exports) {
7091
7091
  if (findList.length) return findList.list[0];
7092
7092
  }
7093
7093
  }
7094
+ if (allowNull) return null;
7094
7095
  return ignoreHittable ? list[0] : list.find(item => LeafHelper.worldHittable(item));
7095
7096
  }
7096
7097
  getPath(leaf) {
7097
- const path = new LeafList;
7098
+ const path = new LeafList, syncList = [], {target: target} = this;
7098
7099
  while (leaf) {
7100
+ if (leaf.syncEventer) syncList.push(leaf.syncEventer);
7099
7101
  path.add(leaf);
7100
7102
  leaf = leaf.parent;
7103
+ if (leaf === target) break;
7104
+ }
7105
+ if (syncList.length) {
7106
+ syncList.forEach(item => {
7107
+ while (item) {
7108
+ if (item.__.hittable) path.add(item);
7109
+ item = item.parent;
7110
+ if (item === target) break;
7111
+ }
7112
+ });
7101
7113
  }
7102
- if (this.target) path.add(this.target);
7114
+ if (target) path.add(target);
7103
7115
  return path;
7104
7116
  }
7105
7117
  getHitablePath(leaf) {
@@ -7556,12 +7568,12 @@ var LeaferUI = function(exports) {
7556
7568
  }
7557
7569
  __getData() {
7558
7570
  const data = super.__getData();
7559
- delete data.fill;
7571
+ if (data.url) delete data.fill;
7560
7572
  return data;
7561
7573
  }
7562
7574
  __getInputData(names, options) {
7563
7575
  const data = super.__getInputData(names, options);
7564
- delete data.fill;
7576
+ if (data.url) delete data.fill;
7565
7577
  return data;
7566
7578
  }
7567
7579
  }
@@ -7578,7 +7590,7 @@ var LeaferUI = function(exports) {
7578
7590
  return data;
7579
7591
  }
7580
7592
  }
7581
- const {max: max$2, add: add$1} = FourNumberHelper;
7593
+ const {max: max$3, add: add$1} = FourNumberHelper;
7582
7594
  const UIBounds = {
7583
7595
  __updateStrokeSpread() {
7584
7596
  let spread = 0, boxSpread = 0;
@@ -7593,7 +7605,7 @@ var LeaferUI = function(exports) {
7593
7605
  }
7594
7606
  if (data.__useArrow) spread += strokeWidth * 5;
7595
7607
  if (box) {
7596
- spread = max$2(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7608
+ spread = max$3(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7597
7609
  boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
7598
7610
  }
7599
7611
  this.__layout.strokeBoxSpread = boxSpread;
@@ -7603,81 +7615,17 @@ var LeaferUI = function(exports) {
7603
7615
  let spread = 0;
7604
7616
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
7605
7617
  if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
7606
- if (blur) spread = max$2(spread, blur);
7618
+ if (blur) spread = max$3(spread, blur);
7607
7619
  if (filter) spread = add$1(spread, Filter.getSpread(filter));
7608
7620
  if (renderSpread) spread = add$1(spread, renderSpread);
7609
7621
  if (strokeSpread) spread = add$1(spread, strokeSpread);
7610
7622
  let shapeSpread = spread;
7611
- if (innerShadow) shapeSpread = max$2(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7612
- if (backgroundBlur) shapeSpread = max$2(shapeSpread, backgroundBlur);
7623
+ if (innerShadow) shapeSpread = max$3(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7624
+ if (backgroundBlur) shapeSpread = max$3(shapeSpread, backgroundBlur);
7613
7625
  this.__layout.renderShapeSpread = shapeSpread;
7614
- return box ? max$2(box.__updateRenderSpread(), spread) : spread;
7626
+ return box ? max$3(box.__updateRenderSpread(), spread) : spread;
7615
7627
  }
7616
7628
  };
7617
- const {float: float} = MathHelper;
7618
- const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
7619
- const DragBoundsHelper = {
7620
- limitMove(leaf, move) {
7621
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7622
- if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
7623
- D.axisMove(leaf, move);
7624
- },
7625
- limitScaleOf(leaf, origin, scale) {
7626
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7627
- if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
7628
- },
7629
- axisMove(leaf, move) {
7630
- const {draggable: draggable} = leaf;
7631
- if (draggable === "x") move.y = 0;
7632
- if (draggable === "y") move.x = 0;
7633
- },
7634
- getDragBounds(leaf) {
7635
- const {dragBounds: dragBounds} = leaf;
7636
- return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
7637
- },
7638
- isInnerMode(content, dragBounds, dragBoundsType, sideType) {
7639
- return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
7640
- },
7641
- getValidMove(content, dragBounds, dragBoundsType, move, change) {
7642
- const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
7643
- const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
7644
- if (!change) move = Object.assign({}, move);
7645
- if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7646
- if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
7647
- } else {
7648
- if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
7649
- }
7650
- if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7651
- if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
7652
- } else {
7653
- if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
7654
- }
7655
- move.x = float(move.x);
7656
- move.y = float(move.y);
7657
- return move;
7658
- },
7659
- getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
7660
- if (!change) scale = Object.assign({}, scale);
7661
- let fitScaleX, fitScaleY;
7662
- tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
7663
- tempMerge.set(tempContent).add(dragBounds);
7664
- tempIntersect.set(tempContent).intersect(dragBounds);
7665
- if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7666
- fitScaleX = tempMerge.width / tempContent.width;
7667
- } else {
7668
- fitScaleX = tempIntersect.width / tempContent.width;
7669
- }
7670
- if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7671
- fitScaleY = tempMerge.height / tempContent.height;
7672
- } else {
7673
- fitScaleY = tempIntersect.height / tempContent.height;
7674
- }
7675
- scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
7676
- scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
7677
- return scale;
7678
- }
7679
- };
7680
- const D = DragBoundsHelper;
7681
7629
  const {stintSet: stintSet$1} = DataHelper;
7682
7630
  const UIRender = {
7683
7631
  __updateChange() {
@@ -9134,6 +9082,98 @@ var LeaferUI = function(exports) {
9134
9082
  EventCreator.changeName(oldName, newName);
9135
9083
  }
9136
9084
  }
9085
+ const {float: float, sign: sign} = MathHelper, {min: min, max: max$2, abs: abs$2} = Math;
9086
+ const tempContent = new Bounds, tempDragBounds = new Bounds;
9087
+ const DragBoundsHelper = {
9088
+ limitMove(leaf, move) {
9089
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
9090
+ if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
9091
+ D.axisMove(leaf, move);
9092
+ },
9093
+ limitScaleOf(leaf, origin, scale, lockRatio) {
9094
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
9095
+ if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, lockRatio, true);
9096
+ },
9097
+ axisMove(leaf, move) {
9098
+ const {draggable: draggable} = leaf;
9099
+ if (draggable === "x") move.y = 0;
9100
+ if (draggable === "y") move.x = 0;
9101
+ },
9102
+ getDragBounds(leaf) {
9103
+ const {dragBounds: dragBounds} = leaf;
9104
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
9105
+ },
9106
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
9107
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
9108
+ },
9109
+ getValidMove(content, dragBounds, dragBoundsType, move, change) {
9110
+ const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
9111
+ const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9112
+ if (!change) move = Object.assign({}, move);
9113
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
9114
+ if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
9115
+ } else {
9116
+ if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
9117
+ }
9118
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
9119
+ if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
9120
+ } else {
9121
+ if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
9122
+ }
9123
+ move.x = float(move.x);
9124
+ move.y = float(move.y);
9125
+ return move;
9126
+ },
9127
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, lockRatio, change) {
9128
+ if (!change) scale = Object.assign({}, scale);
9129
+ tempDragBounds.set(dragBounds);
9130
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y);
9131
+ const originLeftScale = (origin.x - content.x) / content.width, originRightScale = 1 - originLeftScale;
9132
+ const originTopScale = (origin.y - content.y) / content.height, originBottomScale = 1 - originTopScale;
9133
+ let correctScaleX, correctScaleY, aScale, bScale, aSize, bSize;
9134
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
9135
+ correctScaleX = scale.x < 0 ? 1 / scale.x : 1;
9136
+ if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX, 1);
9137
+ aSize = float(tempContent.minX - tempDragBounds.minX);
9138
+ bSize = float(tempDragBounds.maxX - tempContent.maxX);
9139
+ aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
9140
+ bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
9141
+ correctScaleX *= max$2(aScale, bScale);
9142
+ } else {
9143
+ if (scale.x < 0) tempContent.unsign();
9144
+ aSize = float(tempDragBounds.minX - tempContent.minX);
9145
+ bSize = float(tempContent.maxX - tempDragBounds.maxX);
9146
+ aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1;
9147
+ bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1;
9148
+ correctScaleX = min(aScale, bScale);
9149
+ }
9150
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
9151
+ correctScaleY = scale.y < 0 ? 1 / scale.y : 1;
9152
+ if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY);
9153
+ aSize = float(tempContent.minY - tempDragBounds.minY);
9154
+ bSize = float(tempDragBounds.maxY - tempContent.maxY);
9155
+ aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
9156
+ bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
9157
+ correctScaleY *= max$2(aScale, bScale);
9158
+ if (lockRatio) {
9159
+ aScale = max$2(abs$2(correctScaleX), abs$2(correctScaleY));
9160
+ correctScaleX = sign(correctScaleX) * aScale;
9161
+ correctScaleY = sign(correctScaleY) * aScale;
9162
+ }
9163
+ } else {
9164
+ if (scale.y < 0) tempContent.unsign();
9165
+ aSize = float(tempDragBounds.minY - tempContent.minY);
9166
+ bSize = float(tempContent.maxY - tempDragBounds.maxY);
9167
+ aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1;
9168
+ bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
9169
+ correctScaleY = min(aScale, bScale);
9170
+ }
9171
+ scale.x *= isFinite(correctScaleX) ? correctScaleX : 1;
9172
+ scale.y *= isFinite(correctScaleY) ? correctScaleY : 1;
9173
+ return scale;
9174
+ }
9175
+ };
9176
+ const D = DragBoundsHelper;
9137
9177
  exports.PointerEvent = class PointerEvent extends UIEvent {};
9138
9178
  exports.PointerEvent.POINTER = "pointer";
9139
9179
  exports.PointerEvent.BEFORE_DOWN = "pointer.before_down";
@@ -10545,7 +10585,13 @@ var LeaferUI = function(exports) {
10545
10585
  shape: shape
10546
10586
  };
10547
10587
  let origin = {}, tempMatrix$1 = getMatrixData();
10548
- const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
10588
+ const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
10589
+ function stretchMode(data, box, scaleX, scaleY) {
10590
+ const transform = get$3();
10591
+ translate$1(transform, box.x, box.y);
10592
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
10593
+ data.transform = transform;
10594
+ }
10549
10595
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10550
10596
  const transform = get$3();
10551
10597
  translate$1(transform, box.x + x, box.y + y);
@@ -10560,8 +10606,11 @@ var LeaferUI = function(exports) {
10560
10606
  const transform = get$3();
10561
10607
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
10562
10608
  if (clipScaleX) {
10563
- tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
10564
- multiplyParent(transform, tempMatrix$1);
10609
+ if (rotation || skew) {
10610
+ set(tempMatrix$1);
10611
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
10612
+ multiplyParent(transform, tempMatrix$1);
10613
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
10565
10614
  }
10566
10615
  data.transform = transform;
10567
10616
  }
@@ -10649,7 +10698,10 @@ var LeaferUI = function(exports) {
10649
10698
  if (offset) PointHelper.move(tempImage, offset);
10650
10699
  switch (mode) {
10651
10700
  case "stretch":
10652
- if (!sameBox) width = box.width, height = box.height;
10701
+ if (!sameBox) {
10702
+ scaleX = box.width / width, scaleY = box.height / height;
10703
+ stretchMode(data, box, scaleX, scaleY);
10704
+ }
10653
10705
  break;
10654
10706
 
10655
10707
  case "normal":
@@ -10658,7 +10710,7 @@ var LeaferUI = function(exports) {
10658
10710
  let clipScaleX, clipScaleY;
10659
10711
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
10660
10712
  clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
10661
- if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
10713
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
10662
10714
  }
10663
10715
  break;
10664
10716
 
@@ -10675,17 +10727,14 @@ var LeaferUI = function(exports) {
10675
10727
  if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10676
10728
  }
10677
10729
  if (!data.transform) {
10678
- if (box.x || box.y) {
10679
- data.transform = get$2();
10680
- translate(data.transform, box.x, box.y);
10681
- }
10730
+ if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
10682
10731
  }
10683
- if (scaleX && mode !== "stretch") {
10732
+ data.width = width;
10733
+ data.height = height;
10734
+ if (scaleX) {
10684
10735
  data.scaleX = scaleX;
10685
10736
  data.scaleY = scaleY;
10686
10737
  }
10687
- data.width = width;
10688
- data.height = height;
10689
10738
  if (opacity) data.opacity = opacity;
10690
10739
  if (filters) data.filters = filters;
10691
10740
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
@@ -10804,7 +10853,7 @@ var LeaferUI = function(exports) {
10804
10853
  if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
10805
10854
  }
10806
10855
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
10807
- const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
10856
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs$1} = Math;
10808
10857
  function createPattern(ui, paint, pixelRatio) {
10809
10858
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
10810
10859
  const id = scaleX + "-" + scaleY + "-" + pixelRatio;
@@ -10814,8 +10863,8 @@ var LeaferUI = function(exports) {
10814
10863
  scaleX *= pixelRatio;
10815
10864
  scaleY *= pixelRatio;
10816
10865
  if (sx) {
10817
- sx = abs(sx);
10818
- sy = abs(sy);
10866
+ sx = abs$1(sx);
10867
+ sy = abs$1(sy);
10819
10868
  imageMatrix = get$1();
10820
10869
  copy$1(imageMatrix, transform);
10821
10870
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -10953,6 +11002,7 @@ var LeaferUI = function(exports) {
10953
11002
  recycleImage: recycleImage,
10954
11003
  createData: createData,
10955
11004
  getPatternData: getPatternData,
11005
+ stretchMode: stretchMode,
10956
11006
  fillOrFitMode: fillOrFitMode,
10957
11007
  clipMode: clipMode,
10958
11008
  repeatMode: repeatMode
@@ -11044,7 +11094,7 @@ var LeaferUI = function(exports) {
11044
11094
  conicGradient: conicGradient,
11045
11095
  getTransform: getTransform
11046
11096
  };
11047
- const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
11097
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max, abs: abs} = Math;
11048
11098
  const tempBounds = {}, tempMatrix = new Matrix;
11049
11099
  const offsetOutBounds$1 = {};
11050
11100
  function shadow(ui, current, shape) {
@@ -11061,8 +11111,8 @@ var LeaferUI = function(exports) {
11061
11111
  const sx = Math.abs(nowWorld.scaleX);
11062
11112
  if (sx > 1) otherScale = 1 / sx;
11063
11113
  }
11064
- other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
11065
- transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
11114
+ other.setWorldShadow(offsetOutBounds$1.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds$1.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale, ColorConvert.string(item.color));
11115
+ transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
11066
11116
  if (transform) other.setTransform(transform);
11067
11117
  drawWorldShadow(other, offsetOutBounds$1, shape);
11068
11118
  if (transform) other.resetTransform();
@@ -11084,7 +11134,7 @@ var LeaferUI = function(exports) {
11084
11134
  function getShadowRenderSpread(_ui, shadow) {
11085
11135
  let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
11086
11136
  shadow.forEach(item => {
11087
- x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
11137
+ x = item.x || 0, y = item.y || 0, blur = (item.blur || 0) * 1.5, spread = abs(item.spread || 0);
11088
11138
  top = max(top, spread + blur - y);
11089
11139
  right = max(right, spread + blur + x);
11090
11140
  bottom = max(bottom, spread + blur + y);
@@ -11132,8 +11182,8 @@ var LeaferUI = function(exports) {
11132
11182
  if (sx > 1) otherScale = 1 / sx;
11133
11183
  }
11134
11184
  other.save();
11135
- other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
11136
- transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
11185
+ other.setWorldShadow(offsetOutBounds.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale);
11186
+ transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
11137
11187
  if (transform) other.setTransform(transform);
11138
11188
  drawWorldShadow(other, offsetOutBounds, shape);
11139
11189
  other.restore();
@@ -11707,6 +11757,7 @@ var LeaferUI = function(exports) {
11707
11757
  getDrawData: getDrawData
11708
11758
  };
11709
11759
  function string(color, opacity) {
11760
+ if (!color) return "#000";
11710
11761
  const doOpacity = isNumber(opacity) && opacity < 1;
11711
11762
  if (isString(color)) {
11712
11763
  if (doOpacity && ColorConvert.object) color = ColorConvert.object(color); else return color;