@leafer/worker 1.9.7 → 1.9.9

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
@@ -229,17 +229,32 @@ var LeaferUI = function(exports) {
229
229
  this.__input = this.__middle = null;
230
230
  }
231
231
  }
232
- const {round: round$6, pow: pow$2, PI: PI$4} = Math;
233
- const MathHelper = {
234
- within(value, min, max) {
235
- if (isObject(min)) max = min.max, min = min.min;
236
- if (!isUndefined(min) && value < min) value = min;
237
- if (!isUndefined(max) && value > max) value = max;
238
- return value;
232
+ let tempA, tempB, tempTo;
233
+ const {max: max$5} = Math, tempFour = [ 0, 0, 0, 0 ];
234
+ const FourNumberHelper = {
235
+ zero: [ ...tempFour ],
236
+ tempFour: tempFour,
237
+ set(to, top, right, bottom, left) {
238
+ if (right === undefined) right = bottom = left = top;
239
+ to[0] = top;
240
+ to[1] = right;
241
+ to[2] = bottom;
242
+ to[3] = left;
243
+ return to;
244
+ },
245
+ setTemp(top, right, bottom, left) {
246
+ return set$1(tempFour, top, right, bottom, left);
239
247
  },
240
- fourNumber(num, maxValue) {
248
+ toTempAB(a, b, change) {
249
+ tempTo = change ? isNumber(a) ? b : a : [];
250
+ if (isNumber(a)) tempA = setTemp(a), tempB = b; else if (isNumber(b)) tempA = a,
251
+ tempB = setTemp(b); else tempA = a, tempB = b;
252
+ if (tempA.length !== 4) tempA = get$5(tempA);
253
+ if (tempB.length !== 4) tempB = get$5(tempB);
254
+ },
255
+ get(num, maxValue) {
241
256
  let data;
242
- if (isArray(num)) {
257
+ if (!isNumber(num)) {
243
258
  switch (num.length) {
244
259
  case 4:
245
260
  data = isUndefined(maxValue) ? num : [ ...num ];
@@ -262,9 +277,36 @@ var LeaferUI = function(exports) {
262
277
  }
263
278
  }
264
279
  if (!data) data = [ num, num, num, num ];
265
- if (maxValue) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
280
+ if (!isUndefined(maxValue)) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
266
281
  return data;
267
282
  },
283
+ max(t, other, change) {
284
+ if (isNumber(t) && isNumber(other)) return max$5(t, other);
285
+ toTempAB(t, other, change);
286
+ return set$1(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
+ },
288
+ add(t, other, change) {
289
+ if (isNumber(t) && isNumber(other)) return t + other;
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]);
292
+ },
293
+ swapAndScale(t, scaleX, scaleY, change) {
294
+ if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
295
+ const to = change ? t : [];
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);
298
+ }
299
+ };
300
+ const {set: set$1, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
301
+ const {round: round$6, pow: pow$2, PI: PI$4} = Math;
302
+ const MathHelper = {
303
+ within(value, min, max) {
304
+ if (isObject(min)) max = min.max, min = min.min;
305
+ if (!isUndefined(min) && value < min) value = min;
306
+ if (!isUndefined(max) && value > max) value = max;
307
+ return value;
308
+ },
309
+ fourNumber: FourNumberHelper.get,
268
310
  formatRotation(rotation, unsign) {
269
311
  rotation %= 360;
270
312
  if (unsign) {
@@ -402,13 +444,13 @@ var LeaferUI = function(exports) {
402
444
  to.f = t.f * pixelRatio;
403
445
  },
404
446
  scaleOfOuter(t, origin, scaleX, scaleY) {
405
- M$a.toInnerPoint(t, origin, tempPoint$4);
406
- M$a.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
447
+ M$b.toInnerPoint(t, origin, tempPoint$4);
448
+ M$b.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
407
449
  },
408
450
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
409
- M$a.translateInner(t, origin.x, origin.y);
410
- M$a.scale(t, scaleX, scaleY);
411
- M$a.translateInner(t, -origin.x, -origin.y);
451
+ M$b.translateInner(t, origin.x, origin.y);
452
+ M$b.scale(t, scaleX, scaleY);
453
+ M$b.translateInner(t, -origin.x, -origin.y);
412
454
  },
413
455
  rotate(t, rotation) {
414
456
  const {a: a, b: b, c: c, d: d} = t;
@@ -421,13 +463,13 @@ var LeaferUI = function(exports) {
421
463
  t.d = c * sinR + d * cosR;
422
464
  },
423
465
  rotateOfOuter(t, origin, rotation) {
424
- M$a.toInnerPoint(t, origin, tempPoint$4);
425
- M$a.rotateOfInner(t, tempPoint$4, rotation);
466
+ M$b.toInnerPoint(t, origin, tempPoint$4);
467
+ M$b.rotateOfInner(t, tempPoint$4, rotation);
426
468
  },
427
469
  rotateOfInner(t, origin, rotation) {
428
- M$a.translateInner(t, origin.x, origin.y);
429
- M$a.rotate(t, rotation);
430
- M$a.translateInner(t, -origin.x, -origin.y);
470
+ M$b.translateInner(t, origin.x, origin.y);
471
+ M$b.rotate(t, rotation);
472
+ M$b.translateInner(t, -origin.x, -origin.y);
431
473
  },
432
474
  skew(t, skewX, skewY) {
433
475
  const {a: a, b: b, c: c, d: d} = t;
@@ -443,13 +485,13 @@ var LeaferUI = function(exports) {
443
485
  }
444
486
  },
445
487
  skewOfOuter(t, origin, skewX, skewY) {
446
- M$a.toInnerPoint(t, origin, tempPoint$4);
447
- M$a.skewOfInner(t, tempPoint$4, skewX, skewY);
488
+ M$b.toInnerPoint(t, origin, tempPoint$4);
489
+ M$b.skewOfInner(t, tempPoint$4, skewX, skewY);
448
490
  },
449
491
  skewOfInner(t, origin, skewX, skewY = 0) {
450
- M$a.translateInner(t, origin.x, origin.y);
451
- M$a.skew(t, skewX, skewY);
452
- M$a.translateInner(t, -origin.x, -origin.y);
492
+ M$b.translateInner(t, origin.x, origin.y);
493
+ M$b.skew(t, skewX, skewY);
494
+ M$b.translateInner(t, -origin.x, -origin.y);
453
495
  },
454
496
  multiply(t, child) {
455
497
  const {a: a, b: b, c: c, d: d, e: e, f: f} = t;
@@ -488,15 +530,15 @@ var LeaferUI = function(exports) {
488
530
  to.f = e * parent.b + f * parent.d + parent.f;
489
531
  },
490
532
  divide(t, child) {
491
- M$a.multiply(t, M$a.tempInvert(child));
533
+ M$b.multiply(t, M$b.tempInvert(child));
492
534
  },
493
535
  divideParent(t, parent) {
494
- M$a.multiplyParent(t, M$a.tempInvert(parent));
536
+ M$b.multiplyParent(t, M$b.tempInvert(parent));
495
537
  },
496
538
  tempInvert(t) {
497
- const {tempMatrix: tempMatrix} = M$a;
498
- M$a.copy(tempMatrix, t);
499
- M$a.invert(tempMatrix);
539
+ const {tempMatrix: tempMatrix} = M$b;
540
+ M$b.copy(tempMatrix, t);
541
+ M$b.invert(tempMatrix);
500
542
  return tempMatrix;
501
543
  },
502
544
  invert(t) {
@@ -574,7 +616,7 @@ var LeaferUI = function(exports) {
574
616
  }
575
617
  t.e = x;
576
618
  t.f = y;
577
- if (origin = origin || around) M$a.translateInner(t, -origin.x, -origin.y, !around);
619
+ if (origin = origin || around) M$b.translateInner(t, -origin.x, -origin.y, !around);
578
620
  },
579
621
  getLayout(t, origin, around, firstSkewY) {
580
622
  const {a: a, b: b, c: c, d: d, e: e, f: f} = t;
@@ -635,10 +677,10 @@ var LeaferUI = function(exports) {
635
677
  return world;
636
678
  },
637
679
  reset(t) {
638
- M$a.set(t);
680
+ M$b.set(t);
639
681
  }
640
682
  };
641
- const M$a = MatrixHelper;
683
+ const M$b = MatrixHelper;
642
684
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
643
685
  const {sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5} = Math;
644
686
  const PointHelper = {
@@ -973,7 +1015,7 @@ var LeaferUI = function(exports) {
973
1015
  MatrixHelper.reset(this);
974
1016
  }
975
1017
  }
976
- const tempMatrix$1 = new Matrix;
1018
+ const tempMatrix$2 = new Matrix;
977
1019
  const TwoPointBoundsHelper = {
978
1020
  tempPointBounds: {},
979
1021
  setPoint(t, minX, minY) {
@@ -1103,9 +1145,9 @@ var LeaferUI = function(exports) {
1103
1145
  let right$4, bottom$3, boundsRight, boundsBottom;
1104
1146
  const point$2 = {};
1105
1147
  const toPoint$5 = {};
1106
- const tempBounds$2 = {};
1148
+ const tempBounds$3 = {};
1107
1149
  const BoundsHelper = {
1108
- tempBounds: tempBounds$2,
1150
+ tempBounds: tempBounds$3,
1109
1151
  set(t, x = 0, y = 0, width = 0, height = 0) {
1110
1152
  t.x = x;
1111
1153
  t.y = y;
@@ -1156,19 +1198,11 @@ var LeaferUI = function(exports) {
1156
1198
  B.move(t, x, y);
1157
1199
  return t;
1158
1200
  },
1159
- toOffsetOutBounds(t, to, parent) {
1160
- if (!to) {
1161
- to = t;
1162
- } else {
1163
- copy$c(to, t);
1164
- }
1165
- if (parent) {
1166
- to.offsetX = -(B.maxX(parent) - t.x);
1167
- to.offsetY = -(B.maxY(parent) - t.y);
1168
- } else {
1169
- to.offsetX = t.x + t.width;
1170
- to.offsetY = t.y + t.height;
1171
- }
1201
+ toOffsetOutBounds(t, to, offsetBounds) {
1202
+ if (!to) to = t; else copy$c(to, t);
1203
+ if (!offsetBounds) offsetBounds = t;
1204
+ to.offsetX = B.maxX(offsetBounds);
1205
+ to.offsetY = B.maxY(offsetBounds);
1172
1206
  B.move(to, -to.offsetX, -to.offsetY);
1173
1207
  },
1174
1208
  scale(t, scaleX, scaleY = scaleX, onlySize) {
@@ -1182,9 +1216,9 @@ var LeaferUI = function(exports) {
1182
1216
  t.height *= scaleY;
1183
1217
  },
1184
1218
  tempToOuterOf(t, matrix) {
1185
- B.copy(tempBounds$2, t);
1186
- B.toOuterOf(tempBounds$2, matrix);
1187
- return tempBounds$2;
1219
+ B.copy(tempBounds$3, t);
1220
+ B.toOuterOf(tempBounds$3, matrix);
1221
+ return tempBounds$3;
1188
1222
  },
1189
1223
  getOuterOf(t, matrix) {
1190
1224
  t = Object.assign({}, t);
@@ -1242,9 +1276,9 @@ var LeaferUI = function(exports) {
1242
1276
  put(t, put, align = "center", putScale = 1, changeSize = true, to) {
1243
1277
  to || (to = put);
1244
1278
  if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
1245
- tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
1246
- tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
1247
- AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
1279
+ tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
1280
+ tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
1281
+ AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
1248
1282
  },
1249
1283
  getSpread(t, spread, side) {
1250
1284
  const n = {};
@@ -1314,7 +1348,7 @@ var LeaferUI = function(exports) {
1314
1348
  first = false;
1315
1349
  if (!addMode) copy$c(t, bounds);
1316
1350
  } else {
1317
- add$1(t, bounds);
1351
+ add$2(t, bounds);
1318
1352
  }
1319
1353
  }
1320
1354
  }
@@ -1328,7 +1362,7 @@ var LeaferUI = function(exports) {
1328
1362
  B.set(t, point.x, point.y);
1329
1363
  },
1330
1364
  addPoint(t, point) {
1331
- add$1(t, point, true);
1365
+ add$2(t, point, true);
1332
1366
  },
1333
1367
  getPoints(t) {
1334
1368
  const {x: x, y: y, width: width, height: height} = t;
@@ -1397,7 +1431,7 @@ var LeaferUI = function(exports) {
1397
1431
  }
1398
1432
  };
1399
1433
  const B = BoundsHelper;
1400
- const {add: add$1, copy: copy$c} = B;
1434
+ const {add: add$2, copy: copy$c} = B;
1401
1435
  class Bounds {
1402
1436
  get minX() {
1403
1437
  return BoundsHelper.minX(this);
@@ -1540,7 +1574,7 @@ var LeaferUI = function(exports) {
1540
1574
  BoundsHelper.reset(this);
1541
1575
  }
1542
1576
  }
1543
- const tempBounds$1 = new Bounds;
1577
+ const tempBounds$2 = new Bounds;
1544
1578
  class AutoBounds {
1545
1579
  constructor(top, right, bottom, left, width, height) {
1546
1580
  isObject(top) ? this.copy(top) : this.set(top, right, bottom, left, width, height);
@@ -2103,7 +2137,7 @@ var LeaferUI = function(exports) {
2103
2137
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2104
2138
  if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
2105
2139
  pixelScale(matrix, pixelRatio, w);
2106
- if (pixelSnap) {
2140
+ if (pixelSnap && !matrix.ignorePixelSnap) {
2107
2141
  if (matrix.half && matrix.half * pixelRatio % 2) w.e = round$4(w.e - .5) + .5, w.f = round$4(w.f - .5) + .5; else w.e = round$4(w.e),
2108
2142
  w.f = round$4(w.f);
2109
2143
  }
@@ -2386,12 +2420,12 @@ var LeaferUI = function(exports) {
2386
2420
  const {sin: sin$4, cos: cos$4, hypot: hypot, atan2: atan2$1, ceil: ceil$2, abs: abs$6, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
2387
2421
  const {setPoint: setPoint$4, addPoint: addPoint$2} = TwoPointBoundsHelper;
2388
2422
  const {set: set, toNumberPoints: toNumberPoints$1} = PointHelper;
2389
- const {M: M$9, L: L$a, C: C$8, Q: Q$7, Z: Z$8} = PathCommandMap;
2423
+ const {M: M$a, L: L$a, C: C$8, Q: Q$7, Z: Z$8} = PathCommandMap;
2390
2424
  const tempPoint$2 = {};
2391
2425
  const BezierHelper = {
2392
2426
  points(data, originPoints, curve, close) {
2393
2427
  let points = toNumberPoints$1(originPoints);
2394
- data.push(M$9, points[0], points[1]);
2428
+ data.push(M$a, points[0], points[1]);
2395
2429
  if (curve && points.length > 5) {
2396
2430
  let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
2397
2431
  let ba, cb, d, len = points.length;
@@ -2498,7 +2532,7 @@ var LeaferUI = function(exports) {
2498
2532
  let startX = x = rotationCos * radiusX * startCos - rotationSin * radiusY * startSin;
2499
2533
  let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
2500
2534
  let fromX = cx + x, fromY = cy + y;
2501
- if (data) data.push(data.length ? L$a : M$9, fromX, fromY);
2535
+ if (data) data.push(data.length ? L$a : M$a, fromX, fromY);
2502
2536
  if (setPointBounds) setPoint$4(setPointBounds, fromX, fromY);
2503
2537
  if (setStartPoint) set(setStartPoint, fromX, fromY);
2504
2538
  for (let i = 0; i < parts; i++) {
@@ -2623,7 +2657,7 @@ var LeaferUI = function(exports) {
2623
2657
  }
2624
2658
  }
2625
2659
  };
2626
- const {M: M$8, 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;
2660
+ 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;
2627
2661
  const {rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1} = BezierHelper;
2628
2662
  const {ellipticalArc: ellipticalArc} = EllipseHelper;
2629
2663
  const debug$f = Debug.get("PathConvert");
@@ -2710,10 +2744,10 @@ var LeaferUI = function(exports) {
2710
2744
  old[i + 1] += x;
2711
2745
  old[i + 2] += y;
2712
2746
 
2713
- case M$8:
2747
+ case M$9:
2714
2748
  x = old[i + 1];
2715
2749
  y = old[i + 2];
2716
- data.push(M$8, x, y);
2750
+ data.push(M$9, x, y);
2717
2751
  i += 3;
2718
2752
  break;
2719
2753
 
@@ -2900,7 +2934,7 @@ var LeaferUI = function(exports) {
2900
2934
  list.forEach(item => {
2901
2935
  switch (item.name) {
2902
2936
  case "M":
2903
- data.push(M$8, item.x, item.y);
2937
+ data.push(M$9, item.x, item.y);
2904
2938
  break;
2905
2939
 
2906
2940
  case "L":
@@ -2937,7 +2971,7 @@ var LeaferUI = function(exports) {
2937
2971
  }
2938
2972
  };
2939
2973
  const {current: current, pushData: pushData, copyData: copyData} = PathConvert;
2940
- const {M: M$7, L: L$8, C: C$6, Q: Q$5, Z: Z$6, N: N$4, D: D$5, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4} = PathCommandMap;
2974
+ const {M: M$8, L: L$8, C: C$6, Q: Q$5, Z: Z$6, N: N$4, D: D$5, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4} = PathCommandMap;
2941
2975
  const {getMinDistanceFrom: getMinDistanceFrom, getRadianFrom: getRadianFrom} = PointHelper;
2942
2976
  const {tan: tan, min: min, abs: abs$5} = Math;
2943
2977
  const startPoint = {};
@@ -2946,7 +2980,7 @@ var LeaferUI = function(exports) {
2946
2980
  data.length = 0;
2947
2981
  },
2948
2982
  moveTo(data, x, y) {
2949
- data.push(M$7, x, y);
2983
+ data.push(M$8, x, y);
2950
2984
  },
2951
2985
  lineTo(data, x, y) {
2952
2986
  data.push(L$8, x, y);
@@ -3001,12 +3035,12 @@ var LeaferUI = function(exports) {
3001
3035
  },
3002
3036
  drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
3003
3037
  BezierHelper.ellipse(null, x, y, radiusX, radiusY, isNull(rotation) ? 0 : rotation, isNull(startAngle) ? 0 : startAngle, isNull(endAngle) ? 360 : endAngle, anticlockwise, null, null, startPoint);
3004
- data.push(M$7, startPoint.x, startPoint.y);
3038
+ data.push(M$8, startPoint.x, startPoint.y);
3005
3039
  ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
3006
3040
  },
3007
3041
  drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
3008
3042
  BezierHelper.arc(null, x, y, radius, isNull(startAngle) ? 0 : startAngle, isNull(endAngle) ? 360 : endAngle, anticlockwise, null, null, startPoint);
3009
- data.push(M$7, startPoint.x, startPoint.y);
3043
+ data.push(M$8, startPoint.x, startPoint.y);
3010
3044
  arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
3011
3045
  },
3012
3046
  drawPoints(data, points, curve, close) {
@@ -3104,7 +3138,7 @@ var LeaferUI = function(exports) {
3104
3138
  }
3105
3139
  paint() {}
3106
3140
  }
3107
- const {M: M$6, L: L$7, C: C$5, Q: Q$4, Z: Z$5, N: N$3, D: D$4, X: X$3, G: G$3, F: F$4, O: O$4, P: P$3, U: U$3} = PathCommandMap;
3141
+ const {M: M$7, L: L$7, C: C$5, Q: Q$4, Z: Z$5, N: N$3, D: D$4, X: X$3, G: G$3, F: F$4, O: O$4, P: P$3, U: U$3} = PathCommandMap;
3108
3142
  const debug$e = Debug.get("PathDrawer");
3109
3143
  const PathDrawer = {
3110
3144
  drawPathByData(drawer, data) {
@@ -3114,7 +3148,7 @@ var LeaferUI = function(exports) {
3114
3148
  while (i < len) {
3115
3149
  command = data[i];
3116
3150
  switch (command) {
3117
- case M$6:
3151
+ case M$7:
3118
3152
  drawer.moveTo(data[i + 1], data[i + 2]);
3119
3153
  i += 3;
3120
3154
  break;
@@ -3186,7 +3220,7 @@ var LeaferUI = function(exports) {
3186
3220
  }
3187
3221
  }
3188
3222
  };
3189
- const {M: M$5, L: L$6, C: C$4, Q: Q$3, Z: Z$4, N: N$2, D: D$3, X: X$2, G: G$2, F: F$3, O: O$3, P: P$2, U: U$2} = PathCommandMap;
3223
+ const {M: M$6, L: L$6, C: C$4, Q: Q$3, Z: Z$4, N: N$2, D: D$3, X: X$2, G: G$2, F: F$3, O: O$3, P: P$2, U: U$2} = PathCommandMap;
3190
3224
  const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
3191
3225
  const {addPointBounds: addPointBounds, copy: copy$a, addPoint: addPoint$1, setPoint: setPoint$3, addBounds: addBounds, toBounds: toBounds$2} = TwoPointBoundsHelper;
3192
3226
  const debug$d = Debug.get("PathBounds");
@@ -3213,7 +3247,7 @@ var LeaferUI = function(exports) {
3213
3247
  }
3214
3248
  }
3215
3249
  switch (command) {
3216
- case M$5:
3250
+ case M$6:
3217
3251
  case L$6:
3218
3252
  x = data[i + 1];
3219
3253
  y = data[i + 2];
@@ -3312,7 +3346,7 @@ var LeaferUI = function(exports) {
3312
3346
  }
3313
3347
  }
3314
3348
  };
3315
- const {M: M$4, L: L$5, Z: Z$3} = PathCommandMap;
3349
+ const {M: M$5, L: L$5, Z: Z$3} = PathCommandMap;
3316
3350
  const {getCenterX: getCenterX, getCenterY: getCenterY} = PointHelper;
3317
3351
  const {arcTo: arcTo} = PathCommandDataHelper;
3318
3352
  const PathCorner = {
@@ -3324,16 +3358,16 @@ var LeaferUI = function(exports) {
3324
3358
  while (i < len) {
3325
3359
  command = data[i];
3326
3360
  switch (command) {
3327
- case M$4:
3361
+ case M$5:
3328
3362
  startX = lastX = data[i + 1];
3329
3363
  startY = lastY = data[i + 2];
3330
3364
  i += 3;
3331
3365
  if (data[i] === L$5) {
3332
3366
  secondX = data[i + 1];
3333
3367
  secondY = data[i + 2];
3334
- smooth.push(M$4, getCenterX(startX, secondX), getCenterY(startY, secondY));
3368
+ smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3335
3369
  } else {
3336
- smooth.push(M$4, startX, startY);
3370
+ smooth.push(M$5, startX, startY);
3337
3371
  }
3338
3372
  break;
3339
3373
 
@@ -3753,7 +3787,7 @@ var LeaferUI = function(exports) {
3753
3787
  };
3754
3788
  const I$1 = ImageManager;
3755
3789
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3756
- const {floor: floor$2, max: max$2} = Math;
3790
+ const {floor: floor$2, max: max$4} = Math;
3757
3791
  class LeaferImage {
3758
3792
  get url() {
3759
3793
  return this.config.url;
@@ -3841,7 +3875,7 @@ var LeaferUI = function(exports) {
3841
3875
  }
3842
3876
  if (data) return data;
3843
3877
  }
3844
- const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
3878
+ const canvas = Platform.origin.createCanvas(max$4(floor$2(width + (xGap || 0)), 1), max$4(floor$2(height + (yGap || 0)), 1));
3845
3879
  const ctx = canvas.getContext("2d");
3846
3880
  if (opacity) ctx.globalAlpha = opacity;
3847
3881
  ctx.imageSmoothingEnabled = smooth === false ? false : true;
@@ -4573,7 +4607,7 @@ var LeaferUI = function(exports) {
4573
4607
  }
4574
4608
  };
4575
4609
  const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$3} = LeafHelper;
4576
- const {toOuterOf: toOuterOf$2, getPoints: getPoints, copy: copy$8} = BoundsHelper;
4610
+ const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$8} = BoundsHelper;
4577
4611
  const localContent = "_localContentBounds";
4578
4612
  const worldContent = "_worldContentBounds", worldBox = "_worldBoxBounds", worldStroke = "_worldStrokeBounds";
4579
4613
  class LeafLayout {
@@ -4593,7 +4627,7 @@ var LeaferUI = function(exports) {
4593
4627
  this._renderBounds = bounds;
4594
4628
  }
4595
4629
  get localContentBounds() {
4596
- toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4630
+ toOuterOf$3(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4597
4631
  return this[localContent];
4598
4632
  }
4599
4633
  get localStrokeBounds() {
@@ -4603,15 +4637,15 @@ var LeaferUI = function(exports) {
4603
4637
  return this._localRenderBounds || this;
4604
4638
  }
4605
4639
  get worldContentBounds() {
4606
- toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4640
+ toOuterOf$3(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4607
4641
  return this[worldContent];
4608
4642
  }
4609
4643
  get worldBoxBounds() {
4610
- toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4644
+ toOuterOf$3(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4611
4645
  return this[worldBox];
4612
4646
  }
4613
4647
  get worldStrokeBounds() {
4614
- toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4648
+ toOuterOf$3(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4615
4649
  return this[worldStroke];
4616
4650
  }
4617
4651
  get a() {
@@ -5382,12 +5416,12 @@ var LeaferUI = function(exports) {
5382
5416
  };
5383
5417
  const {updateMatrix: updateMatrix$3, updateAllMatrix: updateAllMatrix$3} = LeafHelper;
5384
5418
  const {updateBounds: updateBounds$2} = BranchHelper;
5385
- const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$7} = BoundsHelper;
5419
+ const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$3, copy: copy$7} = BoundsHelper;
5386
5420
  const {toBounds: toBounds$1} = PathBounds;
5387
5421
  const LeafBounds = {
5388
5422
  __updateWorldBounds() {
5389
5423
  const layout = this.__layout;
5390
- toOuterOf$1(layout.renderBounds, this.__world, this.__world);
5424
+ toOuterOf$2(layout.renderBounds, this.__world, this.__world);
5391
5425
  if (layout.resized) {
5392
5426
  if (layout.resized === "inner") this.__onUpdateSize();
5393
5427
  if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
@@ -5443,13 +5477,13 @@ var LeaferUI = function(exports) {
5443
5477
  __updateLocalBoxBounds() {
5444
5478
  if (this.__hasMotionPath) this.__updateMotionPath();
5445
5479
  if (this.__hasAutoLayout) this.__updateAutoLayout();
5446
- toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
5480
+ toOuterOf$2(this.__layout.boxBounds, this.__local, this.__local);
5447
5481
  },
5448
5482
  __updateLocalStrokeBounds() {
5449
- toOuterOf$1(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5483
+ toOuterOf$2(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5450
5484
  },
5451
5485
  __updateLocalRenderBounds() {
5452
- toOuterOf$1(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5486
+ toOuterOf$2(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5453
5487
  },
5454
5488
  __updateBoxBounds(_secondLayout, _bounds) {
5455
5489
  const b = this.__layout.boxBounds;
@@ -5487,11 +5521,11 @@ var LeaferUI = function(exports) {
5487
5521
  },
5488
5522
  __updateStrokeBounds(_bounds) {
5489
5523
  const layout = this.__layout;
5490
- copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5524
+ copyAndSpread$3(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5491
5525
  },
5492
5526
  __updateRenderBounds(_bounds) {
5493
- const layout = this.__layout;
5494
- layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$7(layout.renderBounds, layout.strokeBounds);
5527
+ const layout = this.__layout, {renderSpread: renderSpread} = layout;
5528
+ isNumber(renderSpread) && renderSpread <= 0 ? copy$7(layout.renderBounds, layout.strokeBounds) : copyAndSpread$3(layout.renderBounds, layout.boxBounds, renderSpread);
5495
5529
  }
5496
5530
  };
5497
5531
  const LeafRender = {
@@ -5583,9 +5617,10 @@ var LeaferUI = function(exports) {
5583
5617
  };
5584
5618
  const tempScaleData$1 = {};
5585
5619
  const {LEAF: LEAF, create: create} = IncrementId;
5620
+ const {stintSet: stintSet$3} = DataHelper;
5586
5621
  const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
5587
- const {toOuterOf: toOuterOf} = BoundsHelper;
5588
- const {copy: copy$6, move: move$6} = PointHelper;
5622
+ const {toOuterOf: toOuterOf$1} = BoundsHelper;
5623
+ const {copy: copy$6, move: move$8} = PointHelper;
5589
5624
  const {moveLocal: moveLocal, zoomOfLocal: zoomOfLocal, rotateOfLocal: rotateOfLocal, skewOfLocal: skewOfLocal, moveWorld: moveWorld, zoomOfWorld: zoomOfWorld, rotateOfWorld: rotateOfWorld, skewOfWorld: skewOfWorld, transform: transform, transformWorld: transformWorld, setTransform: setTransform, getFlipTransform: getFlipTransform, getLocalOrigin: getLocalOrigin, getRelativeWorld: getRelativeWorld, drop: drop} = LeafHelper;
5590
5625
  exports.Leaf = class Leaf {
5591
5626
  get tag() {
@@ -5859,8 +5894,9 @@ var LeaferUI = function(exports) {
5859
5894
  if (!this.__cameraWorld) this.__cameraWorld = {};
5860
5895
  const cameraWorld = this.__cameraWorld, world = this.__world;
5861
5896
  multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
5862
- toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
5863
- cameraWorld.half !== world.half && (cameraWorld.half = world.half);
5897
+ toOuterOf$1(this.__layout.renderBounds, cameraWorld, cameraWorld);
5898
+ stintSet$3(cameraWorld, "half", world.half);
5899
+ stintSet$3(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
5864
5900
  return cameraWorld;
5865
5901
  } else {
5866
5902
  return this.__world;
@@ -5894,7 +5930,7 @@ var LeaferUI = function(exports) {
5894
5930
  getWorldBounds(inner, relative, change) {
5895
5931
  const matrix = relative ? getRelativeWorld(this, relative) : this.worldTransform;
5896
5932
  const to = change ? inner : {};
5897
- toOuterOf(inner, matrix, to);
5933
+ toOuterOf$1(inner, matrix, to);
5898
5934
  return to;
5899
5935
  }
5900
5936
  worldToLocal(world, to, distance, relative) {
@@ -5927,7 +5963,7 @@ var LeaferUI = function(exports) {
5927
5963
  }
5928
5964
  getBoxPointByInner(inner, _relative, _distance, change) {
5929
5965
  const point = change ? inner : Object.assign({}, inner), {x: x, y: y} = this.boxBounds;
5930
- move$6(point, -x, -y);
5966
+ move$8(point, -x, -y);
5931
5967
  return point;
5932
5968
  }
5933
5969
  getInnerPoint(world, relative, distance, change) {
@@ -5937,7 +5973,7 @@ var LeaferUI = function(exports) {
5937
5973
  }
5938
5974
  getInnerPointByBox(box, _relative, _distance, change) {
5939
5975
  const point = change ? box : Object.assign({}, box), {x: x, y: y} = this.boxBounds;
5940
- move$6(point, x, y);
5976
+ move$8(point, x, y);
5941
5977
  return point;
5942
5978
  }
5943
5979
  getInnerPointByLocal(local, _relative, distance, change) {
@@ -6373,7 +6409,7 @@ var LeaferUI = function(exports) {
6373
6409
  this.levelMap = null;
6374
6410
  }
6375
6411
  }
6376
- const version = "1.9.7";
6412
+ const version = "1.9.9";
6377
6413
  class LeaferCanvas extends LeaferCanvasBase {
6378
6414
  get allowBackgroundColor() {
6379
6415
  return true;
@@ -6771,6 +6807,7 @@ var LeaferUI = function(exports) {
6771
6807
  usePartRender: true,
6772
6808
  maxFPS: 120
6773
6809
  };
6810
+ this.frames = [];
6774
6811
  this.target = target;
6775
6812
  this.canvas = canvas;
6776
6813
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -6923,12 +6960,15 @@ var LeaferUI = function(exports) {
6923
6960
  const target = this.target;
6924
6961
  if (this.requestTime || !target) return;
6925
6962
  if (target.parentApp) return target.parentApp.requestRender(false);
6926
- const requestTime = this.requestTime = Date.now();
6963
+ this.requestTime = this.frameTime || Date.now();
6927
6964
  const render = () => {
6928
- const nowFPS = 1e3 / (Date.now() - requestTime);
6965
+ const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
6929
6966
  const {maxFPS: maxFPS} = this.config;
6930
- if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
6931
- this.FPS = Math.min(120, Math.ceil(nowFPS));
6967
+ if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
6968
+ const {frames: frames} = this;
6969
+ if (frames.length > 30) frames.shift();
6970
+ frames.push(nowFPS);
6971
+ this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
6932
6972
  this.requestTime = 0;
6933
6973
  this.checkRender();
6934
6974
  };
@@ -7538,39 +7578,40 @@ var LeaferUI = function(exports) {
7538
7578
  return data;
7539
7579
  }
7540
7580
  }
7581
+ const {max: max$3, add: add$1} = FourNumberHelper;
7541
7582
  const UIBounds = {
7542
7583
  __updateStrokeSpread() {
7543
- let width = 0, boxWidth = 0;
7584
+ let spread = 0, boxSpread = 0;
7544
7585
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
7545
7586
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
7546
- boxWidth = width = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7587
+ boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7547
7588
  if (!data.__boxStroke) {
7548
- const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * width;
7589
+ const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
7549
7590
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
7550
- width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
7591
+ spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
7551
7592
  }
7552
7593
  }
7553
- if (data.__useArrow) width += strokeWidth * 5;
7594
+ if (data.__useArrow) spread += strokeWidth * 5;
7554
7595
  if (box) {
7555
- width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
7556
- boxWidth = box.__layout.strokeBoxSpread;
7596
+ spread = max$3(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7597
+ boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
7557
7598
  }
7558
- this.__layout.strokeBoxSpread = boxWidth;
7559
- return width;
7599
+ this.__layout.strokeBoxSpread = boxSpread;
7600
+ return spread;
7560
7601
  },
7561
7602
  __updateRenderSpread() {
7562
- let width = 0;
7563
- const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7564
- if (shadow) width = Effect.getShadowSpread(this, shadow);
7565
- if (blur) width = Math.max(width, blur);
7566
- if (filter) width += Filter.getSpread(filter);
7567
- if (renderSpread) width += renderSpread;
7568
- let shapeWidth = width = Math.ceil(width);
7569
- if (innerShadow) innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
7570
- if (backgroundBlur) shapeWidth = Math.max(shapeWidth, backgroundBlur);
7571
- this.__layout.renderShapeSpread = shapeWidth;
7572
- width += this.__layout.strokeSpread || 0;
7573
- return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7603
+ let spread = 0;
7604
+ const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
7605
+ if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
7606
+ if (blur) spread = max$3(spread, blur);
7607
+ if (filter) spread = add$1(spread, Filter.getSpread(filter));
7608
+ if (renderSpread) spread = add$1(spread, renderSpread);
7609
+ if (strokeSpread) spread = add$1(spread, strokeSpread);
7610
+ let shapeSpread = spread;
7611
+ if (innerShadow) shapeSpread = max$3(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7612
+ if (backgroundBlur) shapeSpread = max$3(shapeSpread, backgroundBlur);
7613
+ this.__layout.renderShapeSpread = shapeSpread;
7614
+ return box ? max$3(box.__updateRenderSpread(), spread) : spread;
7574
7615
  }
7575
7616
  };
7576
7617
  const {float: float$1} = MathHelper;
@@ -8712,7 +8753,7 @@ var LeaferUI = function(exports) {
8712
8753
  __decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
8713
8754
  __decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
8714
8755
  exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
8715
- const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
8756
+ const {copyAndSpread: copyAndSpread$2, includes: includes, spread: spread, setList: setList} = BoundsHelper;
8716
8757
  exports.Text = class Text extends exports.UI {
8717
8758
  get __tag() {
8718
8759
  return "Text";
@@ -8758,13 +8799,13 @@ var LeaferUI = function(exports) {
8758
8799
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
8759
8800
  }
8760
8801
  __updateRenderSpread() {
8761
- let width = super.__updateRenderSpread();
8762
- if (!width) width = this.isOverflow ? 1 : 0;
8763
- return width;
8802
+ let spread = super.__updateRenderSpread();
8803
+ if (!spread) spread = this.isOverflow ? 1 : 0;
8804
+ return spread;
8764
8805
  }
8765
8806
  __updateRenderBounds() {
8766
8807
  const {renderBounds: renderBounds, renderSpread: renderSpread} = this.__layout;
8767
- copyAndSpread$1(renderBounds, this.__.__textBoxBounds, renderSpread);
8808
+ copyAndSpread$2(renderBounds, this.__.__textBoxBounds, renderSpread);
8768
8809
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
8769
8810
  }
8770
8811
  __updateChange() {
@@ -9123,9 +9164,9 @@ var LeaferUI = function(exports) {
9123
9164
  static setData(data) {
9124
9165
  this.data = data;
9125
9166
  }
9126
- static getValidMove(leaf, start, total, checkLimit = true) {
9127
- const move = leaf.getLocalPoint(total, null, true);
9128
- PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9167
+ static getValidMove(leaf, localStart, worldTotal, checkLimit = true) {
9168
+ const move = leaf.getLocalPoint(worldTotal, null, true);
9169
+ PointHelper.move(move, localStart.x - leaf.x, localStart.y - leaf.y);
9129
9170
  if (checkLimit) this.limitMove(leaf, move);
9130
9171
  DragBoundsHelper.axisMove(leaf, move);
9131
9172
  return move;
@@ -10079,8 +10120,8 @@ var LeaferUI = function(exports) {
10079
10120
  if (isHitPixel) {
10080
10121
  const {renderBounds: renderBounds} = this.__layout;
10081
10122
  const size = Platform.image.hitCanvasSize;
10082
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10083
- const {x: x, y: y, width: width, height: height} = tempBounds$1.set(renderBounds).scale(scale);
10123
+ const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10124
+ const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
10084
10125
  h.resize({
10085
10126
  width: width,
10086
10127
  height: height,
@@ -10167,8 +10208,8 @@ var LeaferUI = function(exports) {
10167
10208
  canvas$1.hitPixel = function(radiusPoint, offset, scale = 1) {
10168
10209
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
10169
10210
  if (offset) x -= offset.x, y -= offset.y;
10170
- tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10171
- const {data: data} = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
10211
+ tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10212
+ const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
10172
10213
  for (let i = 0, len = data.length; i < len; i += 4) {
10173
10214
  if (data[i + 3] > 0) return true;
10174
10215
  }
@@ -10353,23 +10394,27 @@ var LeaferUI = function(exports) {
10353
10394
  out.recycle(ui.__nowWorld);
10354
10395
  }
10355
10396
  }
10356
- const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
10397
+ const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
10398
+ const tempBounds$1 = {};
10357
10399
  function shape(ui, current, options) {
10358
10400
  const canvas = current.getSameCanvas();
10359
- const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
10360
- let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
10401
+ const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
10402
+ const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
10403
+ toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$1, layout.boxBounds, layout.strokeSpread),
10404
+ tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
10405
+ let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
10361
10406
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
10362
- if (currentBounds.includes(nowWorld)) {
10407
+ if (currentBounds.includes(nowWorldShapeBounds)) {
10363
10408
  worldCanvas = canvas;
10364
- bounds = shapeBounds = nowWorld;
10409
+ bounds = shapeBounds = nowWorldShapeBounds;
10410
+ renderBounds = nowWorld;
10365
10411
  } else {
10366
- const {renderShapeSpread: spread} = ui.__layout;
10367
10412
  let worldClipBounds;
10368
10413
  if (Platform.fullImageShadow) {
10369
- worldClipBounds = nowWorld;
10414
+ worldClipBounds = nowWorldShapeBounds;
10370
10415
  } else {
10371
- const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
10372
- worldClipBounds = getIntersectData(spreadBounds, nowWorld);
10416
+ const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
10417
+ worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
10373
10418
  }
10374
10419
  fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
10375
10420
  let {a: fitScaleX, d: fitScaleY} = fitMatrix;
@@ -10379,8 +10424,10 @@ var LeaferUI = function(exports) {
10379
10424
  scaleX *= fitScaleX;
10380
10425
  scaleY *= fitScaleY;
10381
10426
  }
10382
- shapeBounds = getOuterOf(nowWorld, fitMatrix);
10427
+ shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
10383
10428
  bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
10429
+ renderBounds = getOuterOf(nowWorld, fitMatrix);
10430
+ move$7(renderBounds, -fitMatrix.e, -fitMatrix.f);
10384
10431
  const userMatrix = options.matrix;
10385
10432
  if (userMatrix) {
10386
10433
  matrix = new Matrix(fitMatrix);
@@ -10399,6 +10446,7 @@ var LeaferUI = function(exports) {
10399
10446
  matrix: matrix,
10400
10447
  fitMatrix: fitMatrix,
10401
10448
  bounds: bounds,
10449
+ renderBounds: renderBounds,
10402
10450
  worldCanvas: worldCanvas,
10403
10451
  shapeBounds: shapeBounds,
10404
10452
  scaleX: scaleX,
@@ -10496,7 +10544,7 @@ var LeaferUI = function(exports) {
10496
10544
  drawTextStroke: drawTextStroke,
10497
10545
  shape: shape
10498
10546
  };
10499
- let origin$1 = {}, tempMatrix = getMatrixData();
10547
+ let origin$1 = {}, tempMatrix$1 = getMatrixData();
10500
10548
  const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper} = MatrixHelper;
10501
10549
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10502
10550
  const transform = get$3();
@@ -10508,12 +10556,12 @@ var LeaferUI = function(exports) {
10508
10556
  }, rotation);
10509
10557
  data.transform = transform;
10510
10558
  }
10511
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
10559
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
10512
10560
  const transform = get$3();
10513
10561
  layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
10514
- if (clipSize) {
10515
- tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
10516
- multiplyParent(transform, tempMatrix);
10562
+ if (clipScaleX) {
10563
+ tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
10564
+ multiplyParent(transform, tempMatrix$1);
10517
10565
  }
10518
10566
  data.transform = transform;
10519
10567
  }
@@ -10606,7 +10654,12 @@ var LeaferUI = function(exports) {
10606
10654
 
10607
10655
  case "normal":
10608
10656
  case "clip":
10609
- if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
10657
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
10658
+ let clipScaleX, clipScaleY;
10659
+ if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
10660
+ 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;
10662
+ }
10610
10663
  break;
10611
10664
 
10612
10665
  case "repeat":
@@ -10751,7 +10804,7 @@ var LeaferUI = function(exports) {
10751
10804
  if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
10752
10805
  }
10753
10806
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
10754
- const {floor: floor$1, ceil: ceil$1, max: max$1, abs: abs$4} = Math;
10807
+ const {floor: floor$1, ceil: ceil$1, max: max$2, abs: abs$4} = Math;
10755
10808
  function createPattern(ui, paint, pixelRatio) {
10756
10809
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
10757
10810
  const id = scaleX + "-" + scaleY + "-" + pixelRatio;
@@ -10799,8 +10852,8 @@ var LeaferUI = function(exports) {
10799
10852
  if (transform || scaleX !== 1 || scaleY !== 1) {
10800
10853
  const canvasWidth = width + (xGap || 0);
10801
10854
  const canvasHeight = height + (yGap || 0);
10802
- scaleX /= canvasWidth / max$1(floor$1(canvasWidth), 1);
10803
- scaleY /= canvasHeight / max$1(floor$1(canvasHeight), 1);
10855
+ scaleX /= canvasWidth / max$2(floor$1(canvasWidth), 1);
10856
+ scaleY /= canvasHeight / max$2(floor$1(canvasHeight), 1);
10804
10857
  if (!imageMatrix) {
10805
10858
  imageMatrix = get$1();
10806
10859
  if (transform) copy$4(imageMatrix, transform);
@@ -10825,17 +10878,15 @@ var LeaferUI = function(exports) {
10825
10878
  if (allowDraw) {
10826
10879
  if (data.repeat) {
10827
10880
  allowDraw = false;
10828
- } else {
10829
- if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
10830
- let {width: width, height: height} = data;
10831
- width *= scaleX * pixelRatio;
10832
- height *= scaleY * pixelRatio;
10833
- if (data.scaleX) {
10834
- width *= data.scaleX;
10835
- height *= data.scaleY;
10836
- }
10837
- allowDraw = width * height > Platform.image.maxCacheSize;
10881
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
10882
+ let {width: width, height: height} = data;
10883
+ width *= scaleX * pixelRatio;
10884
+ height *= scaleY * pixelRatio;
10885
+ if (data.scaleX) {
10886
+ width *= data.scaleX;
10887
+ height *= data.scaleY;
10838
10888
  }
10889
+ allowDraw = width * height > Platform.image.maxCacheSize;
10839
10890
  }
10840
10891
  }
10841
10892
  if (allowDraw) {
@@ -10993,81 +11044,87 @@ var LeaferUI = function(exports) {
10993
11044
  conicGradient: conicGradient,
10994
11045
  getTransform: getTransform
10995
11046
  };
10996
- const {copy: copy$3, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
10997
- const tempBounds = {};
11047
+ const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$1} = Math;
11048
+ const tempBounds = {}, tempMatrix = new Matrix;
10998
11049
  const offsetOutBounds$1 = {};
10999
11050
  function shadow$1(ui, current, shape) {
11000
- let copyBounds, spreadScale;
11001
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
11051
+ let copyBounds, transform;
11052
+ const {__nowWorld: nowWorld} = ui;
11002
11053
  const {shadow: shadow} = ui.__;
11003
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11054
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11004
11055
  const other = current.getSameCanvas();
11005
11056
  const end = shadow.length - 1;
11006
- toOffsetOutBounds$1(bounds, offsetOutBounds$1);
11057
+ toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
11007
11058
  shadow.forEach((item, index) => {
11008
11059
  let otherScale = 1;
11009
11060
  if (item.scaleFixed) {
11010
11061
  const sx = Math.abs(nowWorld.scaleX);
11011
11062
  if (sx > 1) otherScale = 1 / sx;
11012
11063
  }
11013
- other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
11014
- spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
11015
- drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
11016
- copyBounds = bounds;
11064
+ 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));
11065
+ transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
11066
+ if (transform) other.setTransform(transform);
11067
+ drawWorldShadow(other, offsetOutBounds$1, shape);
11068
+ if (transform) other.resetTransform();
11069
+ copyBounds = renderBounds;
11017
11070
  if (item.box) {
11018
11071
  other.restore();
11019
11072
  other.save();
11020
11073
  if (worldCanvas) {
11021
- other.copyWorld(other, bounds, nowWorld, "copy");
11074
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
11022
11075
  copyBounds = nowWorld;
11023
11076
  }
11024
11077
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
11025
11078
  }
11026
- if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11079
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11027
11080
  if (end && index < end) other.clearWorld(copyBounds);
11028
11081
  });
11029
11082
  other.recycle(copyBounds);
11030
11083
  }
11031
- function getShadowSpread(_ui, shadow) {
11032
- let width = 0;
11033
- 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));
11034
- return width;
11084
+ function getShadowRenderSpread(_ui, shadow) {
11085
+ let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
11086
+ shadow.forEach(item => {
11087
+ x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
11088
+ top = max$1(top, spread + blur - y);
11089
+ right = max$1(right, spread + blur + x);
11090
+ bottom = max$1(bottom, spread + blur + y);
11091
+ left = max$1(left, spread + blur - x);
11092
+ });
11093
+ return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
11094
+ }
11095
+ function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
11096
+ if (shadow.spread) {
11097
+ const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
11098
+ tempMatrix.set().scaleOfOuter({
11099
+ x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
11100
+ y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
11101
+ }, spreadScale);
11102
+ return tempMatrix;
11103
+ }
11104
+ return undefined;
11035
11105
  }
11036
- function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
11037
- const {bounds: bounds, shapeBounds: shapeBounds} = shape;
11106
+ function drawWorldShadow(canvas, outBounds, shape) {
11107
+ const {shapeBounds: shapeBounds} = shape;
11108
+ let from, to;
11038
11109
  if (Platform.fullImageShadow) {
11039
11110
  copy$3(tempBounds, canvas.bounds);
11040
- tempBounds.x += outBounds.x - shapeBounds.x;
11041
- tempBounds.y += outBounds.y - shapeBounds.y;
11042
- if (spreadScale) {
11043
- const {fitMatrix: fitMatrix} = shape;
11044
- tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
11045
- tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
11046
- tempBounds.width *= spreadScale;
11047
- tempBounds.height *= spreadScale;
11048
- }
11049
- canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
11111
+ move$6(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
11112
+ from = canvas.bounds, to = tempBounds;
11050
11113
  } else {
11051
- if (spreadScale) {
11052
- copy$3(tempBounds, outBounds);
11053
- tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
11054
- tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
11055
- tempBounds.width *= spreadScale;
11056
- tempBounds.height *= spreadScale;
11057
- }
11058
- canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
11114
+ from = shapeBounds, to = outBounds;
11059
11115
  }
11116
+ canvas.copyWorld(shape.canvas, from, to);
11060
11117
  }
11061
11118
  const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
11062
11119
  const offsetOutBounds = {};
11063
11120
  function innerShadow(ui, current, shape) {
11064
- let copyBounds, spreadScale;
11065
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
11121
+ let copyBounds, transform;
11122
+ const {__nowWorld: nowWorld} = ui;
11066
11123
  const {innerShadow: innerShadow} = ui.__;
11067
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11124
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11068
11125
  const other = current.getSameCanvas();
11069
11126
  const end = innerShadow.length - 1;
11070
- toOffsetOutBounds(bounds, offsetOutBounds);
11127
+ toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
11071
11128
  innerShadow.forEach((item, index) => {
11072
11129
  let otherScale = 1;
11073
11130
  if (item.scaleFixed) {
@@ -11075,17 +11132,18 @@ var LeaferUI = function(exports) {
11075
11132
  if (sx > 1) otherScale = 1 / sx;
11076
11133
  }
11077
11134
  other.save();
11078
- other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
11079
- spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
11080
- drawWorldShadow(other, offsetOutBounds, spreadScale, shape);
11135
+ other.setWorldShadow(offsetOutBounds.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale);
11136
+ transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
11137
+ if (transform) other.setTransform(transform);
11138
+ drawWorldShadow(other, offsetOutBounds, shape);
11081
11139
  other.restore();
11082
11140
  if (worldCanvas) {
11083
- other.copyWorld(other, bounds, nowWorld, "copy");
11141
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
11084
11142
  other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
11085
11143
  copyBounds = nowWorld;
11086
11144
  } else {
11087
11145
  other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
11088
- copyBounds = bounds;
11146
+ copyBounds = renderBounds;
11089
11147
  }
11090
11148
  other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
11091
11149
  LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
@@ -11093,6 +11151,7 @@ var LeaferUI = function(exports) {
11093
11151
  });
11094
11152
  other.recycle(copyBounds);
11095
11153
  }
11154
+ const getInnerShadowSpread = getShadowRenderSpread;
11096
11155
  function blur(ui, current, origin) {
11097
11156
  const {blur: blur} = ui.__;
11098
11157
  origin.setWorldBlur(blur * ui.__nowWorld.a);
@@ -11105,10 +11164,12 @@ var LeaferUI = function(exports) {
11105
11164
  innerShadow: innerShadow,
11106
11165
  blur: blur,
11107
11166
  backgroundBlur: backgroundBlur,
11108
- getShadowSpread: getShadowSpread,
11167
+ getShadowRenderSpread: getShadowRenderSpread,
11168
+ getShadowTransform: getShadowTransform,
11109
11169
  isTransformShadow(_shadow) {
11110
11170
  return undefined;
11111
- }
11171
+ },
11172
+ getInnerShadowSpread: getInnerShadowSpread
11112
11173
  };
11113
11174
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
11114
11175
  let usedGrayscaleAlpha;
@@ -11122,6 +11183,7 @@ var LeaferUI = function(exports) {
11122
11183
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
11123
11184
  maskCanvas = contentCanvas = null;
11124
11185
  }
11186
+ if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
11125
11187
  maskOpacity = child.__.opacity;
11126
11188
  usedGrayscaleAlpha = false;
11127
11189
  if (mask === "path" || mask === "clipping-path") {
@@ -11139,7 +11201,6 @@ var LeaferUI = function(exports) {
11139
11201
  if (!contentCanvas) contentCanvas = getCanvas(canvas);
11140
11202
  child.__render(maskCanvas, options);
11141
11203
  }
11142
- if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
11143
11204
  continue;
11144
11205
  }
11145
11206
  const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
@@ -11646,6 +11707,7 @@ var LeaferUI = function(exports) {
11646
11707
  getDrawData: getDrawData$1
11647
11708
  };
11648
11709
  function string(color, opacity) {
11710
+ if (!color) return "#000";
11649
11711
  const doOpacity = isNumber(opacity) && opacity < 1;
11650
11712
  if (isString(color)) {
11651
11713
  if (doOpacity && ColorConvert.object) color = ColorConvert.object(color); else return color;
@@ -11704,10 +11766,6 @@ var LeaferUI = function(exports) {
11704
11766
  if (t.config) {
11705
11767
  const isSelect = key === "target";
11706
11768
  if (isSelect) {
11707
- t.setDimOthers(false);
11708
- t.setBright(false);
11709
- if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
11710
- if (t.single) t.element.syncEventer = null;
11711
11769
  const {beforeSelect: beforeSelect} = t.config;
11712
11770
  if (beforeSelect) {
11713
11771
  const check = beforeSelect({
@@ -11715,6 +11773,10 @@ var LeaferUI = function(exports) {
11715
11773
  });
11716
11774
  if (isObject(check)) value = check; else if (check === false) return;
11717
11775
  }
11776
+ t.setDimOthers(false);
11777
+ t.setBright(false);
11778
+ if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
11779
+ if (t.single) t.element.syncEventer = null;
11718
11780
  }
11719
11781
  const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
11720
11782
  if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, {
@@ -11885,11 +11947,12 @@ var LeaferUI = function(exports) {
11885
11947
  return !!this.originList;
11886
11948
  }
11887
11949
  get running() {
11888
- const {editor: editor} = this;
11889
- return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && this.app.mode === "normal";
11950
+ const {editor: editor, app: app} = this;
11951
+ return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && (app && app.mode === "normal");
11890
11952
  }
11891
11953
  get isMoveMode() {
11892
- return this.app && this.app.interaction.moveMode;
11954
+ const {app: app} = this;
11955
+ return app && app.interaction.moveMode;
11893
11956
  }
11894
11957
  constructor(editor) {
11895
11958
  super();
@@ -11952,12 +12015,12 @@ var LeaferUI = function(exports) {
11952
12015
  onTap(e) {
11953
12016
  if (e.multiTouch) return;
11954
12017
  const {editor: editor} = this;
11955
- const {select: select} = editor.mergeConfig;
12018
+ const {select: select, selectKeep: selectKeep} = editor.mergeConfig;
11956
12019
  if (select === "tap") this.checkAndSelect(e); else if (this.waitSelect) this.waitSelect();
11957
12020
  if (this.needRemoveItem) {
11958
12021
  editor.removeItem(this.needRemoveItem);
11959
12022
  } else if (this.isMoveMode) {
11960
- editor.target = null;
12023
+ if (!selectKeep) editor.target = null;
11961
12024
  }
11962
12025
  }
11963
12026
  checkAndSelect(e) {
@@ -11972,7 +12035,7 @@ var LeaferUI = function(exports) {
11972
12035
  editor.target = find;
11973
12036
  }
11974
12037
  } else if (this.allow(e.target)) {
11975
- if (!this.isHoldMultipleSelectKey(e)) editor.target = null;
12038
+ if (!this.isHoldMultipleSelectKey(e) && !this.editor.mergedConfig.selectKeep) editor.target = null;
11976
12039
  }
11977
12040
  }
11978
12041
  }
@@ -12087,91 +12150,95 @@ var LeaferUI = function(exports) {
12087
12150
  const {toPoint: toPoint} = AroundHelper;
12088
12151
  const {within: within$3, sign: sign$1} = MathHelper;
12089
12152
  const EditDataHelper = {
12090
- getScaleData(target, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
12153
+ getScaleData(target, startBounds, direction, totalMoveOrScale, lockRatio, around, flipable, scaleMode) {
12091
12154
  let align, origin = {}, scaleX = 1, scaleY = 1;
12092
12155
  const {boxBounds: boxBounds, widthRange: widthRange, heightRange: heightRange, dragBounds: dragBounds, worldBoxBounds: worldBoxBounds} = target;
12093
12156
  const {width: width, height: height} = startBounds;
12094
- if (around) {
12095
- totalMove.x *= 2;
12096
- totalMove.y *= 2;
12097
- }
12098
12157
  const originChangedScaleX = target.scaleX / startBounds.scaleX;
12099
12158
  const originChangedScaleY = target.scaleY / startBounds.scaleY;
12100
12159
  const signX = sign$1(originChangedScaleX);
12101
12160
  const signY = sign$1(originChangedScaleY);
12102
12161
  const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
12103
12162
  const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height;
12104
- totalMove.x *= scaleMode ? originChangedScaleX : signX;
12105
- totalMove.y *= scaleMode ? originChangedScaleY : signY;
12106
- const topScale = (-totalMove.y + height) / height;
12107
- const rightScale = (totalMove.x + width) / width;
12108
- const bottomScale = (totalMove.y + height) / height;
12109
- const leftScale = (-totalMove.x + width) / width;
12110
- switch (direction) {
12111
- case top$1:
12112
- scaleY = topScale;
12113
- align = "bottom";
12114
- break;
12163
+ if (isNumber(totalMoveOrScale)) {
12164
+ scaleX = scaleY = Math.sqrt(totalMoveOrScale);
12165
+ } else {
12166
+ if (around) {
12167
+ totalMoveOrScale.x *= 2;
12168
+ totalMoveOrScale.y *= 2;
12169
+ }
12170
+ totalMoveOrScale.x *= scaleMode ? originChangedScaleX : signX;
12171
+ totalMoveOrScale.y *= scaleMode ? originChangedScaleY : signY;
12172
+ const topScale = (-totalMoveOrScale.y + height) / height;
12173
+ const rightScale = (totalMoveOrScale.x + width) / width;
12174
+ const bottomScale = (totalMoveOrScale.y + height) / height;
12175
+ const leftScale = (-totalMoveOrScale.x + width) / width;
12176
+ switch (direction) {
12177
+ case top$1:
12178
+ scaleY = topScale;
12179
+ align = "bottom";
12180
+ break;
12115
12181
 
12116
- case right$2:
12117
- scaleX = rightScale;
12118
- align = "left";
12119
- break;
12182
+ case right$2:
12183
+ scaleX = rightScale;
12184
+ align = "left";
12185
+ break;
12120
12186
 
12121
- case bottom$1:
12122
- scaleY = bottomScale;
12123
- align = "top";
12124
- break;
12187
+ case bottom$1:
12188
+ scaleY = bottomScale;
12189
+ align = "top";
12190
+ break;
12125
12191
 
12126
- case left$2:
12127
- scaleX = leftScale;
12128
- align = "right";
12129
- break;
12192
+ case left$2:
12193
+ scaleX = leftScale;
12194
+ align = "right";
12195
+ break;
12130
12196
 
12131
- case topLeft$1:
12132
- scaleY = topScale;
12133
- scaleX = leftScale;
12134
- align = "bottom-right";
12135
- break;
12197
+ case topLeft$1:
12198
+ scaleY = topScale;
12199
+ scaleX = leftScale;
12200
+ align = "bottom-right";
12201
+ break;
12136
12202
 
12137
- case topRight$1:
12138
- scaleY = topScale;
12139
- scaleX = rightScale;
12140
- align = "bottom-left";
12141
- break;
12203
+ case topRight$1:
12204
+ scaleY = topScale;
12205
+ scaleX = rightScale;
12206
+ align = "bottom-left";
12207
+ break;
12142
12208
 
12143
- case bottomRight:
12144
- scaleY = bottomScale;
12145
- scaleX = rightScale;
12146
- align = "top-left";
12147
- break;
12209
+ case bottomRight:
12210
+ scaleY = bottomScale;
12211
+ scaleX = rightScale;
12212
+ align = "top-left";
12213
+ break;
12148
12214
 
12149
- case bottomLeft:
12150
- scaleY = bottomScale;
12151
- scaleX = leftScale;
12152
- align = "top-right";
12153
- }
12154
- if (lockRatio) {
12155
- if (lockRatio === "corner" && direction % 2) {
12156
- lockRatio = false;
12157
- } else {
12158
- let scale;
12159
- switch (direction) {
12160
- case top$1:
12161
- case bottom$1:
12162
- scale = scaleY;
12163
- break;
12215
+ case bottomLeft:
12216
+ scaleY = bottomScale;
12217
+ scaleX = leftScale;
12218
+ align = "top-right";
12219
+ }
12220
+ if (lockRatio) {
12221
+ if (lockRatio === "corner" && direction % 2) {
12222
+ lockRatio = false;
12223
+ } else {
12224
+ let scale;
12225
+ switch (direction) {
12226
+ case top$1:
12227
+ case bottom$1:
12228
+ scale = scaleY;
12229
+ break;
12164
12230
 
12165
- case left$2:
12166
- case right$2:
12167
- scale = scaleX;
12168
- break;
12231
+ case left$2:
12232
+ case right$2:
12233
+ scale = scaleX;
12234
+ break;
12169
12235
 
12170
- default:
12171
- scale = Math.sqrt(Math.abs(scaleX * scaleY));
12236
+ default:
12237
+ scale = Math.sqrt(Math.abs(scaleX * scaleY));
12238
+ }
12239
+ scaleX = scaleX < 0 ? -scale : scale;
12240
+ scaleY = scaleY < 0 ? -scale : scale;
12172
12241
  }
12173
- scaleX = scaleX < 0 ? -scale : scale;
12174
- scaleY = scaleY < 0 ? -scale : scale;
12175
12242
  }
12176
12243
  }
12177
12244
  const useScaleX = scaleX !== 1, useScaleY = scaleY !== 1;
@@ -12452,6 +12519,9 @@ var LeaferUI = function(exports) {
12452
12519
  const {moveable: moveable, resizeable: resizeable, rotateable: rotateable} = this.mergeConfig;
12453
12520
  return isString(moveable) || isString(resizeable) || isString(rotateable);
12454
12521
  }
12522
+ get canDragLimitAnimate() {
12523
+ return this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds;
12524
+ }
12455
12525
  constructor(editor) {
12456
12526
  super();
12457
12527
  this.view = new exports.Group;
@@ -12685,10 +12755,9 @@ var LeaferUI = function(exports) {
12685
12755
  onDragStart(e) {
12686
12756
  this.dragging = true;
12687
12757
  const point = this.dragPoint = e.current, {pointType: pointType} = point;
12688
- const {editor: editor, dragStartData: dragStartData} = this, {target: target} = this, {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable, hideOnMove: hideOnMove} = this.mergeConfig;
12758
+ const {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = this.mergeConfig;
12689
12759
  if (pointType === "move") {
12690
12760
  moveable && (this.moving = true);
12691
- editor.opacity = hideOnMove ? 0 : 1;
12692
12761
  } else {
12693
12762
  if (pointType.includes("rotate") || this.isHoldRotateKey(e) || !resizeable) {
12694
12763
  rotateable && (this.rotating = true);
@@ -12697,23 +12766,7 @@ var LeaferUI = function(exports) {
12697
12766
  } else if (pointType === "resize") resizeable && (this.resizing = true);
12698
12767
  if (pointType === "skew") skewable && (this.skewing = true);
12699
12768
  }
12700
- dragStartData.x = e.x;
12701
- dragStartData.y = e.y;
12702
- dragStartData.point = {
12703
- x: target.x,
12704
- y: target.y
12705
- };
12706
- dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
12707
- dragStartData.rotation = target.rotation;
12708
- if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = editor.leafList.keys;
12709
- }
12710
- onDragEnd(e) {
12711
- if (this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds) this.transformTool.onMove(e);
12712
- this.dragPoint = null;
12713
- this.resetDoing();
12714
- const {pointType: pointType} = e.current;
12715
- if (pointType === "move") this.editor.opacity = 1;
12716
- if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = null;
12769
+ this.onTransformStart(e);
12717
12770
  }
12718
12771
  onDrag(e) {
12719
12772
  const {transformTool: transformTool, moving: moving, resizing: resizing, rotating: rotating, skewing: skewing} = this;
@@ -12728,37 +12781,59 @@ var LeaferUI = function(exports) {
12728
12781
  }
12729
12782
  updatePointCursor(this, e);
12730
12783
  }
12731
- resetDoing() {
12732
- if (this.canUse) this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
12784
+ onDragEnd(e) {
12785
+ this.onTransformEnd(e);
12786
+ this.dragPoint = null;
12787
+ }
12788
+ onTransformStart(e) {
12789
+ if (this.canUse) {
12790
+ if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
12791
+ if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
12792
+ const {dragStartData: dragStartData, target: target} = this;
12793
+ dragStartData.x = e.x;
12794
+ dragStartData.y = e.y;
12795
+ dragStartData.totalOffset = getPointData();
12796
+ dragStartData.point = {
12797
+ x: target.x,
12798
+ y: target.y
12799
+ };
12800
+ dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
12801
+ dragStartData.rotation = target.rotation;
12802
+ }
12803
+ }
12804
+ onTransformEnd(e) {
12805
+ if (this.canUse) {
12806
+ if (this.canDragLimitAnimate && (e instanceof exports.DragEvent || e instanceof exports.MoveEvent)) this.transformTool.onMove(e);
12807
+ if (this.resizing) ResizeEvent.resizingKeys = null;
12808
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
12809
+ this.editor.opacity = 1;
12810
+ this.update();
12811
+ }
12733
12812
  }
12734
12813
  onMove(e) {
12735
12814
  if (this.canGesture && e.moveType !== "drag") {
12736
12815
  e.stop();
12737
- if (isString(this.mergeConfig.moveable)) {
12816
+ if (isString(this.mergedConfig.moveable)) {
12738
12817
  this.gesturing = this.moving = true;
12739
- this.transformTool.onMove(e);
12818
+ e.type === exports.MoveEvent.START ? this.onTransformStart(e) : this.transformTool.onMove(e);
12740
12819
  }
12741
12820
  }
12742
12821
  }
12743
- onMoveEnd(e) {
12744
- if (this.moving) this.transformTool.onMove(e);
12745
- this.resetDoing();
12746
- }
12747
12822
  onScale(e) {
12748
12823
  if (this.canGesture) {
12749
12824
  e.stop();
12750
- if (isString(this.mergeConfig.resizeable)) {
12825
+ if (isString(this.mergedConfig.resizeable)) {
12751
12826
  this.gesturing = this.resizing = true;
12752
- this.transformTool.onScale(e);
12827
+ e.type === exports.ZoomEvent.START ? this.onTransformStart(e) : this.transformTool.onScale(e);
12753
12828
  }
12754
12829
  }
12755
12830
  }
12756
12831
  onRotate(e) {
12757
12832
  if (this.canGesture) {
12758
12833
  e.stop();
12759
- if (isString(this.mergeConfig.rotateable)) {
12834
+ if (isString(this.mergedConfig.rotateable)) {
12760
12835
  this.gesturing = this.rotating = true;
12761
- this.transformTool.onRotate(e);
12836
+ e.type === exports.RotateEvent.START ? this.onTransformStart(e) : this.transformTool.onRotate(e);
12762
12837
  }
12763
12838
  }
12764
12839
  }
@@ -12771,8 +12846,7 @@ var LeaferUI = function(exports) {
12771
12846
  updatePointCursor(this, e);
12772
12847
  }
12773
12848
  onArrow(e) {
12774
- const {editor: editor, transformTool: transformTool} = this;
12775
- if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
12849
+ if (this.canUse && this.mergeConfig.keyEvent) {
12776
12850
  let x = 0, y = 0;
12777
12851
  const distance = e.shiftKey ? 10 : 1;
12778
12852
  switch (e.code) {
@@ -12791,7 +12865,7 @@ var LeaferUI = function(exports) {
12791
12865
  case "ArrowRight":
12792
12866
  x = distance;
12793
12867
  }
12794
- if (x || y) transformTool.move(x, y);
12868
+ if (x || y) this.transformTool.move(x, y);
12795
12869
  }
12796
12870
  }
12797
12871
  onDoubleTap(e) {
@@ -12832,7 +12906,7 @@ var LeaferUI = function(exports) {
12832
12906
  const {rect: rect, editor: editor, __eventIds: events} = this;
12833
12907
  events.push(rect.on_([ [ exports.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ exports.PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
12834
12908
  this.waitLeafer(() => {
12835
- events.push(editor.app.on_([ [ [ exports.KeyEvent.HOLD, exports.KeyEvent.UP ], this.onKey, this ], [ exports.KeyEvent.DOWN, this.onArrow, this ], [ exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ exports.MoveEvent.END, this.onMoveEnd, this ], [ exports.ZoomEvent.END, this.resetDoing, this ], [ exports.RotateEvent.END, this.resetDoing, this ] ]));
12909
+ events.push(editor.app.on_([ [ [ exports.KeyEvent.HOLD, exports.KeyEvent.UP ], this.onKey, this ], [ exports.KeyEvent.DOWN, this.onArrow, this ], [ [ exports.MoveEvent.START, exports.MoveEvent.BEFORE_MOVE ], this.onMove, this, true ], [ [ exports.ZoomEvent.START, exports.ZoomEvent.BEFORE_ZOOM ], this.onScale, this, true ], [ [ exports.RotateEvent.START, exports.RotateEvent.BEFORE_ROTATE ], this.onRotate, this, true ], [ [ exports.MoveEvent.END, exports.ZoomEvent.END, exports.RotateEvent.END ], this.onTransformEnd, this ] ]));
12836
12910
  });
12837
12911
  }
12838
12912
  __removeListenEvents() {
@@ -13181,56 +13255,61 @@ var LeaferUI = function(exports) {
13181
13255
  const isMoveEnd = e.type === exports.MoveEvent.END || e.type === exports.DragEvent.END;
13182
13256
  const axisDrag = isString(target.draggable);
13183
13257
  const checkLimitMove = !dragLimitAnimate || isMoveEnd || axisDrag;
13258
+ const total = {
13259
+ x: e.totalX,
13260
+ y: e.totalY
13261
+ };
13184
13262
  if (e instanceof exports.MoveEvent) {
13185
- move = e.getLocalMove(target);
13186
- if (checkLimitMove) exports.DragEvent.limitMove(target, move);
13187
- } else {
13188
- const total = {
13189
- x: e.totalX,
13190
- y: e.totalY
13191
- };
13192
- if (e.shiftKey) {
13193
- if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
13194
- }
13195
- move = exports.DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
13263
+ PointHelper.move(total, target.getWorldPointByLocal(dragStartData.totalOffset, null, true));
13196
13264
  }
13265
+ if (e.shiftKey) {
13266
+ if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
13267
+ }
13268
+ move = exports.DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
13197
13269
  if (move.x || move.y) {
13198
13270
  if (dragLimitAnimate && !axisDrag && isMoveEnd) LeafHelper.animateMove(this, move, isNumber(dragLimitAnimate) ? dragLimitAnimate : .3); else this.move(move);
13199
13271
  }
13200
13272
  }
13201
13273
  onScale(e) {
13202
13274
  const {target: target, mergeConfig: mergeConfig, single: single, dragStartData: dragStartData} = this.editBox;
13203
- let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig;
13275
+ let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig, totalMove;
13204
13276
  if (e instanceof exports.ZoomEvent) {
13205
- this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
13277
+ around = target.getBoxPoint(e);
13278
+ totalMove = e.totalScale;
13206
13279
  } else {
13207
- const {direction: direction} = e.current;
13208
- if (e.shiftKey || target.lockRatio) lockRatio = true;
13209
- const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, e.getInnerTotal(target), lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale");
13210
- if (this.editTool && this.editTool.onScaleWithDrag) {
13211
- data.drag = e;
13212
- this.scaleWithDrag(data);
13213
- } else {
13214
- this.scaleOf(data.origin, data.scaleX, data.scaleY);
13215
- }
13280
+ totalMove = e.getInnerTotal(target);
13216
13281
  }
13282
+ const {direction: direction} = e.current;
13283
+ if (e.shiftKey || target.lockRatio) lockRatio = true;
13284
+ const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, totalMove, lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale");
13285
+ const targetX = target.x, targetY = target.y;
13286
+ if (e instanceof exports.DragEvent && this.editTool && this.editTool.onScaleWithDrag) {
13287
+ data.drag = e;
13288
+ this.scaleWithDrag(data);
13289
+ } else {
13290
+ this.scaleOf(data.origin, data.scaleX, data.scaleY);
13291
+ }
13292
+ PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
13217
13293
  }
13218
13294
  onRotate(e) {
13219
13295
  const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData} = this.editBox;
13220
- const {around: around, rotateAround: rotateAround, rotateGap: rotateGap} = mergeConfig;
13296
+ const {around: around, rotateAround: rotateAround, rotateGap: rotateGap, diagonalRotateKey: diagonalRotateKey} = mergeConfig;
13221
13297
  const {direction: direction} = e.current;
13222
13298
  let origin, rotation;
13223
13299
  if (e instanceof exports.RotateEvent) {
13224
13300
  rotation = e.rotation;
13225
13301
  origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
13226
13302
  } else {
13227
- const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : rotateAround || target.around || target.origin || around || "center");
13303
+ const isDiagonalRotate = diagonalRotateKey ? e.isHoldKeys(diagonalRotateKey) : e.shiftKey;
13304
+ const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, isDiagonalRotate ? null : rotateAround || target.around || target.origin || around || "center");
13228
13305
  rotation = dragStartData.rotation + data.rotation - target.rotation;
13229
13306
  origin = data.origin;
13230
13307
  }
13231
13308
  rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
13232
13309
  if (!rotation) return;
13310
+ const targetX = target.x, targetY = target.y;
13233
13311
  this.rotateOf(origin, rotation);
13312
+ PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
13234
13313
  }
13235
13314
  onSkew(e) {
13236
13315
  const {target: target, mergeConfig: mergeConfig} = this.editBox;
@@ -13960,7 +14039,7 @@ var LeaferUI = function(exports) {
13960
14039
  }
13961
14040
  };
13962
14041
  exports.LineEditTool = __decorate([ registerEditTool() ], exports.LineEditTool);
13963
- const {M: M$3, L: L$3, C: C$3, Q: Q$2, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$2, P: P$1, U: U$1} = PathCommandMap;
14042
+ const {M: M$4, L: L$3, C: C$3, Q: Q$2, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$2, P: P$1, U: U$1} = PathCommandMap;
13964
14043
  const PathScaler = {
13965
14044
  scale(data, scaleX, scaleY) {
13966
14045
  if (!data) return;
@@ -13969,7 +14048,7 @@ var LeaferUI = function(exports) {
13969
14048
  while (i < len) {
13970
14049
  command = data[i];
13971
14050
  switch (command) {
13972
- case M$3:
14051
+ case M$4:
13973
14052
  case L$3:
13974
14053
  scalePoints(data, scaleX, scaleY, i, 1);
13975
14054
  i += 3;
@@ -14386,28 +14465,24 @@ var LeaferUI = function(exports) {
14386
14465
  const data = text.__;
14387
14466
  if (data.__autoWidth) {
14388
14467
  width += 20;
14389
- if (data.autoSizeAlign) {
14390
- switch (data.textAlign) {
14391
- case "center":
14392
- offsetX = -width / 2;
14393
- break;
14468
+ switch (data.textAlign) {
14469
+ case "center":
14470
+ offsetX = data.autoSizeAlign ? -width / 2 : -10;
14471
+ break;
14394
14472
 
14395
- case "right":
14396
- offsetX = -width;
14397
- }
14473
+ case "right":
14474
+ offsetX = data.autoSizeAlign ? -width : -20;
14398
14475
  }
14399
14476
  }
14400
14477
  if (data.__autoHeight) {
14401
14478
  height += 20;
14402
- if (data.autoSizeAlign) {
14403
- switch (data.verticalAlign) {
14404
- case "middle":
14405
- offsetY = -height / 2;
14406
- break;
14479
+ switch (data.verticalAlign) {
14480
+ case "middle":
14481
+ offsetY = data.autoSizeAlign ? -height / 2 : -10;
14482
+ break;
14407
14483
 
14408
- case "bottom":
14409
- offsetY = -height;
14410
- }
14484
+ case "bottom":
14485
+ offsetY = data.autoSizeAlign ? -height : -20;
14411
14486
  }
14412
14487
  }
14413
14488
  const {x: x, y: y} = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
@@ -14511,6 +14586,13 @@ var LeaferUI = function(exports) {
14511
14586
  register("design", design);
14512
14587
  register("document", document$1);
14513
14588
  const MultiTouchHelper = {
14589
+ state: {
14590
+ type: "none",
14591
+ typeCount: 0,
14592
+ startTime: 0,
14593
+ totalData: null,
14594
+ center: {}
14595
+ },
14514
14596
  getData(list) {
14515
14597
  const a = list[0], b = list[1];
14516
14598
  const lastCenter = PointHelper.getCenter(a.from, b.from);
@@ -14529,8 +14611,51 @@ var LeaferUI = function(exports) {
14529
14611
  rotation: rotation,
14530
14612
  center: center
14531
14613
  };
14614
+ },
14615
+ getType(data, config) {
14616
+ const moveScore = Math.hypot(data.move.x, data.move.y) / (config.move || 5);
14617
+ const scaleScore = Math.abs(data.scale - 1) / (config.scale || .03);
14618
+ const rotateScore = Math.abs(data.rotation) / (config.rotation || 2);
14619
+ if (moveScore < 1 && scaleScore < 1 && rotateScore < 1) return "none";
14620
+ if (moveScore >= scaleScore && moveScore >= rotateScore) return "move";
14621
+ if (scaleScore >= rotateScore) return "zoom";
14622
+ return "rotate";
14623
+ },
14624
+ detect(data, config) {
14625
+ const {state: state} = M$3;
14626
+ const type = M$3.getType(data, config);
14627
+ if (!state.totalData) {
14628
+ state.startTime = Date.now();
14629
+ state.center = data.center;
14630
+ }
14631
+ M$3.add(data, state.totalData);
14632
+ state.totalData = data;
14633
+ if (type === state.type) {
14634
+ state.typeCount++;
14635
+ if (state.typeCount >= (config.count || 3) && type !== "none") return type;
14636
+ } else {
14637
+ state.type = type;
14638
+ state.typeCount = 1;
14639
+ }
14640
+ if (Date.now() - state.startTime >= (config.time || 160)) return M$3.getType(state.totalData, config);
14641
+ return "none";
14642
+ },
14643
+ add(data, add) {
14644
+ if (!add) return;
14645
+ PointHelper.move(data.move, add.move);
14646
+ data.scale *= add.scale;
14647
+ data.rotation += add.rotation;
14648
+ data.center = add.center;
14649
+ },
14650
+ reset() {
14651
+ const {state: state} = M$3;
14652
+ state.type = "none";
14653
+ state.typeCount = 0;
14654
+ state.startTime = 0;
14655
+ state.totalData = null;
14532
14656
  }
14533
14657
  };
14658
+ const M$3 = MultiTouchHelper;
14534
14659
  const {abs: abs$2, max: max} = Math, {sign: sign, within: within$2} = MathHelper;
14535
14660
  const WheelEventHelper = {
14536
14661
  getMove(event, config) {
@@ -14568,9 +14693,19 @@ var LeaferUI = function(exports) {
14568
14693
  return scale;
14569
14694
  }
14570
14695
  };
14696
+ let totalX, totalY, totalScale, totalRotation;
14571
14697
  class Transformer {
14572
14698
  get transforming() {
14573
- return !!(this.moveData || this.zoomData || this.rotateData);
14699
+ return this.moving || this.zooming || this.rotating;
14700
+ }
14701
+ get moving() {
14702
+ return !!this.moveData;
14703
+ }
14704
+ get zooming() {
14705
+ return !!this.zoomData;
14706
+ }
14707
+ get rotating() {
14708
+ return !!this.rotateData;
14574
14709
  }
14575
14710
  constructor(interaction) {
14576
14711
  this.interaction = interaction;
@@ -14580,13 +14715,18 @@ var LeaferUI = function(exports) {
14580
14715
  if (!data.moveType) data.moveType = "move";
14581
14716
  if (!this.moveData) {
14582
14717
  this.setPath(data);
14718
+ totalX = 0, totalY = 0;
14583
14719
  this.moveData = Object.assign(Object.assign({}, data), {
14584
14720
  moveX: 0,
14585
- moveY: 0
14721
+ moveY: 0,
14722
+ totalX: totalX,
14723
+ totalY: totalY
14586
14724
  });
14587
14725
  interaction.emit(exports.MoveEvent.START, this.moveData);
14588
14726
  }
14589
14727
  data.path = this.moveData.path;
14728
+ data.totalX = totalX = totalX + data.moveX;
14729
+ data.totalY = totalY = totalY + data.moveY;
14590
14730
  interaction.emit(exports.MoveEvent.BEFORE_MOVE, data);
14591
14731
  interaction.emit(exports.MoveEvent.MOVE, data);
14592
14732
  this.transformEndWait();
@@ -14595,12 +14735,15 @@ var LeaferUI = function(exports) {
14595
14735
  const {interaction: interaction} = this;
14596
14736
  if (!this.zoomData) {
14597
14737
  this.setPath(data);
14738
+ totalScale = 1;
14598
14739
  this.zoomData = Object.assign(Object.assign({}, data), {
14599
- scale: 1
14740
+ scale: 1,
14741
+ totalScale: totalScale
14600
14742
  });
14601
14743
  interaction.emit(exports.ZoomEvent.START, this.zoomData);
14602
14744
  }
14603
14745
  data.path = this.zoomData.path;
14746
+ data.totalScale = totalScale = totalScale * data.scale;
14604
14747
  interaction.emit(exports.ZoomEvent.BEFORE_ZOOM, data);
14605
14748
  interaction.emit(exports.ZoomEvent.ZOOM, data);
14606
14749
  this.transformEndWait();
@@ -14609,12 +14752,15 @@ var LeaferUI = function(exports) {
14609
14752
  const {interaction: interaction} = this;
14610
14753
  if (!this.rotateData) {
14611
14754
  this.setPath(data);
14755
+ totalRotation = 0;
14612
14756
  this.rotateData = Object.assign(Object.assign({}, data), {
14613
- rotation: 0
14757
+ rotation: 0,
14758
+ totalRotation: totalRotation
14614
14759
  });
14615
14760
  interaction.emit(exports.RotateEvent.START, this.rotateData);
14616
14761
  }
14617
14762
  data.path = this.rotateData.path;
14763
+ data.totalRotation = totalRotation = totalRotation + data.rotation;
14618
14764
  interaction.emit(exports.RotateEvent.BEFORE_ROTATE, data);
14619
14765
  interaction.emit(exports.RotateEvent.ROTATE, data);
14620
14766
  this.transformEndWait();
@@ -14633,9 +14779,16 @@ var LeaferUI = function(exports) {
14633
14779
  }
14634
14780
  transformEnd() {
14635
14781
  const {interaction: interaction, moveData: moveData, zoomData: zoomData, rotateData: rotateData} = this;
14636
- if (moveData) interaction.emit(exports.MoveEvent.END, moveData);
14637
- if (zoomData) interaction.emit(exports.ZoomEvent.END, zoomData);
14638
- if (rotateData) interaction.emit(exports.RotateEvent.END, rotateData);
14782
+ if (moveData) interaction.emit(exports.MoveEvent.END, Object.assign(Object.assign({}, moveData), {
14783
+ totalX: totalX,
14784
+ totalY: totalY
14785
+ }));
14786
+ if (zoomData) interaction.emit(exports.ZoomEvent.END, Object.assign(Object.assign({}, zoomData), {
14787
+ totalScale: totalScale
14788
+ }));
14789
+ if (rotateData) interaction.emit(exports.RotateEvent.END, Object.assign(Object.assign({}, rotateData), {
14790
+ totalRotation: totalRotation
14791
+ }));
14639
14792
  this.reset();
14640
14793
  }
14641
14794
  reset() {
@@ -14717,14 +14870,39 @@ var LeaferUI = function(exports) {
14717
14870
  }
14718
14871
  };
14719
14872
  interaction.multiTouch = function(data, list) {
14720
- if (this.config.multiTouch.disabled) return;
14721
- const {move: move, rotation: rotation, scale: scale, center: center} = MultiTouchHelper.getData(list);
14722
- Object.assign(data, center);
14723
- data.multiTouch = true;
14873
+ const {disabled: disabled, singleGesture: singleGesture} = this.config.multiTouch;
14874
+ if (disabled) return;
14724
14875
  this.pointerWaitCancel();
14725
- this.rotate(getRotateEventData(rotation, data));
14726
- this.zoom(getZoomEventData(scale, data));
14727
- this.move(getMoveEventData(move, data));
14876
+ let gestureData = MultiTouchHelper.getData(list);
14877
+ let {moving: moving, zooming: zooming, rotating: rotating} = this.transformer;
14878
+ if (singleGesture) {
14879
+ if (!this.transformer.transforming) {
14880
+ const type = MultiTouchHelper.detect(gestureData, isObject(singleGesture) ? singleGesture : {});
14881
+ switch (type) {
14882
+ case "move":
14883
+ moving = true;
14884
+ break;
14885
+
14886
+ case "zoom":
14887
+ zooming = true;
14888
+ break;
14889
+
14890
+ case "rotate":
14891
+ rotating = true;
14892
+ break;
14893
+
14894
+ default:
14895
+ return;
14896
+ }
14897
+ MultiTouchHelper.reset();
14898
+ }
14899
+ if (!moving) gestureData.center = MultiTouchHelper.state.center;
14900
+ } else moving = zooming = rotating = true;
14901
+ Object.assign(data, gestureData.center);
14902
+ data.multiTouch = true;
14903
+ if (rotating) this.rotate(getRotateEventData(gestureData.rotation, data));
14904
+ if (zooming) this.zoom(getZoomEventData(gestureData.scale, data));
14905
+ if (moving) this.move(getMoveEventData(gestureData.move, data));
14728
14906
  };
14729
14907
  const dragger = Dragger.prototype;
14730
14908
  const {abs: abs$1} = Math;
@@ -17460,6 +17638,17 @@ var LeaferUI = function(exports) {
17460
17638
  exports.UI.addAttr("disabledStyle", undefined, stateStyleType);
17461
17639
  exports.UI.addAttr("placeholderStyle", undefined, stateStyleType);
17462
17640
  exports.UI.addAttr("button", false, dataType);
17641
+ ui$1.set = function(data, transition) {
17642
+ if (data) {
17643
+ if (transition) {
17644
+ if (transition === "temp") {
17645
+ this.lockNormalStyle = true;
17646
+ Object.assign(this, data);
17647
+ this.lockNormalStyle = false;
17648
+ } else this.animate(data, transition);
17649
+ } else Object.assign(this, data);
17650
+ }
17651
+ };
17463
17652
  ui$1.focus = function(value = true) {
17464
17653
  this.waitLeafer(() => {
17465
17654
  let {focusData: focusData} = this.app.interaction;
@@ -18058,6 +18247,7 @@ var LeaferUI = function(exports) {
18058
18247
  exports.FileHelper = FileHelper;
18059
18248
  exports.Filter = Filter;
18060
18249
  exports.Finder = Finder;
18250
+ exports.FourNumberHelper = FourNumberHelper;
18061
18251
  exports.FrameData = FrameData;
18062
18252
  exports.GroupData = GroupData;
18063
18253
  exports.HTMLTextData = HTMLTextData;
@@ -18236,8 +18426,8 @@ var LeaferUI = function(exports) {
18236
18426
  exports.stateType = stateType;
18237
18427
  exports.strokeType = strokeType;
18238
18428
  exports.surfaceType = surfaceType;
18239
- exports.tempBounds = tempBounds$1;
18240
- exports.tempMatrix = tempMatrix$1;
18429
+ exports.tempBounds = tempBounds$2;
18430
+ exports.tempMatrix = tempMatrix$2;
18241
18431
  exports.tempPoint = tempPoint$3;
18242
18432
  exports.tryToNumber = tryToNumber;
18243
18433
  exports.useCanvas = useCanvas;