@leafer/worker 2.0.0 → 2.0.1

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.
@@ -58,8 +58,8 @@ function isEmptyData(value) {
58
58
 
59
59
  const DataHelper = {
60
60
  default(t, defaultData) {
61
- assign$1(defaultData, t);
62
- assign$1(t, defaultData);
61
+ assign$2(defaultData, t);
62
+ assign$2(t, defaultData);
63
63
  return t;
64
64
  },
65
65
  assign(t, merge, exclude) {
@@ -67,9 +67,9 @@ const DataHelper = {
67
67
  Object.keys(merge).forEach(key => {
68
68
  var _a, _b;
69
69
  value = merge[key];
70
- if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) return assign$1(t[key], merge[key], exclude && exclude[key]);
70
+ if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) return assign$2(t[key], merge[key], exclude && exclude[key]);
71
71
  if (exclude && key in exclude) {
72
- if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object) assign$1(t[key] = {}, merge[key], exclude[key]);
72
+ if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object) assign$2(t[key] = {}, merge[key], exclude[key]);
73
73
  return;
74
74
  }
75
75
  t[key] = merge[key];
@@ -95,7 +95,7 @@ const DataHelper = {
95
95
  }
96
96
  };
97
97
 
98
- const {assign: assign$1} = DataHelper;
98
+ const {assign: assign$2} = DataHelper;
99
99
 
100
100
  class LeafData {
101
101
  get __useNaturalRatio() {
@@ -410,7 +410,7 @@ function getMatrixData() {
410
410
 
411
411
  const {sin: sin$6, cos: cos$6, acos: acos, sqrt: sqrt$5} = Math;
412
412
 
413
- const {float: float$5} = MathHelper;
413
+ const {float: float$6} = MathHelper;
414
414
 
415
415
  const tempPoint$5 = {};
416
416
 
@@ -661,12 +661,12 @@ const MatrixHelper = {
661
661
  const cosR = c / scaleY;
662
662
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
663
663
  }
664
- const cosR = float$5(cos$6(rotation));
664
+ const cosR = float$6(cos$6(rotation));
665
665
  const sinR = sin$6(rotation);
666
- scaleX = float$5(scaleX), scaleY = float$5(scaleY);
667
- skewX = cosR ? float$5((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
668
- skewY = cosR ? float$5((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
669
- rotation = float$5(rotation / OneRadian);
666
+ scaleX = float$6(scaleX), scaleY = float$6(scaleY);
667
+ skewX = cosR ? float$6((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
668
+ skewY = cosR ? float$6((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
669
+ rotation = float$6(rotation / OneRadian);
670
670
  } else {
671
671
  scaleX = a;
672
672
  scaleY = d;
@@ -710,7 +710,7 @@ const MatrixHelper = {
710
710
 
711
711
  const M$b = MatrixHelper;
712
712
 
713
- const {float: float$4} = MathHelper;
713
+ const {float: float$5} = MathHelper;
714
714
 
715
715
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
716
716
 
@@ -851,7 +851,7 @@ const PointHelper = {
851
851
  return points;
852
852
  },
853
853
  isSame(t, point) {
854
- return float$4(t.x) === float$4(point.x) && float$4(t.y) === float$4(point.y);
854
+ return float$5(t.x) === float$5(point.x) && float$5(t.y) === float$5(point.y);
855
855
  },
856
856
  reset(t) {
857
857
  P$7.reset(t);
@@ -1206,7 +1206,7 @@ const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPo
1206
1206
 
1207
1207
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1208
1208
 
1209
- const {float: float$3, fourNumber: fourNumber$1} = MathHelper;
1209
+ const {float: float$4, fourNumber: fourNumber$1} = MathHelper;
1210
1210
 
1211
1211
  const {floor: floor$2, ceil: ceil$2} = Math;
1212
1212
 
@@ -1216,10 +1216,10 @@ const point$2 = {};
1216
1216
 
1217
1217
  const toPoint$5 = {};
1218
1218
 
1219
- const tempBounds$3 = {};
1219
+ const tempBounds$4 = {};
1220
1220
 
1221
1221
  const BoundsHelper = {
1222
- tempBounds: tempBounds$3,
1222
+ tempBounds: tempBounds$4,
1223
1223
  set(t, x = 0, y = 0, width = 0, height = 0) {
1224
1224
  t.x = x;
1225
1225
  t.y = y;
@@ -1288,9 +1288,9 @@ const BoundsHelper = {
1288
1288
  t.height *= scaleY;
1289
1289
  },
1290
1290
  tempToOuterOf(t, matrix) {
1291
- B.copy(tempBounds$3, t);
1292
- B.toOuterOf(tempBounds$3, matrix);
1293
- return tempBounds$3;
1291
+ B.copy(tempBounds$4, t);
1292
+ B.toOuterOf(tempBounds$4, matrix);
1293
+ return tempBounds$4;
1294
1294
  },
1295
1295
  getOuterOf(t, matrix) {
1296
1296
  t = Object.assign({}, t);
@@ -1348,9 +1348,9 @@ const BoundsHelper = {
1348
1348
  put(t, put, align = "center", putScale = 1, changeSize = true, to) {
1349
1349
  to || (to = put);
1350
1350
  if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
1351
- tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
1352
- tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
1353
- AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
1351
+ tempBounds$4.width = changeSize ? put.width *= putScale : put.width * putScale;
1352
+ tempBounds$4.height = changeSize ? put.height *= putScale : put.height * putScale;
1353
+ AlignHelper.toPoint(align, tempBounds$4, t, to, true, true);
1354
1354
  },
1355
1355
  getSpread(t, spread, side) {
1356
1356
  const n = {};
@@ -1381,10 +1381,10 @@ const BoundsHelper = {
1381
1381
  }
1382
1382
  },
1383
1383
  float(t, maxLength) {
1384
- t.x = float$3(t.x, maxLength);
1385
- t.y = float$3(t.y, maxLength);
1386
- t.width = float$3(t.width, maxLength);
1387
- t.height = float$3(t.height, maxLength);
1384
+ t.x = float$4(t.x, maxLength);
1385
+ t.y = float$4(t.y, maxLength);
1386
+ t.width = float$4(t.width, maxLength);
1387
+ t.height = float$4(t.height, maxLength);
1388
1388
  },
1389
1389
  add(t, bounds, isPoint) {
1390
1390
  right$4 = t.x + t.width;
@@ -1653,7 +1653,7 @@ class Bounds {
1653
1653
  }
1654
1654
  }
1655
1655
 
1656
- const tempBounds$2 = new Bounds;
1656
+ const tempBounds$3 = new Bounds;
1657
1657
 
1658
1658
  class AutoBounds {
1659
1659
  constructor(top, right, bottom, left, width, height) {
@@ -1727,7 +1727,7 @@ const Platform = {
1727
1727
  resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
1728
1728
  const realWidth = max$5(floor$1(width + (xGap || 0)), 1), realHeight = max$5(floor$1(height + (yGap || 0)), 1);
1729
1729
  let interlaceX, interlaceY, interlaceOffset;
1730
- if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, (interlaceX = interlace.type === "x") ? width : height))) interlaceX || (interlaceY = true);
1730
+ if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
1731
1731
  const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
1732
1732
  const ctx = canvas.getContext("2d");
1733
1733
  if (opacity) ctx.globalAlpha = opacity;
@@ -2931,7 +2931,7 @@ const PathCommandNodeHelper = {
2931
2931
  }
2932
2932
  };
2933
2933
 
2934
- const {M: M$9, m: m, L: L$9, l: l, H: H, h: h, V: V, v: v, C: C$7, c: c, S: S, s: s, Q: Q$6, q: q, T: T, t: t, A: A, a: a, Z: Z$7, z: z, N: N$5, D: D$6, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5} = PathCommandMap;
2934
+ const {M: M$9, m: m, L: L$9, l: l, H: H, h: h, V: V, v: v, C: C$7, c: c, S: S$1, s: s, Q: Q$6, q: q, T: T, t: t, A: A, a: a, Z: Z$7, z: z, N: N$5, D: D$6, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5} = PathCommandMap;
2935
2935
 
2936
2936
  const {rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1} = BezierHelper;
2937
2937
 
@@ -3064,10 +3064,10 @@ const PathConvert = {
3064
3064
  old[i + 2] += y;
3065
3065
  old[i + 3] += x;
3066
3066
  old[i + 4] += y;
3067
- command = S;
3067
+ command = S$1;
3068
3068
 
3069
- case S:
3070
- smooth = lastCommand === C$7 || lastCommand === S;
3069
+ case S$1:
3070
+ smooth = lastCommand === C$7 || lastCommand === S$1;
3071
3071
  x1 = smooth ? x * 2 - controlX : old[i + 1];
3072
3072
  y1 = smooth ? y * 2 - controlY : old[i + 2];
3073
3073
  controlX = old[i + 1];
@@ -3317,10 +3317,10 @@ const PathCommandDataHelper = {
3317
3317
  data.push(O$5, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
3318
3318
  }
3319
3319
  },
3320
- arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3320
+ arcTo(data, x1, y1, x2, y2, radius, lastX, lastY, fullRadius) {
3321
3321
  if (!isUndefined(lastX)) {
3322
- const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3323
- radius = min$2(radius, min$2(d / 2, d / 2 * abs$8(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3322
+ const r = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / (fullRadius ? 1 : 2);
3323
+ radius = min$2(radius, min$2(r, r * abs$8(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3324
3324
  }
3325
3325
  data.push(U$4, x1, y1, x2, y2, radius);
3326
3326
  },
@@ -3664,7 +3664,7 @@ const PathCorner = {
3664
3664
  let command, lastCommand, commandLen;
3665
3665
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3666
3666
  if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
3667
- const len = data.length;
3667
+ const len = data.length, three = len === 9;
3668
3668
  const smooth = [];
3669
3669
  while (i < len) {
3670
3670
  command = data[i];
@@ -3676,7 +3676,7 @@ const PathCorner = {
3676
3676
  if (data[i] === L$5) {
3677
3677
  secondX = data[i + 1];
3678
3678
  secondY = data[i + 2];
3679
- smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3679
+ three ? smooth.push(M$5, startX, startY) : smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3680
3680
  } else {
3681
3681
  smooth.push(M$5, startX, startY);
3682
3682
  }
@@ -3688,11 +3688,11 @@ const PathCorner = {
3688
3688
  i += 3;
3689
3689
  switch (data[i]) {
3690
3690
  case L$5:
3691
- arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
3691
+ arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY, three);
3692
3692
  break;
3693
3693
 
3694
3694
  case Z$3:
3695
- arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
3695
+ arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
3696
3696
  break;
3697
3697
 
3698
3698
  default:
@@ -3704,7 +3704,7 @@ const PathCorner = {
3704
3704
 
3705
3705
  case Z$3:
3706
3706
  if (lastCommand !== Z$3) {
3707
- arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3707
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY, three);
3708
3708
  smooth.push(Z$3);
3709
3709
  }
3710
3710
  i += 1;
@@ -6979,7 +6979,7 @@ class LeafLevelList {
6979
6979
  }
6980
6980
  }
6981
6981
 
6982
- const version = "2.0.0";
6982
+ const version = "2.0.1";
6983
6983
 
6984
6984
  class LeaferCanvas extends LeaferCanvasBase {
6985
6985
  get allowBackgroundColor() {
@@ -7993,16 +7993,16 @@ class UIData extends LeafData {
7993
7993
  return t.fill || t.stroke;
7994
7994
  }
7995
7995
  get __autoWidth() {
7996
- return !this._width;
7996
+ return this._width == null;
7997
7997
  }
7998
7998
  get __autoHeight() {
7999
- return !this._height;
7999
+ return this._height == null;
8000
8000
  }
8001
8001
  get __autoSide() {
8002
- return !this._width || !this._height;
8002
+ return this._width == null || this._height == null;
8003
8003
  }
8004
8004
  get __autoSize() {
8005
- return !this._width && !this._height;
8005
+ return this._width == null && this._height == null;
8006
8006
  }
8007
8007
  setVisible(value) {
8008
8008
  this._visible = value;
@@ -9958,7 +9958,7 @@ class UIEvent extends Event {
9958
9958
  }
9959
9959
  }
9960
9960
 
9961
- const {min: min$1, max: max$3, abs: abs$7} = Math, {float: float$2, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
9961
+ const {min: min$1, max: max$3, abs: abs$7} = Math, {float: float$3, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
9962
9962
 
9963
9963
  const tempContent = new Bounds, tempDragBounds = new Bounds;
9964
9964
 
@@ -9998,8 +9998,8 @@ const DragBoundsHelper = {
9998
9998
  } else {
9999
9999
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
10000
10000
  }
10001
- move.x = float$2(move.x);
10002
- move.y = float$2(move.y);
10001
+ move.x = float$3(move.x);
10002
+ move.y = float$3(move.y);
10003
10003
  return move;
10004
10004
  },
10005
10005
  getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, lockRatio, change) {
@@ -10011,26 +10011,26 @@ const DragBoundsHelper = {
10011
10011
  let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
10012
10012
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
10013
10013
  if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10014
- aSize = float$2(tempContent.minX - tempDragBounds.minX);
10015
- bSize = float$2(tempDragBounds.maxX - tempContent.maxX);
10014
+ aSize = float$3(tempContent.minX - tempDragBounds.minX);
10015
+ bSize = float$3(tempDragBounds.maxX - tempContent.maxX);
10016
10016
  aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
10017
10017
  bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
10018
10018
  correctScaleX *= max$3(aScale, bScale);
10019
10019
  } else {
10020
10020
  if (scale.x < 0) {
10021
- if (float$2(minX(content) - minX(dragBounds)) <= 0 || float$2(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10021
+ if (float$3(minX(content) - minX(dragBounds)) <= 0 || float$3(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10022
10022
  tempContent.unsign();
10023
10023
  }
10024
- aSize = float$2(tempDragBounds.minX - tempContent.minX);
10025
- bSize = float$2(tempContent.maxX - tempDragBounds.maxX);
10024
+ aSize = float$3(tempDragBounds.minX - tempContent.minX);
10025
+ bSize = float$3(tempContent.maxX - tempDragBounds.maxX);
10026
10026
  aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1;
10027
10027
  bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1;
10028
10028
  correctScaleX *= min$1(aScale, bScale);
10029
10029
  }
10030
10030
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
10031
10031
  if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10032
- aSize = float$2(tempContent.minY - tempDragBounds.minY);
10033
- bSize = float$2(tempDragBounds.maxY - tempContent.maxY);
10032
+ aSize = float$3(tempContent.minY - tempDragBounds.minY);
10033
+ bSize = float$3(tempDragBounds.maxY - tempContent.maxY);
10034
10034
  aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
10035
10035
  bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
10036
10036
  correctScaleY *= max$3(aScale, bScale);
@@ -10041,11 +10041,11 @@ const DragBoundsHelper = {
10041
10041
  }
10042
10042
  } else {
10043
10043
  if (scale.y < 0) {
10044
- if (float$2(minY(content) - minY(dragBounds)) <= 0 || float$2(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10044
+ if (float$3(minY(content) - minY(dragBounds)) <= 0 || float$3(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10045
10045
  tempContent.unsign();
10046
10046
  }
10047
- aSize = float$2(tempDragBounds.minY - tempContent.minY);
10048
- bSize = float$2(tempContent.maxY - tempDragBounds.maxY);
10047
+ aSize = float$3(tempDragBounds.minY - tempContent.minY);
10048
+ bSize = float$3(tempContent.maxY - tempDragBounds.maxY);
10049
10049
  aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1;
10050
10050
  bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
10051
10051
  correctScaleY *= min$1(aScale, bScale);
@@ -10566,7 +10566,7 @@ function exclude(leaf, excludePath) {
10566
10566
  return excludePath && excludePath.has(leaf);
10567
10567
  }
10568
10568
 
10569
- const config$1 = {
10569
+ const config$2 = {
10570
10570
  wheel: {
10571
10571
  zoomSpeed: .5,
10572
10572
  moveSpeed: .5,
@@ -10640,7 +10640,7 @@ class InteractionBase {
10640
10640
  return this.p.hitRadius;
10641
10641
  }
10642
10642
  constructor(target, canvas, selector, userConfig) {
10643
- this.config = DataHelper.clone(config$1);
10643
+ this.config = DataHelper.clone(config$2);
10644
10644
  this.tapCount = 0;
10645
10645
  this.downKeyMap = {};
10646
10646
  this.target = target;
@@ -11160,8 +11160,8 @@ ui$5.__updateHitCanvas = function() {
11160
11160
  if (isHitPixel) {
11161
11161
  const {renderBounds: renderBounds} = this.__layout;
11162
11162
  const size = Platform.image.hitCanvasSize;
11163
- const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11164
- const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
11163
+ const scale = h.hitScale = tempBounds$3.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11164
+ const {x: x, y: y, width: width, height: height} = tempBounds$3.set(renderBounds).scale(scale);
11165
11165
  h.resize({
11166
11166
  width: width,
11167
11167
  height: height,
@@ -11221,13 +11221,13 @@ ui$5.__hit = function(inner, forceHitFill) {
11221
11221
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
11222
11222
  };
11223
11223
 
11224
- const ui$4 = UI.prototype, rect = Rect.prototype, box$2 = Box.prototype;
11224
+ const ui$4 = UI.prototype, rect = Rect.prototype, box$3 = Box.prototype;
11225
11225
 
11226
- rect.__updateHitCanvas = box$2.__updateHitCanvas = function() {
11226
+ rect.__updateHitCanvas = box$3.__updateHitCanvas = function() {
11227
11227
  if (this.stroke || this.cornerRadius || (this.fill || this.__.__isCanvas) && this.hitFill === "pixel" || this.hitStroke === "all") ui$4.__updateHitCanvas.call(this); else if (this.__hitCanvas) this.__hitCanvas = null;
11228
11228
  };
11229
11229
 
11230
- rect.__hitFill = box$2.__hitFill = function(inner) {
11230
+ rect.__hitFill = box$3.__hitFill = function(inner) {
11231
11231
  return this.__hitCanvas ? ui$4.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
11232
11232
  };
11233
11233
 
@@ -11259,8 +11259,8 @@ canvas$1.hitStroke = function(point, strokeWidth) {
11259
11259
  canvas$1.hitPixel = function(radiusPoint, offset, scale = 1) {
11260
11260
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
11261
11261
  if (offset) x -= offset.x, y -= offset.y;
11262
- tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11263
- const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
11262
+ tempBounds$3.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11263
+ const {data: data} = this.context.getImageData(tempBounds$3.x, tempBounds$3.y, tempBounds$3.width || 1, tempBounds$3.height || 1);
11264
11264
  for (let i = 0, len = data.length; i < len; i += 4) {
11265
11265
  if (data[i + 3] > 0) return true;
11266
11266
  }
@@ -11463,14 +11463,14 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
11463
11463
 
11464
11464
  const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
11465
11465
 
11466
- const tempBounds$1 = {};
11466
+ const tempBounds$2 = {};
11467
11467
 
11468
11468
  function shape(ui, current, options) {
11469
11469
  const canvas = current.getSameCanvas();
11470
11470
  const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
11471
11471
  const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
11472
- toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$1, layout.boxBounds, layout.strokeSpread),
11473
- tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11472
+ toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$2, layout.boxBounds, layout.strokeSpread),
11473
+ tempBounds$2) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11474
11474
  let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
11475
11475
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11476
11476
  if (currentBounds.includes(nowWorldShapeBounds)) {
@@ -11622,7 +11622,7 @@ const PaintModule = {
11622
11622
  shape: shape
11623
11623
  };
11624
11624
 
11625
- let cache$1, box$1 = new Bounds;
11625
+ let cache$1, box$2 = new Bounds;
11626
11626
 
11627
11627
  const {isSame: isSame} = BoundsHelper;
11628
11628
 
@@ -11640,7 +11640,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11640
11640
  cache$1 = image.use > 1 ? {
11641
11641
  leafPaint: leafPaint,
11642
11642
  paint: paint,
11643
- boxBounds: box$1.set(boxBounds)
11643
+ boxBounds: box$2.set(boxBounds)
11644
11644
  } : null;
11645
11645
  }
11646
11646
  if (firstUse || image.loading) event = {
@@ -12176,7 +12176,7 @@ const PaintGradientModule = {
12176
12176
 
12177
12177
  const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$2, abs: abs$5} = Math;
12178
12178
 
12179
- const tempBounds = {}, tempMatrix = new Matrix;
12179
+ const tempBounds$1 = {}, tempMatrix = new Matrix;
12180
12180
 
12181
12181
  const offsetOutBounds$1 = {};
12182
12182
 
@@ -12243,9 +12243,9 @@ function drawWorldShadow(canvas, outBounds, shape) {
12243
12243
  const {shapeBounds: shapeBounds} = shape;
12244
12244
  let from, to;
12245
12245
  if (Platform.fullImageShadow) {
12246
- copy$3(tempBounds, canvas.bounds);
12247
- move$6(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
12248
- from = canvas.bounds, to = tempBounds;
12246
+ copy$3(tempBounds$1, canvas.bounds);
12247
+ move$6(tempBounds$1, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
12248
+ from = canvas.bounds, to = tempBounds$1;
12249
12249
  } else {
12250
12250
  from = shapeBounds, to = outBounds;
12251
12251
  }
@@ -12728,7 +12728,7 @@ function layoutText(drawData, style) {
12728
12728
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
12729
12729
  let starY = __baseLine;
12730
12730
  if (__clipText && realHeight > height) {
12731
- realHeight = Math.max(height, __lineHeight);
12731
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
12732
12732
  if (countRows > 1) drawData.overflow = countRows;
12733
12733
  } else if (height || autoSizeAlign) {
12734
12734
  switch (verticalAlign) {
@@ -12785,10 +12785,10 @@ function layoutText(drawData, style) {
12785
12785
  }
12786
12786
 
12787
12787
  function clipText(drawData, style, x, width) {
12788
- if (!width) return;
12789
12788
  const {rows: rows, overflow: overflow} = drawData;
12790
12789
  let {textOverflow: textOverflow} = style;
12791
- rows.splice(overflow);
12790
+ if (overflow) rows.splice(overflow);
12791
+ if (!width) return;
12792
12792
  if (textOverflow && textOverflow !== "show") {
12793
12793
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
12794
12794
  let char, charRight;
@@ -13107,8 +13107,13 @@ class Stroker extends UI {
13107
13107
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
13108
13108
  }
13109
13109
  data.strokeWidth = strokeWidth / Math.max(aScaleX, aScaleY);
13110
+ if (data.shadow) {
13111
+ const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
13112
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
13113
+ }
13110
13114
  if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
13111
13115
  if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
13116
+ if (data.shadow) canvas.restore();
13112
13117
  }
13113
13118
  }
13114
13119
  data.strokeWidth = strokeWidth;
@@ -14272,7 +14277,7 @@ const rotateSVG = `\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/s
14272
14277
 
14273
14278
  const skewSVG = `\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${filterStyle$1}\n</filter>\n</defs>\n</svg>\n`;
14274
14279
 
14275
- const config = {
14280
+ const config$1 = {
14276
14281
  editSize: "size",
14277
14282
  keyEvent: true,
14278
14283
  stroke: "#836DFF",
@@ -14917,7 +14922,7 @@ let Editor = class Editor extends Group {
14917
14922
  this.selector = new EditSelect(this);
14918
14923
  this.editMask = new EditMask(this);
14919
14924
  this.targetEventIds = [];
14920
- let mergedConfig = DataHelper.clone(config);
14925
+ let mergedConfig = DataHelper.clone(config$1);
14921
14926
  if (userConfig) mergedConfig = DataHelper.default(userConfig, mergedConfig);
14922
14927
  this.mergedConfig = this.config = mergedConfig;
14923
14928
  this.addMany(this.editMask, this.selector, this.editBox);
@@ -15199,7 +15204,10 @@ class InnerEditor {
15199
15204
  return "focus";
15200
15205
  }
15201
15206
  get editBox() {
15202
- return this.editor.editBox;
15207
+ return this._editBox || this.editor.editBox;
15208
+ }
15209
+ set editBox(value) {
15210
+ this._editBox = value;
15203
15211
  }
15204
15212
  constructor(editor) {
15205
15213
  this.eventIds = [];
@@ -15390,7 +15398,7 @@ let LineEditTool = class LineEditTool extends EditTool {
15390
15398
  onSkew(_e) {}
15391
15399
  onUpdate() {
15392
15400
  const {editBox: editBox} = this, {rotatePoints: rotatePoints, resizeLines: resizeLines, resizePoints: resizePoints, rect: rect} = editBox;
15393
- const line = this.editor.element;
15401
+ const line = editBox.target;
15394
15402
  let fromTo, leftOrRight;
15395
15403
  if (line.pathInputed) fromTo = this.getFromToByPath(line.__.path); else if (line.points) fromTo = this.getFromToByPoints(line.__.points);
15396
15404
  if (fromTo) {
@@ -17685,7 +17693,7 @@ function autoBoundsType(defaultValue) {
17685
17693
 
17686
17694
  Plugin.add("flow", "resize");
17687
17695
 
17688
- const box = Box.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
17696
+ const box$1 = Box.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
17689
17697
 
17690
17698
  UI.addAttr("flow", false, autoLayoutType);
17691
17699
 
@@ -17707,7 +17715,7 @@ UI.addAttr("autoBox", undefined, boundsType);
17707
17715
 
17708
17716
  const {copyAndSpread: copyAndSpread} = BoundsHelper;
17709
17717
 
17710
- box.__updateFlowLayout = function() {
17718
+ box$1.__updateFlowLayout = function() {
17711
17719
  const {leaferIsCreated: leaferIsCreated, flow: flow} = this;
17712
17720
  if (leaferIsCreated) this.leafer.created = false;
17713
17721
  switch (flow) {
@@ -17731,7 +17739,7 @@ box.__updateFlowLayout = function() {
17731
17739
  if (leaferIsCreated) this.leafer.created = true;
17732
17740
  };
17733
17741
 
17734
- box.__updateContentBounds = function() {
17742
+ box$1.__updateContentBounds = function() {
17735
17743
  const {padding: padding} = this.__;
17736
17744
  const layout = this.__layout;
17737
17745
  const same = layout.contentBounds === layout.boxBounds;
@@ -17743,7 +17751,7 @@ box.__updateContentBounds = function() {
17743
17751
  }
17744
17752
  };
17745
17753
 
17746
- box.__updateBoxBounds = function(secondLayout) {
17754
+ box$1.__updateBoxBounds = function(secondLayout) {
17747
17755
  if (this.children.length && !this.pathInputed) {
17748
17756
  const data = this.__, {flow: flow} = data;
17749
17757
  if (data.__autoSide) {
@@ -18545,7 +18553,7 @@ const hslMatch = /^hsl\((\d+),\s*(\d+)%\s*,\s*(\d+)%/i;
18545
18553
 
18546
18554
  const hslaMatch = /^hsla\((\d+),\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d*\.?\d+)/i;
18547
18555
 
18548
- const int = parseInt, float$1 = parseFloat, {round: round$1} = Math;
18556
+ const int = parseInt, float$2 = parseFloat, {round: round$1} = Math;
18549
18557
 
18550
18558
  let cache = {}, totalCache = 0;
18551
18559
 
@@ -18658,18 +18666,18 @@ function rgbaToRGBA(color) {
18658
18666
  r: int(match[1]),
18659
18667
  g: int(match[2]),
18660
18668
  b: int(match[3]),
18661
- a: float$1(match[4])
18669
+ a: float$2(match[4])
18662
18670
  };
18663
18671
  }
18664
18672
 
18665
18673
  function hslToRGBA(color) {
18666
18674
  const match = hslMatch.exec(color);
18667
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), 1);
18675
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), 1);
18668
18676
  }
18669
18677
 
18670
18678
  function hslaToRGBA(color) {
18671
18679
  const match = hslaMatch.exec(color);
18672
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), float$1(match[4]));
18680
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), float$2(match[4]));
18673
18681
  }
18674
18682
 
18675
18683
  const n1 = 1 / 6, n2 = .5, n3 = 2 / 3, n4 = 1 / 3;
@@ -18908,7 +18916,7 @@ const HighBezierHelper = {
18908
18916
 
18909
18917
  const {getDistance: getDistance} = HighBezierHelper;
18910
18918
 
18911
- const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float} = MathHelper;
18919
+ const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float$1} = MathHelper;
18912
18920
 
18913
18921
  const tempPoint = {}, tempFrom = {};
18914
18922
 
@@ -19063,7 +19071,7 @@ const HighCurveHelper = {
19063
19071
  tempFrom.y = y;
19064
19072
  to.x = toX;
19065
19073
  to.y = toY;
19066
- cutDistance = float(motionDistance - total);
19074
+ cutDistance = float$1(motionDistance - total);
19067
19075
  if (cutDistance) {
19068
19076
  PointHelper.getDistancePoint(tempFrom, to, cutDistance, true);
19069
19077
  path.push(command, to.x, to.y);
@@ -19082,7 +19090,7 @@ const HighCurveHelper = {
19082
19090
  toY = data[i + 6];
19083
19091
  distance = segments[index];
19084
19092
  if (total + distance > motionDistance) {
19085
- cutDistance = float(motionDistance - total);
19093
+ cutDistance = float$1(motionDistance - total);
19086
19094
  if (cutDistance) {
19087
19095
  t = HighBezierHelper.getT(cutDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
19088
19096
  HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
@@ -19301,21 +19309,21 @@ function getStyle(leaf) {
19301
19309
  const style = {}, button = findParentButton(leaf);
19302
19310
  const state = button ? leaf.state || button.state : leaf.state;
19303
19311
  const stateStyle = state && leaf.states[state];
19304
- if (stateStyle && State.isState(state, leaf, button)) exist = assign(style, stateStyle);
19312
+ if (stateStyle && State.isState(state, leaf, button)) exist = assign$1(style, stateStyle);
19305
19313
  const selectedStyle = style.selectedStyle || leaf.selectedStyle;
19306
- if (selectedStyle && State.isSelected(leaf, button)) exist = assign(style, selectedStyle);
19314
+ if (selectedStyle && State.isSelected(leaf, button)) exist = assign$1(style, selectedStyle);
19307
19315
  const placeholderStyle = style.placeholderStyle || leaf.placeholderStyle;
19308
- if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign(style, placeholderStyle);
19316
+ if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign$1(style, placeholderStyle);
19309
19317
  if (State.isDisabled(leaf, button)) {
19310
19318
  const disabledStyle = style.disabledStyle || leaf.disabledStyle;
19311
- if (disabledStyle) exist = assign(style, disabledStyle);
19319
+ if (disabledStyle) exist = assign$1(style, disabledStyle);
19312
19320
  } else {
19313
19321
  const focusStyle = style.focusStyle || leaf.focusStyle;
19314
- if (focusStyle && State.isFocus(leaf, button)) exist = assign(style, focusStyle);
19322
+ if (focusStyle && State.isFocus(leaf, button)) exist = assign$1(style, focusStyle);
19315
19323
  const hoverStyle = style.hoverStyle || leaf.hoverStyle;
19316
- if (hoverStyle && State.isHover(leaf, button)) exist = assign(style, hoverStyle);
19324
+ if (hoverStyle && State.isHover(leaf, button)) exist = assign$1(style, hoverStyle);
19317
19325
  const pressStyle = style.pressStyle || leaf.pressStyle;
19318
- if (pressStyle && State.isPress(leaf, button)) exist = assign(style, pressStyle);
19326
+ if (pressStyle && State.isPress(leaf, button)) exist = assign$1(style, pressStyle);
19319
19327
  }
19320
19328
  return exist ? style : undefined;
19321
19329
  }
@@ -19346,7 +19354,7 @@ function getTransition(type, style, data) {
19346
19354
  return isNull(style[name]) ? data[name] : style[name];
19347
19355
  }
19348
19356
 
19349
- function assign(style, stateStyle) {
19357
+ function assign$1(style, stateStyle) {
19350
19358
  Object.assign(style, stateStyle);
19351
19359
  return true;
19352
19360
  }
@@ -20167,4 +20175,258 @@ Plugin.add("bright");
20167
20175
 
20168
20176
  UI.addAttr("bright", false, dimType);
20169
20177
 
20170
- export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$4 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
20178
+ const config = {
20179
+ theme: "light",
20180
+ style: {
20181
+ dragBoundsType: "outer",
20182
+ strokeAlign: "center",
20183
+ strokeWidthFixed: "zoom-in",
20184
+ width: 6,
20185
+ height: 6,
20186
+ opacity: .5,
20187
+ cornerRadius: 3,
20188
+ hoverStyle: {
20189
+ opacity: .6
20190
+ },
20191
+ pressStyle: {
20192
+ opacity: .66
20193
+ }
20194
+ },
20195
+ size: 6,
20196
+ endsMargin: 2,
20197
+ sideMargin: 2,
20198
+ minSize: 10,
20199
+ scaleFixed: "zoom-in",
20200
+ scrollType: "both",
20201
+ hideOnActionEnd: "hover"
20202
+ };
20203
+
20204
+ const tempBounds = new Bounds, {float: float} = MathHelper, {clone: clone, assign: assign} = DataHelper;
20205
+
20206
+ class Scroller extends Group {
20207
+ get canUse() {
20208
+ return this.target.hasScroller;
20209
+ }
20210
+ constructor(target) {
20211
+ super();
20212
+ this.targetWorldBounds = new Bounds;
20213
+ this.viewportBounds = new Bounds;
20214
+ this.contentBounds = new Bounds;
20215
+ this.scrollXBounds = new Bounds;
20216
+ this.scrollYBounds = new Bounds;
20217
+ this.target = target;
20218
+ this.config = clone(config);
20219
+ this.updateConfig();
20220
+ this.__listenEvents();
20221
+ target.waitLeafer(() => {
20222
+ this.parent = target;
20223
+ this.__bindLeafer(target.leafer);
20224
+ });
20225
+ if (this.mergedConfig.hideOnActionEnd) this.opacity = 0;
20226
+ }
20227
+ static registerTheme(theme, themeConfig) {
20228
+ S.themeMap[theme] = themeConfig;
20229
+ }
20230
+ static getTheme(theme) {
20231
+ return theme && S.themeMap[theme];
20232
+ }
20233
+ static hasTheme(theme) {
20234
+ return theme && !!S.themeMap[theme];
20235
+ }
20236
+ updateConfig() {
20237
+ const {scrollConfig: scrollConfig} = this.target;
20238
+ const themeConfig = S.getTheme(scrollConfig && S.hasTheme(scrollConfig.theme) && scrollConfig.theme || this.config.theme);
20239
+ const mergedConfig = this.mergedConfig = clone(this.config);
20240
+ assign(mergedConfig, themeConfig);
20241
+ if (scrollConfig) assign(mergedConfig, scrollConfig);
20242
+ this.updateStyle(mergedConfig.style);
20243
+ }
20244
+ updateStyle(style) {
20245
+ if (!this.scrollXBar) this.addMany(this.scrollXBar = new Box, this.scrollYBar = new Box);
20246
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
20247
+ scrollXBar.set(style);
20248
+ scrollYBar.set(style);
20249
+ scrollXBar.draggable = "x";
20250
+ scrollYBar.draggable = "y";
20251
+ }
20252
+ update(check = true) {
20253
+ if (this.dragScrolling) return;
20254
+ const {target: target, targetOverflow: targetOverflow, targetWorldBounds: targetWorldBounds, viewportBounds: viewportBounds, contentBounds: contentBounds} = this, layout = target.__layout, {overflow: overflow} = target.__;
20255
+ const {childrenRenderBounds: childrenRenderBounds} = layout;
20256
+ const {boxBounds: boxBounds, worldBoxBounds: worldBoxBounds} = layout;
20257
+ const isSameWorldBounds = check && targetOverflow === overflow && targetWorldBounds.isSame(worldBoxBounds);
20258
+ const isSameConfig = layout.scrollConfigChanged ? (this.updateConfig(), layout.scrollConfigChanged = false) : true;
20259
+ const nowContentBounds = tempBounds.set(viewportBounds).add(childrenRenderBounds);
20260
+ if (isSameWorldBounds && isSameConfig && contentBounds.isSame(nowContentBounds)) return;
20261
+ this.targetOverflow = overflow;
20262
+ viewportBounds.set(boxBounds);
20263
+ targetWorldBounds.set(worldBoxBounds);
20264
+ contentBounds.set(nowContentBounds);
20265
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this, {size: size, endsMargin: endsMargin, minSize: minSize} = this.mergedConfig, {width: width, height: height} = viewportBounds;
20266
+ this.contentRealX = contentBounds.x - target.scrollX;
20267
+ this.contentRealY = contentBounds.y - target.scrollY;
20268
+ this.ratioX = viewportBounds.width / contentBounds.width;
20269
+ this.ratioY = viewportBounds.height / contentBounds.height;
20270
+ const min = size + endsMargin * 2 + minSize;
20271
+ scrollXBar.visible = float(contentBounds.width) > float(width) && overflow !== "y-scroll" && width > min;
20272
+ scrollYBar.visible = float(contentBounds.height) > float(height) && overflow !== "x-scroll" && height > min;
20273
+ this.updateScrollBar();
20274
+ }
20275
+ updateScrollBar() {
20276
+ const {target: target, viewportBounds: viewportBounds, contentBounds: contentBounds, ratioX: ratioX, ratioY: ratioY, scrollXBar: scrollXBar, scrollYBar: scrollYBar, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
20277
+ let {size: size, cornerRadius: cornerRadius, endsMargin: endsMargin, sideMargin: sideMargin, minSize: minSize, scaleFixed: scaleFixed, scrollType: scrollType} = this.mergedConfig;
20278
+ const scale = scaleFixed ? target.getClampRenderScale() : 1;
20279
+ endsMargin /= scale;
20280
+ sideMargin /= scale;
20281
+ size /= scale;
20282
+ if (isUndefined(cornerRadius)) cornerRadius = size / 2;
20283
+ if (scrollXBar.visible) {
20284
+ scrollXBounds.set(viewportBounds).shrink([ endsMargin, scrollYBar.visible ? size + sideMargin : endsMargin, sideMargin, endsMargin ]);
20285
+ const scrollRatioX = this.scrollRatioX = scrollXBounds.width / contentBounds.width;
20286
+ scrollXBar.set({
20287
+ x: scrollXBounds.x - contentBounds.x * scrollRatioX,
20288
+ y: scrollXBounds.maxY - size,
20289
+ width: Math.max(scrollXBounds.width * ratioX, minSize),
20290
+ height: size,
20291
+ cornerRadius: cornerRadius,
20292
+ dragBounds: scrollXBounds,
20293
+ hittable: scrollType !== "move"
20294
+ });
20295
+ }
20296
+ if (scrollYBar.visible) {
20297
+ scrollYBounds.set(viewportBounds).shrink([ endsMargin, sideMargin, scrollXBar.visible ? size + sideMargin : endsMargin, endsMargin ]);
20298
+ const scrollRatioY = this.scrollRatioY = scrollYBounds.height / contentBounds.height;
20299
+ scrollYBar.set({
20300
+ x: scrollYBounds.maxX - size,
20301
+ y: scrollYBounds.y - contentBounds.y * scrollRatioY,
20302
+ width: size,
20303
+ height: Math.max(scrollYBounds.height * ratioY, minSize),
20304
+ cornerRadius: cornerRadius,
20305
+ dragBounds: scrollYBounds,
20306
+ hittable: scrollType !== "move"
20307
+ });
20308
+ }
20309
+ this.x = -this.target.scrollX;
20310
+ this.y = -this.target.scrollY;
20311
+ LeafHelper.updateAllMatrix(this);
20312
+ BranchHelper.updateBounds(this);
20313
+ LeafHelper.updateAllChange(this);
20314
+ }
20315
+ onDrag(e) {
20316
+ if (this.mergedConfig.scrollType === "move") return;
20317
+ this.dragScrolling = true;
20318
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
20319
+ const scrollX = e.current === scrollXBar;
20320
+ if (scrollX) target.scrollX = -((scrollXBar.x - scrollXBounds.x) / this.scrollRatioX + this.contentRealX); else target.scrollY = -((scrollYBar.y - scrollYBounds.y) / this.scrollRatioY + this.contentRealY);
20321
+ }
20322
+ onDragEnd() {
20323
+ if (this.mergedConfig.scrollType === "move") return;
20324
+ this.dragScrolling = false;
20325
+ }
20326
+ onMove(e) {
20327
+ if (!this.canUse) return;
20328
+ this.onEnter();
20329
+ const {scrollType: scrollType, stopDefault: stopDefault} = this.mergedConfig;
20330
+ if (scrollType === "drag") return;
20331
+ const {viewportBounds: viewportBounds, contentBounds: contentBounds, scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
20332
+ if (scrollXBar.visible || scrollYBar.visible) {
20333
+ const move = e.getInnerMove(this.target);
20334
+ DragBoundsHelper.getValidMove(contentBounds, viewportBounds, "inner", move, true);
20335
+ let needStop;
20336
+ if (move.x && scrollXBar.visible) this.target.scrollX += move.x, needStop = true;
20337
+ if (move.y && scrollYBar.visible) this.target.scrollY += move.y, needStop = true;
20338
+ if (needStop || stopDefault) e.stop();
20339
+ if (stopDefault) e.stopDefault();
20340
+ }
20341
+ }
20342
+ onMoveEnd(e) {
20343
+ if (!this.canUse) return;
20344
+ if (!this.target.hit(e)) this.onLeave();
20345
+ }
20346
+ onEnter() {
20347
+ if (!this.canUse) return;
20348
+ clearTimeout(this.hideTimer);
20349
+ this.killAnimate();
20350
+ this.opacity = 1;
20351
+ }
20352
+ onLeave() {
20353
+ if (!this.canUse) return;
20354
+ clearTimeout(this.hideTimer);
20355
+ if (this.mergedConfig.hideOnActionEnd) this.hideTimer = setTimeout(() => {
20356
+ this.set({
20357
+ opacity: 0
20358
+ }, Plugin.has("animate"));
20359
+ }, 600);
20360
+ }
20361
+ onResize() {
20362
+ if (this.canUse) this.update();
20363
+ }
20364
+ __listenEvents() {
20365
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target} = this;
20366
+ this.__eventIds = [ scrollXBar.on_(DragEvent.DRAG, this.onDrag, this), scrollXBar.on_(DragEvent.END, this.onDragEnd, this), scrollYBar.on_(DragEvent.DRAG, this.onDrag, this), scrollYBar.on_(DragEvent.END, this.onDragEnd, this), target.on_(PointerEvent.ENTER, this.onEnter, this), target.on_(PointerEvent.LEAVE, this.onLeave, this), target.on_(MoveEvent.BEFORE_MOVE, this.onMove, this), target.on_(MoveEvent.END, this.onMoveEnd, this), target.on_(BoundsEvent.WORLD, this.onResize, this), target.on_(ChildEvent.DESTROY, this.destroy, this) ];
20367
+ }
20368
+ __removeListenEvents() {
20369
+ this.off_(this.__eventIds);
20370
+ }
20371
+ destroy() {
20372
+ if (!this.destroyed) {
20373
+ this.__removeListenEvents();
20374
+ const {target: target} = this;
20375
+ target.scroller = target.topChildren = target.hasScroller = undefined;
20376
+ this.target = this.config = null;
20377
+ super.destroy();
20378
+ }
20379
+ }
20380
+ }
20381
+
20382
+ Scroller.themeMap = {};
20383
+
20384
+ const S = Scroller;
20385
+
20386
+ function scrollConfigType(defaultValue) {
20387
+ return decorateLeafAttr(defaultValue, key => attr({
20388
+ set(value) {
20389
+ if (this.__setAttr(key, value)) {
20390
+ const layout = this.__layout;
20391
+ layout.scrollConfigChanged = true;
20392
+ doBoundsType(this);
20393
+ }
20394
+ }
20395
+ }));
20396
+ }
20397
+
20398
+ Plugin.add("scroller");
20399
+
20400
+ const box = Box.prototype;
20401
+
20402
+ Box.addAttr("scrollConfig", undefined, scrollConfigType);
20403
+
20404
+ box.__checkScroll = function(isScrollMode) {
20405
+ if (isScrollMode && this.isOverflow) {
20406
+ if (!this.scroller) {
20407
+ this.scroller = new Scroller(this);
20408
+ if (!this.topChildren) this.topChildren = [];
20409
+ this.topChildren.push(this.scroller);
20410
+ }
20411
+ this.hasScroller = true;
20412
+ } else {
20413
+ if (this.hasScroller && !this.scroller.dragScrolling) {
20414
+ this.hasScroller = undefined;
20415
+ this.scroller.update();
20416
+ }
20417
+ }
20418
+ };
20419
+
20420
+ Scroller.registerTheme("light", {
20421
+ style: {
20422
+ fill: "black"
20423
+ }
20424
+ });
20425
+
20426
+ Scroller.registerTheme("dark", {
20427
+ style: {
20428
+ fill: "white"
20429
+ }
20430
+ });
20431
+
20432
+ export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, Scroller, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$3 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$4 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };