@leafer/worker 1.9.7 → 1.9.8

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.
@@ -247,18 +247,34 @@ class LeafData {
247
247
  }
248
248
  }
249
249
 
250
- const {round: round$6, pow: pow$2, PI: PI$4} = Math;
251
-
252
- const MathHelper = {
253
- within(value, min, max) {
254
- if (isObject(min)) max = min.max, min = min.min;
255
- if (!isUndefined(min) && value < min) value = min;
256
- if (!isUndefined(max) && value > max) value = max;
257
- return value;
250
+ let tempA, tempB, tempTo;
251
+
252
+ const {max: max$5} = Math, tempFour = [ 0, 0, 0, 0 ];
253
+
254
+ const FourNumberHelper = {
255
+ zero: [ ...tempFour ],
256
+ tempFour: tempFour,
257
+ set(to, top, right, bottom, left) {
258
+ if (right === undefined) right = bottom = left = top;
259
+ to[0] = top;
260
+ to[1] = right;
261
+ to[2] = bottom;
262
+ to[3] = left;
263
+ return to;
264
+ },
265
+ setTemp(top, right, bottom, left) {
266
+ return set$1(tempFour, top, right, bottom, left);
258
267
  },
259
- fourNumber(num, maxValue) {
268
+ toTempAB(a, b, change) {
269
+ tempTo = change ? isNumber(a) ? b : a : [];
270
+ if (isNumber(a)) tempA = setTemp(a), tempB = b; else if (isNumber(b)) tempA = a,
271
+ tempB = setTemp(b); else tempA = a, tempB = b;
272
+ if (tempA.length !== 4) tempA = get$5(tempA);
273
+ if (tempB.length !== 4) tempB = get$5(tempB);
274
+ },
275
+ get(num, maxValue) {
260
276
  let data;
261
- if (isArray(num)) {
277
+ if (!isNumber(num)) {
262
278
  switch (num.length) {
263
279
  case 4:
264
280
  data = isUndefined(maxValue) ? num : [ ...num ];
@@ -281,9 +297,39 @@ const MathHelper = {
281
297
  }
282
298
  }
283
299
  if (!data) data = [ num, num, num, num ];
284
- if (maxValue) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
300
+ if (!isUndefined(maxValue)) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
285
301
  return data;
286
302
  },
303
+ max(t, other, change) {
304
+ if (isNumber(t) && isNumber(other)) return max$5(t, other);
305
+ toTempAB(t, other, change);
306
+ 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]));
307
+ },
308
+ add(t, other, change) {
309
+ if (isNumber(t) && isNumber(other)) return t + other;
310
+ toTempAB(t, other, change);
311
+ return set$1(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
312
+ },
313
+ swapAndScale(t, scaleX, scaleY, change) {
314
+ if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
315
+ const to = change ? t : [];
316
+ const [top, right, bottom, left] = t.length === 4 ? t : get$5(t);
317
+ return set$1(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
318
+ }
319
+ };
320
+
321
+ const {set: set$1, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
322
+
323
+ const {round: round$6, pow: pow$2, PI: PI$4} = Math;
324
+
325
+ const MathHelper = {
326
+ within(value, min, max) {
327
+ if (isObject(min)) max = min.max, min = min.min;
328
+ if (!isUndefined(min) && value < min) value = min;
329
+ if (!isUndefined(max) && value > max) value = max;
330
+ return value;
331
+ },
332
+ fourNumber: FourNumberHelper.get,
287
333
  formatRotation(rotation, unsign) {
288
334
  rotation %= 360;
289
335
  if (unsign) {
@@ -433,13 +479,13 @@ const MatrixHelper = {
433
479
  to.f = t.f * pixelRatio;
434
480
  },
435
481
  scaleOfOuter(t, origin, scaleX, scaleY) {
436
- M$a.toInnerPoint(t, origin, tempPoint$4);
437
- M$a.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
482
+ M$b.toInnerPoint(t, origin, tempPoint$4);
483
+ M$b.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
438
484
  },
439
485
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
440
- M$a.translateInner(t, origin.x, origin.y);
441
- M$a.scale(t, scaleX, scaleY);
442
- M$a.translateInner(t, -origin.x, -origin.y);
486
+ M$b.translateInner(t, origin.x, origin.y);
487
+ M$b.scale(t, scaleX, scaleY);
488
+ M$b.translateInner(t, -origin.x, -origin.y);
443
489
  },
444
490
  rotate(t, rotation) {
445
491
  const {a: a, b: b, c: c, d: d} = t;
@@ -452,13 +498,13 @@ const MatrixHelper = {
452
498
  t.d = c * sinR + d * cosR;
453
499
  },
454
500
  rotateOfOuter(t, origin, rotation) {
455
- M$a.toInnerPoint(t, origin, tempPoint$4);
456
- M$a.rotateOfInner(t, tempPoint$4, rotation);
501
+ M$b.toInnerPoint(t, origin, tempPoint$4);
502
+ M$b.rotateOfInner(t, tempPoint$4, rotation);
457
503
  },
458
504
  rotateOfInner(t, origin, rotation) {
459
- M$a.translateInner(t, origin.x, origin.y);
460
- M$a.rotate(t, rotation);
461
- M$a.translateInner(t, -origin.x, -origin.y);
505
+ M$b.translateInner(t, origin.x, origin.y);
506
+ M$b.rotate(t, rotation);
507
+ M$b.translateInner(t, -origin.x, -origin.y);
462
508
  },
463
509
  skew(t, skewX, skewY) {
464
510
  const {a: a, b: b, c: c, d: d} = t;
@@ -474,13 +520,13 @@ const MatrixHelper = {
474
520
  }
475
521
  },
476
522
  skewOfOuter(t, origin, skewX, skewY) {
477
- M$a.toInnerPoint(t, origin, tempPoint$4);
478
- M$a.skewOfInner(t, tempPoint$4, skewX, skewY);
523
+ M$b.toInnerPoint(t, origin, tempPoint$4);
524
+ M$b.skewOfInner(t, tempPoint$4, skewX, skewY);
479
525
  },
480
526
  skewOfInner(t, origin, skewX, skewY = 0) {
481
- M$a.translateInner(t, origin.x, origin.y);
482
- M$a.skew(t, skewX, skewY);
483
- M$a.translateInner(t, -origin.x, -origin.y);
527
+ M$b.translateInner(t, origin.x, origin.y);
528
+ M$b.skew(t, skewX, skewY);
529
+ M$b.translateInner(t, -origin.x, -origin.y);
484
530
  },
485
531
  multiply(t, child) {
486
532
  const {a: a, b: b, c: c, d: d, e: e, f: f} = t;
@@ -519,15 +565,15 @@ const MatrixHelper = {
519
565
  to.f = e * parent.b + f * parent.d + parent.f;
520
566
  },
521
567
  divide(t, child) {
522
- M$a.multiply(t, M$a.tempInvert(child));
568
+ M$b.multiply(t, M$b.tempInvert(child));
523
569
  },
524
570
  divideParent(t, parent) {
525
- M$a.multiplyParent(t, M$a.tempInvert(parent));
571
+ M$b.multiplyParent(t, M$b.tempInvert(parent));
526
572
  },
527
573
  tempInvert(t) {
528
- const {tempMatrix: tempMatrix} = M$a;
529
- M$a.copy(tempMatrix, t);
530
- M$a.invert(tempMatrix);
574
+ const {tempMatrix: tempMatrix} = M$b;
575
+ M$b.copy(tempMatrix, t);
576
+ M$b.invert(tempMatrix);
531
577
  return tempMatrix;
532
578
  },
533
579
  invert(t) {
@@ -605,7 +651,7 @@ const MatrixHelper = {
605
651
  }
606
652
  t.e = x;
607
653
  t.f = y;
608
- if (origin = origin || around) M$a.translateInner(t, -origin.x, -origin.y, !around);
654
+ if (origin = origin || around) M$b.translateInner(t, -origin.x, -origin.y, !around);
609
655
  },
610
656
  getLayout(t, origin, around, firstSkewY) {
611
657
  const {a: a, b: b, c: c, d: d, e: e, f: f} = t;
@@ -666,11 +712,11 @@ const MatrixHelper = {
666
712
  return world;
667
713
  },
668
714
  reset(t) {
669
- M$a.set(t);
715
+ M$b.set(t);
670
716
  }
671
717
  };
672
718
 
673
- const M$a = MatrixHelper;
719
+ const M$b = MatrixHelper;
674
720
 
675
721
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
676
722
 
@@ -1014,7 +1060,7 @@ class Matrix {
1014
1060
  }
1015
1061
  }
1016
1062
 
1017
- const tempMatrix$1 = new Matrix;
1063
+ const tempMatrix$2 = new Matrix;
1018
1064
 
1019
1065
  const TwoPointBoundsHelper = {
1020
1066
  tempPointBounds: {},
@@ -1164,10 +1210,10 @@ const point$2 = {};
1164
1210
 
1165
1211
  const toPoint$5 = {};
1166
1212
 
1167
- const tempBounds$2 = {};
1213
+ const tempBounds$3 = {};
1168
1214
 
1169
1215
  const BoundsHelper = {
1170
- tempBounds: tempBounds$2,
1216
+ tempBounds: tempBounds$3,
1171
1217
  set(t, x = 0, y = 0, width = 0, height = 0) {
1172
1218
  t.x = x;
1173
1219
  t.y = y;
@@ -1218,19 +1264,11 @@ const BoundsHelper = {
1218
1264
  B.move(t, x, y);
1219
1265
  return t;
1220
1266
  },
1221
- toOffsetOutBounds(t, to, parent) {
1222
- if (!to) {
1223
- to = t;
1224
- } else {
1225
- copy$c(to, t);
1226
- }
1227
- if (parent) {
1228
- to.offsetX = -(B.maxX(parent) - t.x);
1229
- to.offsetY = -(B.maxY(parent) - t.y);
1230
- } else {
1231
- to.offsetX = t.x + t.width;
1232
- to.offsetY = t.y + t.height;
1233
- }
1267
+ toOffsetOutBounds(t, to, offsetBounds) {
1268
+ if (!to) to = t; else copy$c(to, t);
1269
+ if (!offsetBounds) offsetBounds = t;
1270
+ to.offsetX = B.maxX(offsetBounds);
1271
+ to.offsetY = B.maxY(offsetBounds);
1234
1272
  B.move(to, -to.offsetX, -to.offsetY);
1235
1273
  },
1236
1274
  scale(t, scaleX, scaleY = scaleX, onlySize) {
@@ -1244,9 +1282,9 @@ const BoundsHelper = {
1244
1282
  t.height *= scaleY;
1245
1283
  },
1246
1284
  tempToOuterOf(t, matrix) {
1247
- B.copy(tempBounds$2, t);
1248
- B.toOuterOf(tempBounds$2, matrix);
1249
- return tempBounds$2;
1285
+ B.copy(tempBounds$3, t);
1286
+ B.toOuterOf(tempBounds$3, matrix);
1287
+ return tempBounds$3;
1250
1288
  },
1251
1289
  getOuterOf(t, matrix) {
1252
1290
  t = Object.assign({}, t);
@@ -1304,9 +1342,9 @@ const BoundsHelper = {
1304
1342
  put(t, put, align = "center", putScale = 1, changeSize = true, to) {
1305
1343
  to || (to = put);
1306
1344
  if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
1307
- tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
1308
- tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
1309
- AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
1345
+ tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
1346
+ tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
1347
+ AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
1310
1348
  },
1311
1349
  getSpread(t, spread, side) {
1312
1350
  const n = {};
@@ -1376,7 +1414,7 @@ const BoundsHelper = {
1376
1414
  first = false;
1377
1415
  if (!addMode) copy$c(t, bounds);
1378
1416
  } else {
1379
- add$1(t, bounds);
1417
+ add$2(t, bounds);
1380
1418
  }
1381
1419
  }
1382
1420
  }
@@ -1390,7 +1428,7 @@ const BoundsHelper = {
1390
1428
  B.set(t, point.x, point.y);
1391
1429
  },
1392
1430
  addPoint(t, point) {
1393
- add$1(t, point, true);
1431
+ add$2(t, point, true);
1394
1432
  },
1395
1433
  getPoints(t) {
1396
1434
  const {x: x, y: y, width: width, height: height} = t;
@@ -1461,7 +1499,7 @@ const BoundsHelper = {
1461
1499
 
1462
1500
  const B = BoundsHelper;
1463
1501
 
1464
- const {add: add$1, copy: copy$c} = B;
1502
+ const {add: add$2, copy: copy$c} = B;
1465
1503
 
1466
1504
  class Bounds {
1467
1505
  get minX() {
@@ -1606,7 +1644,7 @@ class Bounds {
1606
1644
  }
1607
1645
  }
1608
1646
 
1609
- const tempBounds$1 = new Bounds;
1647
+ const tempBounds$2 = new Bounds;
1610
1648
 
1611
1649
  class AutoBounds {
1612
1650
  constructor(top, right, bottom, left, width, height) {
@@ -2261,7 +2299,7 @@ class LeaferCanvasBase extends Canvas$1 {
2261
2299
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2262
2300
  if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
2263
2301
  pixelScale(matrix, pixelRatio, w);
2264
- if (pixelSnap) {
2302
+ if (pixelSnap && !matrix.ignorePixelSnap) {
2265
2303
  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),
2266
2304
  w.f = round$4(w.f);
2267
2305
  }
@@ -2560,14 +2598,14 @@ const {setPoint: setPoint$4, addPoint: addPoint$2} = TwoPointBoundsHelper;
2560
2598
 
2561
2599
  const {set: set, toNumberPoints: toNumberPoints$1} = PointHelper;
2562
2600
 
2563
- const {M: M$9, L: L$a, C: C$8, Q: Q$7, Z: Z$8} = PathCommandMap;
2601
+ const {M: M$a, L: L$a, C: C$8, Q: Q$7, Z: Z$8} = PathCommandMap;
2564
2602
 
2565
2603
  const tempPoint$2 = {};
2566
2604
 
2567
2605
  const BezierHelper = {
2568
2606
  points(data, originPoints, curve, close) {
2569
2607
  let points = toNumberPoints$1(originPoints);
2570
- data.push(M$9, points[0], points[1]);
2608
+ data.push(M$a, points[0], points[1]);
2571
2609
  if (curve && points.length > 5) {
2572
2610
  let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
2573
2611
  let ba, cb, d, len = points.length;
@@ -2674,7 +2712,7 @@ const BezierHelper = {
2674
2712
  let startX = x = rotationCos * radiusX * startCos - rotationSin * radiusY * startSin;
2675
2713
  let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
2676
2714
  let fromX = cx + x, fromY = cy + y;
2677
- if (data) data.push(data.length ? L$a : M$9, fromX, fromY);
2715
+ if (data) data.push(data.length ? L$a : M$a, fromX, fromY);
2678
2716
  if (setPointBounds) setPoint$4(setPointBounds, fromX, fromY);
2679
2717
  if (setStartPoint) set(setStartPoint, fromX, fromY);
2680
2718
  for (let i = 0; i < parts; i++) {
@@ -2804,7 +2842,7 @@ const EllipseHelper = {
2804
2842
  }
2805
2843
  };
2806
2844
 
2807
- 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;
2845
+ 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;
2808
2846
 
2809
2847
  const {rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1} = BezierHelper;
2810
2848
 
@@ -2896,10 +2934,10 @@ const PathConvert = {
2896
2934
  old[i + 1] += x;
2897
2935
  old[i + 2] += y;
2898
2936
 
2899
- case M$8:
2937
+ case M$9:
2900
2938
  x = old[i + 1];
2901
2939
  y = old[i + 2];
2902
- data.push(M$8, x, y);
2940
+ data.push(M$9, x, y);
2903
2941
  i += 3;
2904
2942
  break;
2905
2943
 
@@ -3086,7 +3124,7 @@ const PathConvert = {
3086
3124
  list.forEach(item => {
3087
3125
  switch (item.name) {
3088
3126
  case "M":
3089
- data.push(M$8, item.x, item.y);
3127
+ data.push(M$9, item.x, item.y);
3090
3128
  break;
3091
3129
 
3092
3130
  case "L":
@@ -3125,7 +3163,7 @@ const PathConvert = {
3125
3163
 
3126
3164
  const {current: current, pushData: pushData, copyData: copyData} = PathConvert;
3127
3165
 
3128
- 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;
3166
+ 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;
3129
3167
 
3130
3168
  const {getMinDistanceFrom: getMinDistanceFrom, getRadianFrom: getRadianFrom} = PointHelper;
3131
3169
 
@@ -3138,7 +3176,7 @@ const PathCommandDataHelper = {
3138
3176
  data.length = 0;
3139
3177
  },
3140
3178
  moveTo(data, x, y) {
3141
- data.push(M$7, x, y);
3179
+ data.push(M$8, x, y);
3142
3180
  },
3143
3181
  lineTo(data, x, y) {
3144
3182
  data.push(L$8, x, y);
@@ -3193,12 +3231,12 @@ const PathCommandDataHelper = {
3193
3231
  },
3194
3232
  drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
3195
3233
  BezierHelper.ellipse(null, x, y, radiusX, radiusY, isNull(rotation) ? 0 : rotation, isNull(startAngle) ? 0 : startAngle, isNull(endAngle) ? 360 : endAngle, anticlockwise, null, null, startPoint);
3196
- data.push(M$7, startPoint.x, startPoint.y);
3234
+ data.push(M$8, startPoint.x, startPoint.y);
3197
3235
  ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
3198
3236
  },
3199
3237
  drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
3200
3238
  BezierHelper.arc(null, x, y, radius, isNull(startAngle) ? 0 : startAngle, isNull(endAngle) ? 360 : endAngle, anticlockwise, null, null, startPoint);
3201
- data.push(M$7, startPoint.x, startPoint.y);
3239
+ data.push(M$8, startPoint.x, startPoint.y);
3202
3240
  arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
3203
3241
  },
3204
3242
  drawPoints(data, points, curve, close) {
@@ -3300,7 +3338,7 @@ class PathCreator {
3300
3338
  paint() {}
3301
3339
  }
3302
3340
 
3303
- 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;
3341
+ 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;
3304
3342
 
3305
3343
  const debug$e = Debug.get("PathDrawer");
3306
3344
 
@@ -3312,7 +3350,7 @@ const PathDrawer = {
3312
3350
  while (i < len) {
3313
3351
  command = data[i];
3314
3352
  switch (command) {
3315
- case M$6:
3353
+ case M$7:
3316
3354
  drawer.moveTo(data[i + 1], data[i + 2]);
3317
3355
  i += 3;
3318
3356
  break;
@@ -3385,7 +3423,7 @@ const PathDrawer = {
3385
3423
  }
3386
3424
  };
3387
3425
 
3388
- 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;
3426
+ 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;
3389
3427
 
3390
3428
  const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
3391
3429
 
@@ -3420,7 +3458,7 @@ const PathBounds = {
3420
3458
  }
3421
3459
  }
3422
3460
  switch (command) {
3423
- case M$5:
3461
+ case M$6:
3424
3462
  case L$6:
3425
3463
  x = data[i + 1];
3426
3464
  y = data[i + 2];
@@ -3520,7 +3558,7 @@ const PathBounds = {
3520
3558
  }
3521
3559
  };
3522
3560
 
3523
- const {M: M$4, L: L$5, Z: Z$3} = PathCommandMap;
3561
+ const {M: M$5, L: L$5, Z: Z$3} = PathCommandMap;
3524
3562
 
3525
3563
  const {getCenterX: getCenterX, getCenterY: getCenterY} = PointHelper;
3526
3564
 
@@ -3535,16 +3573,16 @@ const PathCorner = {
3535
3573
  while (i < len) {
3536
3574
  command = data[i];
3537
3575
  switch (command) {
3538
- case M$4:
3576
+ case M$5:
3539
3577
  startX = lastX = data[i + 1];
3540
3578
  startY = lastY = data[i + 2];
3541
3579
  i += 3;
3542
3580
  if (data[i] === L$5) {
3543
3581
  secondX = data[i + 1];
3544
3582
  secondY = data[i + 2];
3545
- smooth.push(M$4, getCenterX(startX, secondX), getCenterY(startY, secondY));
3583
+ smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3546
3584
  } else {
3547
- smooth.push(M$4, startX, startY);
3585
+ smooth.push(M$5, startX, startY);
3548
3586
  }
3549
3587
  break;
3550
3588
 
@@ -3985,7 +4023,7 @@ const I$1 = ImageManager;
3985
4023
 
3986
4024
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3987
4025
 
3988
- const {floor: floor$2, max: max$2} = Math;
4026
+ const {floor: floor$2, max: max$4} = Math;
3989
4027
 
3990
4028
  class LeaferImage {
3991
4029
  get url() {
@@ -4074,7 +4112,7 @@ class LeaferImage {
4074
4112
  }
4075
4113
  if (data) return data;
4076
4114
  }
4077
- const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
4115
+ const canvas = Platform.origin.createCanvas(max$4(floor$2(width + (xGap || 0)), 1), max$4(floor$2(height + (yGap || 0)), 1));
4078
4116
  const ctx = canvas.getContext("2d");
4079
4117
  if (opacity) ctx.globalAlpha = opacity;
4080
4118
  ctx.imageSmoothingEnabled = smooth === false ? false : true;
@@ -4868,7 +4906,7 @@ const WaitHelper = {
4868
4906
 
4869
4907
  const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$3} = LeafHelper;
4870
4908
 
4871
- const {toOuterOf: toOuterOf$2, getPoints: getPoints, copy: copy$8} = BoundsHelper;
4909
+ const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$8} = BoundsHelper;
4872
4910
 
4873
4911
  const localContent = "_localContentBounds";
4874
4912
 
@@ -4891,7 +4929,7 @@ class LeafLayout {
4891
4929
  this._renderBounds = bounds;
4892
4930
  }
4893
4931
  get localContentBounds() {
4894
- toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4932
+ toOuterOf$3(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
4895
4933
  return this[localContent];
4896
4934
  }
4897
4935
  get localStrokeBounds() {
@@ -4901,15 +4939,15 @@ class LeafLayout {
4901
4939
  return this._localRenderBounds || this;
4902
4940
  }
4903
4941
  get worldContentBounds() {
4904
- toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4942
+ toOuterOf$3(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
4905
4943
  return this[worldContent];
4906
4944
  }
4907
4945
  get worldBoxBounds() {
4908
- toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4946
+ toOuterOf$3(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
4909
4947
  return this[worldBox];
4910
4948
  }
4911
4949
  get worldStrokeBounds() {
4912
- toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4950
+ toOuterOf$3(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
4913
4951
  return this[worldStroke];
4914
4952
  }
4915
4953
  get a() {
@@ -5761,14 +5799,14 @@ const {updateMatrix: updateMatrix$3, updateAllMatrix: updateAllMatrix$3} = LeafH
5761
5799
 
5762
5800
  const {updateBounds: updateBounds$2} = BranchHelper;
5763
5801
 
5764
- const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$7} = BoundsHelper;
5802
+ const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$3, copy: copy$7} = BoundsHelper;
5765
5803
 
5766
5804
  const {toBounds: toBounds$1} = PathBounds;
5767
5805
 
5768
5806
  const LeafBounds = {
5769
5807
  __updateWorldBounds() {
5770
5808
  const layout = this.__layout;
5771
- toOuterOf$1(layout.renderBounds, this.__world, this.__world);
5809
+ toOuterOf$2(layout.renderBounds, this.__world, this.__world);
5772
5810
  if (layout.resized) {
5773
5811
  if (layout.resized === "inner") this.__onUpdateSize();
5774
5812
  if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
@@ -5824,13 +5862,13 @@ const LeafBounds = {
5824
5862
  __updateLocalBoxBounds() {
5825
5863
  if (this.__hasMotionPath) this.__updateMotionPath();
5826
5864
  if (this.__hasAutoLayout) this.__updateAutoLayout();
5827
- toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
5865
+ toOuterOf$2(this.__layout.boxBounds, this.__local, this.__local);
5828
5866
  },
5829
5867
  __updateLocalStrokeBounds() {
5830
- toOuterOf$1(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5868
+ toOuterOf$2(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5831
5869
  },
5832
5870
  __updateLocalRenderBounds() {
5833
- toOuterOf$1(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5871
+ toOuterOf$2(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5834
5872
  },
5835
5873
  __updateBoxBounds(_secondLayout, _bounds) {
5836
5874
  const b = this.__layout.boxBounds;
@@ -5868,11 +5906,11 @@ const LeafBounds = {
5868
5906
  },
5869
5907
  __updateStrokeBounds(_bounds) {
5870
5908
  const layout = this.__layout;
5871
- copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5909
+ copyAndSpread$3(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5872
5910
  },
5873
5911
  __updateRenderBounds(_bounds) {
5874
- const layout = this.__layout;
5875
- layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$7(layout.renderBounds, layout.strokeBounds);
5912
+ const layout = this.__layout, {renderSpread: renderSpread} = layout;
5913
+ isNumber(renderSpread) && renderSpread <= 0 ? copy$7(layout.renderBounds, layout.strokeBounds) : copyAndSpread$3(layout.renderBounds, layout.boxBounds, renderSpread);
5876
5914
  }
5877
5915
  };
5878
5916
 
@@ -5970,11 +6008,13 @@ const tempScaleData$1 = {};
5970
6008
 
5971
6009
  const {LEAF: LEAF, create: create} = IncrementId;
5972
6010
 
6011
+ const {stintSet: stintSet$3} = DataHelper;
6012
+
5973
6013
  const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
5974
6014
 
5975
- const {toOuterOf: toOuterOf} = BoundsHelper;
6015
+ const {toOuterOf: toOuterOf$1} = BoundsHelper;
5976
6016
 
5977
- const {copy: copy$6, move: move$6} = PointHelper;
6017
+ const {copy: copy$6, move: move$8} = PointHelper;
5978
6018
 
5979
6019
  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;
5980
6020
 
@@ -6250,8 +6290,9 @@ let Leaf = class Leaf {
6250
6290
  if (!this.__cameraWorld) this.__cameraWorld = {};
6251
6291
  const cameraWorld = this.__cameraWorld, world = this.__world;
6252
6292
  multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
6253
- toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
6254
- cameraWorld.half !== world.half && (cameraWorld.half = world.half);
6293
+ toOuterOf$1(this.__layout.renderBounds, cameraWorld, cameraWorld);
6294
+ stintSet$3(cameraWorld, "half", world.half);
6295
+ stintSet$3(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
6255
6296
  return cameraWorld;
6256
6297
  } else {
6257
6298
  return this.__world;
@@ -6285,7 +6326,7 @@ let Leaf = class Leaf {
6285
6326
  getWorldBounds(inner, relative, change) {
6286
6327
  const matrix = relative ? getRelativeWorld(this, relative) : this.worldTransform;
6287
6328
  const to = change ? inner : {};
6288
- toOuterOf(inner, matrix, to);
6329
+ toOuterOf$1(inner, matrix, to);
6289
6330
  return to;
6290
6331
  }
6291
6332
  worldToLocal(world, to, distance, relative) {
@@ -6318,7 +6359,7 @@ let Leaf = class Leaf {
6318
6359
  }
6319
6360
  getBoxPointByInner(inner, _relative, _distance, change) {
6320
6361
  const point = change ? inner : Object.assign({}, inner), {x: x, y: y} = this.boxBounds;
6321
- move$6(point, -x, -y);
6362
+ move$8(point, -x, -y);
6322
6363
  return point;
6323
6364
  }
6324
6365
  getInnerPoint(world, relative, distance, change) {
@@ -6328,7 +6369,7 @@ let Leaf = class Leaf {
6328
6369
  }
6329
6370
  getInnerPointByBox(box, _relative, _distance, change) {
6330
6371
  const point = change ? box : Object.assign({}, box), {x: x, y: y} = this.boxBounds;
6331
- move$6(point, x, y);
6372
+ move$8(point, x, y);
6332
6373
  return point;
6333
6374
  }
6334
6375
  getInnerPointByLocal(local, _relative, distance, change) {
@@ -6774,7 +6815,7 @@ class LeafLevelList {
6774
6815
  }
6775
6816
  }
6776
6817
 
6777
- const version = "1.9.7";
6818
+ const version = "1.9.8";
6778
6819
 
6779
6820
  class LeaferCanvas extends LeaferCanvasBase {
6780
6821
  get allowBackgroundColor() {
@@ -7199,6 +7240,7 @@ class Renderer {
7199
7240
  usePartRender: true,
7200
7241
  maxFPS: 120
7201
7242
  };
7243
+ this.frames = [];
7202
7244
  this.target = target;
7203
7245
  this.canvas = canvas;
7204
7246
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -7351,12 +7393,15 @@ class Renderer {
7351
7393
  const target = this.target;
7352
7394
  if (this.requestTime || !target) return;
7353
7395
  if (target.parentApp) return target.parentApp.requestRender(false);
7354
- const requestTime = this.requestTime = Date.now();
7396
+ this.requestTime = this.frameTime || Date.now();
7355
7397
  const render = () => {
7356
- const nowFPS = 1e3 / (Date.now() - requestTime);
7398
+ const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
7357
7399
  const {maxFPS: maxFPS} = this.config;
7358
- if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7359
- this.FPS = Math.min(120, Math.ceil(nowFPS));
7400
+ if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
7401
+ const {frames: frames} = this;
7402
+ if (frames.length > 30) frames.shift();
7403
+ frames.push(nowFPS);
7404
+ this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
7360
7405
  this.requestTime = 0;
7361
7406
  this.checkRender();
7362
7407
  };
@@ -8012,39 +8057,41 @@ class CanvasData extends RectData {
8012
8057
  }
8013
8058
  }
8014
8059
 
8060
+ const {max: max$3, add: add$1} = FourNumberHelper;
8061
+
8015
8062
  const UIBounds = {
8016
8063
  __updateStrokeSpread() {
8017
- let width = 0, boxWidth = 0;
8064
+ let spread = 0, boxSpread = 0;
8018
8065
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
8019
8066
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
8020
- boxWidth = width = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
8067
+ boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
8021
8068
  if (!data.__boxStroke) {
8022
- const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * width;
8069
+ const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
8023
8070
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
8024
- width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
8071
+ spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
8025
8072
  }
8026
8073
  }
8027
- if (data.__useArrow) width += strokeWidth * 5;
8074
+ if (data.__useArrow) spread += strokeWidth * 5;
8028
8075
  if (box) {
8029
- width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
8030
- boxWidth = box.__layout.strokeBoxSpread;
8076
+ spread = max$3(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
8077
+ boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
8031
8078
  }
8032
- this.__layout.strokeBoxSpread = boxWidth;
8033
- return width;
8079
+ this.__layout.strokeBoxSpread = boxSpread;
8080
+ return spread;
8034
8081
  },
8035
8082
  __updateRenderSpread() {
8036
- let width = 0;
8037
- const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
8038
- if (shadow) width = Effect.getShadowSpread(this, shadow);
8039
- if (blur) width = Math.max(width, blur);
8040
- if (filter) width += Filter.getSpread(filter);
8041
- if (renderSpread) width += renderSpread;
8042
- let shapeWidth = width = Math.ceil(width);
8043
- 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));
8044
- if (backgroundBlur) shapeWidth = Math.max(shapeWidth, backgroundBlur);
8045
- this.__layout.renderShapeSpread = shapeWidth;
8046
- width += this.__layout.strokeSpread || 0;
8047
- return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
8083
+ let spread = 0;
8084
+ const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
8085
+ if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
8086
+ if (blur) spread = max$3(spread, blur);
8087
+ if (filter) spread = add$1(spread, Filter.getSpread(filter));
8088
+ if (renderSpread) spread = add$1(spread, renderSpread);
8089
+ if (strokeSpread) spread = add$1(spread, strokeSpread);
8090
+ let shapeSpread = spread;
8091
+ if (innerShadow) shapeSpread = max$3(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
8092
+ if (backgroundBlur) shapeSpread = max$3(shapeSpread, backgroundBlur);
8093
+ this.__layout.renderShapeSpread = shapeSpread;
8094
+ return box ? max$3(box.__updateRenderSpread(), spread) : spread;
8048
8095
  }
8049
8096
  };
8050
8097
 
@@ -9355,7 +9402,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
9355
9402
 
9356
9403
  Canvas = __decorate([ registerUI() ], Canvas);
9357
9404
 
9358
- const {copyAndSpread: copyAndSpread$1, includes: includes, spread: spread, setList: setList} = BoundsHelper;
9405
+ const {copyAndSpread: copyAndSpread$2, includes: includes, spread: spread, setList: setList} = BoundsHelper;
9359
9406
 
9360
9407
  let Text = class Text extends UI {
9361
9408
  get __tag() {
@@ -9402,13 +9449,13 @@ let Text = class Text extends UI {
9402
9449
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9403
9450
  }
9404
9451
  __updateRenderSpread() {
9405
- let width = super.__updateRenderSpread();
9406
- if (!width) width = this.isOverflow ? 1 : 0;
9407
- return width;
9452
+ let spread = super.__updateRenderSpread();
9453
+ if (!spread) spread = this.isOverflow ? 1 : 0;
9454
+ return spread;
9408
9455
  }
9409
9456
  __updateRenderBounds() {
9410
9457
  const {renderBounds: renderBounds, renderSpread: renderSpread} = this.__layout;
9411
- copyAndSpread$1(renderBounds, this.__.__textBoxBounds, renderSpread);
9458
+ copyAndSpread$2(renderBounds, this.__.__textBoxBounds, renderSpread);
9412
9459
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
9413
9460
  }
9414
9461
  __updateChange() {
@@ -9834,9 +9881,9 @@ let DragEvent = class DragEvent extends PointerEvent {
9834
9881
  static setData(data) {
9835
9882
  this.data = data;
9836
9883
  }
9837
- static getValidMove(leaf, start, total, checkLimit = true) {
9838
- const move = leaf.getLocalPoint(total, null, true);
9839
- PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9884
+ static getValidMove(leaf, localStart, worldTotal, checkLimit = true) {
9885
+ const move = leaf.getLocalPoint(worldTotal, null, true);
9886
+ PointHelper.move(move, localStart.x - leaf.x, localStart.y - leaf.y);
9840
9887
  if (checkLimit) this.limitMove(leaf, move);
9841
9888
  DragBoundsHelper.axisMove(leaf, move);
9842
9889
  return move;
@@ -10866,8 +10913,8 @@ ui$5.__updateHitCanvas = function() {
10866
10913
  if (isHitPixel) {
10867
10914
  const {renderBounds: renderBounds} = this.__layout;
10868
10915
  const size = Platform.image.hitCanvasSize;
10869
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10870
- const {x: x, y: y, width: width, height: height} = tempBounds$1.set(renderBounds).scale(scale);
10916
+ const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10917
+ const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
10871
10918
  h.resize({
10872
10919
  width: width,
10873
10920
  height: height,
@@ -10964,8 +11011,8 @@ canvas$1.hitStroke = function(point, strokeWidth) {
10964
11011
  canvas$1.hitPixel = function(radiusPoint, offset, scale = 1) {
10965
11012
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
10966
11013
  if (offset) x -= offset.x, y -= offset.y;
10967
- tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10968
- const {data: data} = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
11014
+ tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11015
+ const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
10969
11016
  for (let i = 0, len = data.length; i < len; i += 4) {
10970
11017
  if (data[i + 3] > 0) return true;
10971
11018
  }
@@ -11165,24 +11212,29 @@ function drawOutside(stroke, ui, canvas) {
11165
11212
  }
11166
11213
  }
11167
11214
 
11168
- const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
11215
+ const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
11216
+
11217
+ const tempBounds$1 = {};
11169
11218
 
11170
11219
  function shape(ui, current, options) {
11171
11220
  const canvas = current.getSameCanvas();
11172
- const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
11173
- let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
11221
+ const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
11222
+ const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
11223
+ toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$1, layout.boxBounds, layout.strokeSpread),
11224
+ tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11225
+ let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
11174
11226
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11175
- if (currentBounds.includes(nowWorld)) {
11227
+ if (currentBounds.includes(nowWorldShapeBounds)) {
11176
11228
  worldCanvas = canvas;
11177
- bounds = shapeBounds = nowWorld;
11229
+ bounds = shapeBounds = nowWorldShapeBounds;
11230
+ renderBounds = nowWorld;
11178
11231
  } else {
11179
- const {renderShapeSpread: spread} = ui.__layout;
11180
11232
  let worldClipBounds;
11181
11233
  if (Platform.fullImageShadow) {
11182
- worldClipBounds = nowWorld;
11234
+ worldClipBounds = nowWorldShapeBounds;
11183
11235
  } else {
11184
- const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
11185
- worldClipBounds = getIntersectData(spreadBounds, nowWorld);
11236
+ const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
11237
+ worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
11186
11238
  }
11187
11239
  fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
11188
11240
  let {a: fitScaleX, d: fitScaleY} = fitMatrix;
@@ -11192,8 +11244,10 @@ function shape(ui, current, options) {
11192
11244
  scaleX *= fitScaleX;
11193
11245
  scaleY *= fitScaleY;
11194
11246
  }
11195
- shapeBounds = getOuterOf(nowWorld, fitMatrix);
11247
+ shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
11196
11248
  bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
11249
+ renderBounds = getOuterOf(nowWorld, fitMatrix);
11250
+ move$7(renderBounds, -fitMatrix.e, -fitMatrix.f);
11197
11251
  const userMatrix = options.matrix;
11198
11252
  if (userMatrix) {
11199
11253
  matrix = new Matrix(fitMatrix);
@@ -11212,6 +11266,7 @@ function shape(ui, current, options) {
11212
11266
  matrix: matrix,
11213
11267
  fitMatrix: fitMatrix,
11214
11268
  bounds: bounds,
11269
+ renderBounds: renderBounds,
11215
11270
  worldCanvas: worldCanvas,
11216
11271
  shapeBounds: shapeBounds,
11217
11272
  scaleX: scaleX,
@@ -11315,7 +11370,7 @@ const PaintModule = {
11315
11370
  shape: shape
11316
11371
  };
11317
11372
 
11318
- let origin$1 = {}, tempMatrix = getMatrixData();
11373
+ let origin$1 = {}, tempMatrix$1 = getMatrixData();
11319
11374
 
11320
11375
  const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper} = MatrixHelper;
11321
11376
 
@@ -11330,12 +11385,12 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
11330
11385
  data.transform = transform;
11331
11386
  }
11332
11387
 
11333
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
11388
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
11334
11389
  const transform = get$3();
11335
11390
  layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
11336
- if (clipSize) {
11337
- tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
11338
- multiplyParent(transform, tempMatrix);
11391
+ if (clipScaleX) {
11392
+ tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
11393
+ multiplyParent(transform, tempMatrix$1);
11339
11394
  }
11340
11395
  data.transform = transform;
11341
11396
  }
@@ -11436,7 +11491,12 @@ function getPatternData(paint, box, image) {
11436
11491
 
11437
11492
  case "normal":
11438
11493
  case "clip":
11439
- if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
11494
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
11495
+ let clipScaleX, clipScaleY;
11496
+ if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
11497
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
11498
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
11499
+ }
11440
11500
  break;
11441
11501
 
11442
11502
  case "repeat":
@@ -11594,7 +11654,7 @@ function ignoreRender(ui, value) {
11594
11654
 
11595
11655
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
11596
11656
 
11597
- const {floor: floor$1, ceil: ceil$1, max: max$1, abs: abs$4} = Math;
11657
+ const {floor: floor$1, ceil: ceil$1, max: max$2, abs: abs$4} = Math;
11598
11658
 
11599
11659
  function createPattern(ui, paint, pixelRatio) {
11600
11660
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -11643,8 +11703,8 @@ function createPattern(ui, paint, pixelRatio) {
11643
11703
  if (transform || scaleX !== 1 || scaleY !== 1) {
11644
11704
  const canvasWidth = width + (xGap || 0);
11645
11705
  const canvasHeight = height + (yGap || 0);
11646
- scaleX /= canvasWidth / max$1(floor$1(canvasWidth), 1);
11647
- scaleY /= canvasHeight / max$1(floor$1(canvasHeight), 1);
11706
+ scaleX /= canvasWidth / max$2(floor$1(canvasWidth), 1);
11707
+ scaleY /= canvasHeight / max$2(floor$1(canvasHeight), 1);
11648
11708
  if (!imageMatrix) {
11649
11709
  imageMatrix = get$1();
11650
11710
  if (transform) copy$4(imageMatrix, transform);
@@ -11670,17 +11730,15 @@ function checkImage(ui, canvas, paint, allowDraw) {
11670
11730
  if (allowDraw) {
11671
11731
  if (data.repeat) {
11672
11732
  allowDraw = false;
11673
- } else {
11674
- if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
11675
- let {width: width, height: height} = data;
11676
- width *= scaleX * pixelRatio;
11677
- height *= scaleY * pixelRatio;
11678
- if (data.scaleX) {
11679
- width *= data.scaleX;
11680
- height *= data.scaleY;
11681
- }
11682
- allowDraw = width * height > Platform.image.maxCacheSize;
11733
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
11734
+ let {width: width, height: height} = data;
11735
+ width *= scaleX * pixelRatio;
11736
+ height *= scaleY * pixelRatio;
11737
+ if (data.scaleX) {
11738
+ width *= data.scaleX;
11739
+ height *= data.scaleY;
11683
11740
  }
11741
+ allowDraw = width * height > Platform.image.maxCacheSize;
11684
11742
  }
11685
11743
  }
11686
11744
  if (allowDraw) {
@@ -11860,20 +11918,20 @@ const PaintGradientModule = {
11860
11918
  getTransform: getTransform
11861
11919
  };
11862
11920
 
11863
- const {copy: copy$3, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
11921
+ const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$1} = Math;
11864
11922
 
11865
- const tempBounds = {};
11923
+ const tempBounds = {}, tempMatrix = new Matrix;
11866
11924
 
11867
11925
  const offsetOutBounds$1 = {};
11868
11926
 
11869
11927
  function shadow$1(ui, current, shape) {
11870
- let copyBounds, spreadScale;
11871
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
11928
+ let copyBounds, transform;
11929
+ const {__nowWorld: nowWorld} = ui;
11872
11930
  const {shadow: shadow} = ui.__;
11873
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11931
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11874
11932
  const other = current.getSameCanvas();
11875
11933
  const end = shadow.length - 1;
11876
- toOffsetOutBounds$1(bounds, offsetOutBounds$1);
11934
+ toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
11877
11935
  shadow.forEach((item, index) => {
11878
11936
  let otherScale = 1;
11879
11937
  if (item.scaleFixed) {
@@ -11881,54 +11939,61 @@ function shadow$1(ui, current, shape) {
11881
11939
  if (sx > 1) otherScale = 1 / sx;
11882
11940
  }
11883
11941
  other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
11884
- spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
11885
- drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
11886
- copyBounds = bounds;
11942
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
11943
+ if (transform) other.setTransform(transform);
11944
+ drawWorldShadow(other, offsetOutBounds$1, shape);
11945
+ if (transform) other.resetTransform();
11946
+ copyBounds = renderBounds;
11887
11947
  if (item.box) {
11888
11948
  other.restore();
11889
11949
  other.save();
11890
11950
  if (worldCanvas) {
11891
- other.copyWorld(other, bounds, nowWorld, "copy");
11951
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
11892
11952
  copyBounds = nowWorld;
11893
11953
  }
11894
11954
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
11895
11955
  }
11896
- if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11956
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11897
11957
  if (end && index < end) other.clearWorld(copyBounds);
11898
11958
  });
11899
11959
  other.recycle(copyBounds);
11900
11960
  }
11901
11961
 
11902
- function getShadowSpread(_ui, shadow) {
11903
- let width = 0;
11904
- 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));
11905
- return width;
11962
+ function getShadowRenderSpread(_ui, shadow) {
11963
+ let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
11964
+ shadow.forEach(item => {
11965
+ x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
11966
+ top = max$1(top, spread + blur - y);
11967
+ right = max$1(right, spread + blur + x);
11968
+ bottom = max$1(bottom, spread + blur + y);
11969
+ left = max$1(left, spread + blur - x);
11970
+ });
11971
+ return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
11906
11972
  }
11907
11973
 
11908
- function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
11909
- const {bounds: bounds, shapeBounds: shapeBounds} = shape;
11974
+ function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
11975
+ if (shadow.spread) {
11976
+ const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
11977
+ tempMatrix.set().scaleOfOuter({
11978
+ x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
11979
+ y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
11980
+ }, spreadScale);
11981
+ return tempMatrix;
11982
+ }
11983
+ return undefined;
11984
+ }
11985
+
11986
+ function drawWorldShadow(canvas, outBounds, shape) {
11987
+ const {shapeBounds: shapeBounds} = shape;
11988
+ let from, to;
11910
11989
  if (Platform.fullImageShadow) {
11911
11990
  copy$3(tempBounds, canvas.bounds);
11912
- tempBounds.x += outBounds.x - shapeBounds.x;
11913
- tempBounds.y += outBounds.y - shapeBounds.y;
11914
- if (spreadScale) {
11915
- const {fitMatrix: fitMatrix} = shape;
11916
- tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
11917
- tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
11918
- tempBounds.width *= spreadScale;
11919
- tempBounds.height *= spreadScale;
11920
- }
11921
- canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
11991
+ move$6(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
11992
+ from = canvas.bounds, to = tempBounds;
11922
11993
  } else {
11923
- if (spreadScale) {
11924
- copy$3(tempBounds, outBounds);
11925
- tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
11926
- tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
11927
- tempBounds.width *= spreadScale;
11928
- tempBounds.height *= spreadScale;
11929
- }
11930
- canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
11994
+ from = shapeBounds, to = outBounds;
11931
11995
  }
11996
+ canvas.copyWorld(shape.canvas, from, to);
11932
11997
  }
11933
11998
 
11934
11999
  const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
@@ -11936,13 +12001,13 @@ const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
11936
12001
  const offsetOutBounds = {};
11937
12002
 
11938
12003
  function innerShadow(ui, current, shape) {
11939
- let copyBounds, spreadScale;
11940
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
12004
+ let copyBounds, transform;
12005
+ const {__nowWorld: nowWorld} = ui;
11941
12006
  const {innerShadow: innerShadow} = ui.__;
11942
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
12007
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
11943
12008
  const other = current.getSameCanvas();
11944
12009
  const end = innerShadow.length - 1;
11945
- toOffsetOutBounds(bounds, offsetOutBounds);
12010
+ toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
11946
12011
  innerShadow.forEach((item, index) => {
11947
12012
  let otherScale = 1;
11948
12013
  if (item.scaleFixed) {
@@ -11951,16 +12016,17 @@ function innerShadow(ui, current, shape) {
11951
12016
  }
11952
12017
  other.save();
11953
12018
  other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
11954
- spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
11955
- drawWorldShadow(other, offsetOutBounds, spreadScale, shape);
12019
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
12020
+ if (transform) other.setTransform(transform);
12021
+ drawWorldShadow(other, offsetOutBounds, shape);
11956
12022
  other.restore();
11957
12023
  if (worldCanvas) {
11958
- other.copyWorld(other, bounds, nowWorld, "copy");
12024
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
11959
12025
  other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
11960
12026
  copyBounds = nowWorld;
11961
12027
  } else {
11962
12028
  other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
11963
- copyBounds = bounds;
12029
+ copyBounds = renderBounds;
11964
12030
  }
11965
12031
  other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
11966
12032
  LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
@@ -11969,6 +12035,8 @@ function innerShadow(ui, current, shape) {
11969
12035
  other.recycle(copyBounds);
11970
12036
  }
11971
12037
 
12038
+ const getInnerShadowSpread = getShadowRenderSpread;
12039
+
11972
12040
  function blur(ui, current, origin) {
11973
12041
  const {blur: blur} = ui.__;
11974
12042
  origin.setWorldBlur(blur * ui.__nowWorld.a);
@@ -11983,10 +12051,12 @@ const EffectModule = {
11983
12051
  innerShadow: innerShadow,
11984
12052
  blur: blur,
11985
12053
  backgroundBlur: backgroundBlur,
11986
- getShadowSpread: getShadowSpread,
12054
+ getShadowRenderSpread: getShadowRenderSpread,
12055
+ getShadowTransform: getShadowTransform,
11987
12056
  isTransformShadow(_shadow) {
11988
12057
  return undefined;
11989
- }
12058
+ },
12059
+ getInnerShadowSpread: getInnerShadowSpread
11990
12060
  };
11991
12061
 
11992
12062
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -12003,6 +12073,7 @@ Group.prototype.__renderMask = function(canvas, options) {
12003
12073
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
12004
12074
  maskCanvas = contentCanvas = null;
12005
12075
  }
12076
+ if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
12006
12077
  maskOpacity = child.__.opacity;
12007
12078
  usedGrayscaleAlpha = false;
12008
12079
  if (mask === "path" || mask === "clipping-path") {
@@ -12020,7 +12091,6 @@ Group.prototype.__renderMask = function(canvas, options) {
12020
12091
  if (!contentCanvas) contentCanvas = getCanvas(canvas);
12021
12092
  child.__render(maskCanvas, options);
12022
12093
  }
12023
- if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
12024
12094
  continue;
12025
12095
  }
12026
12096
  const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
@@ -12657,10 +12727,6 @@ function targetAttr(fn) {
12657
12727
  if (t.config) {
12658
12728
  const isSelect = key === "target";
12659
12729
  if (isSelect) {
12660
- t.setDimOthers(false);
12661
- t.setBright(false);
12662
- if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
12663
- if (t.single) t.element.syncEventer = null;
12664
12730
  const {beforeSelect: beforeSelect} = t.config;
12665
12731
  if (beforeSelect) {
12666
12732
  const check = beforeSelect({
@@ -12668,6 +12734,10 @@ function targetAttr(fn) {
12668
12734
  });
12669
12735
  if (isObject(check)) value = check; else if (check === false) return;
12670
12736
  }
12737
+ t.setDimOthers(false);
12738
+ t.setBright(false);
12739
+ if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
12740
+ if (t.single) t.element.syncEventer = null;
12671
12741
  }
12672
12742
  const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
12673
12743
  if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, {
@@ -12853,11 +12923,12 @@ class EditSelect extends Group {
12853
12923
  return !!this.originList;
12854
12924
  }
12855
12925
  get running() {
12856
- const {editor: editor} = this;
12857
- return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && this.app.mode === "normal";
12926
+ const {editor: editor, app: app} = this;
12927
+ return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && (app && app.mode === "normal");
12858
12928
  }
12859
12929
  get isMoveMode() {
12860
- return this.app && this.app.interaction.moveMode;
12930
+ const {app: app} = this;
12931
+ return app && app.interaction.moveMode;
12861
12932
  }
12862
12933
  constructor(editor) {
12863
12934
  super();
@@ -12920,12 +12991,12 @@ class EditSelect extends Group {
12920
12991
  onTap(e) {
12921
12992
  if (e.multiTouch) return;
12922
12993
  const {editor: editor} = this;
12923
- const {select: select} = editor.mergeConfig;
12994
+ const {select: select, selectKeep: selectKeep} = editor.mergeConfig;
12924
12995
  if (select === "tap") this.checkAndSelect(e); else if (this.waitSelect) this.waitSelect();
12925
12996
  if (this.needRemoveItem) {
12926
12997
  editor.removeItem(this.needRemoveItem);
12927
12998
  } else if (this.isMoveMode) {
12928
- editor.target = null;
12999
+ if (!selectKeep) editor.target = null;
12929
13000
  }
12930
13001
  }
12931
13002
  checkAndSelect(e) {
@@ -12940,7 +13011,7 @@ class EditSelect extends Group {
12940
13011
  editor.target = find;
12941
13012
  }
12942
13013
  } else if (this.allow(e.target)) {
12943
- if (!this.isHoldMultipleSelectKey(e)) editor.target = null;
13014
+ if (!this.isHoldMultipleSelectKey(e) && !this.editor.mergedConfig.selectKeep) editor.target = null;
12944
13015
  }
12945
13016
  }
12946
13017
  }
@@ -13059,91 +13130,95 @@ const {toPoint: toPoint} = AroundHelper;
13059
13130
  const {within: within$3, sign: sign$1} = MathHelper;
13060
13131
 
13061
13132
  const EditDataHelper = {
13062
- getScaleData(target, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
13133
+ getScaleData(target, startBounds, direction, totalMoveOrScale, lockRatio, around, flipable, scaleMode) {
13063
13134
  let align, origin = {}, scaleX = 1, scaleY = 1;
13064
13135
  const {boxBounds: boxBounds, widthRange: widthRange, heightRange: heightRange, dragBounds: dragBounds, worldBoxBounds: worldBoxBounds} = target;
13065
13136
  const {width: width, height: height} = startBounds;
13066
- if (around) {
13067
- totalMove.x *= 2;
13068
- totalMove.y *= 2;
13069
- }
13070
13137
  const originChangedScaleX = target.scaleX / startBounds.scaleX;
13071
13138
  const originChangedScaleY = target.scaleY / startBounds.scaleY;
13072
13139
  const signX = sign$1(originChangedScaleX);
13073
13140
  const signY = sign$1(originChangedScaleY);
13074
13141
  const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
13075
13142
  const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height;
13076
- totalMove.x *= scaleMode ? originChangedScaleX : signX;
13077
- totalMove.y *= scaleMode ? originChangedScaleY : signY;
13078
- const topScale = (-totalMove.y + height) / height;
13079
- const rightScale = (totalMove.x + width) / width;
13080
- const bottomScale = (totalMove.y + height) / height;
13081
- const leftScale = (-totalMove.x + width) / width;
13082
- switch (direction) {
13083
- case top$1:
13084
- scaleY = topScale;
13085
- align = "bottom";
13086
- break;
13143
+ if (isNumber(totalMoveOrScale)) {
13144
+ scaleX = scaleY = Math.sqrt(totalMoveOrScale);
13145
+ } else {
13146
+ if (around) {
13147
+ totalMoveOrScale.x *= 2;
13148
+ totalMoveOrScale.y *= 2;
13149
+ }
13150
+ totalMoveOrScale.x *= scaleMode ? originChangedScaleX : signX;
13151
+ totalMoveOrScale.y *= scaleMode ? originChangedScaleY : signY;
13152
+ const topScale = (-totalMoveOrScale.y + height) / height;
13153
+ const rightScale = (totalMoveOrScale.x + width) / width;
13154
+ const bottomScale = (totalMoveOrScale.y + height) / height;
13155
+ const leftScale = (-totalMoveOrScale.x + width) / width;
13156
+ switch (direction) {
13157
+ case top$1:
13158
+ scaleY = topScale;
13159
+ align = "bottom";
13160
+ break;
13087
13161
 
13088
- case right$2:
13089
- scaleX = rightScale;
13090
- align = "left";
13091
- break;
13162
+ case right$2:
13163
+ scaleX = rightScale;
13164
+ align = "left";
13165
+ break;
13092
13166
 
13093
- case bottom$1:
13094
- scaleY = bottomScale;
13095
- align = "top";
13096
- break;
13167
+ case bottom$1:
13168
+ scaleY = bottomScale;
13169
+ align = "top";
13170
+ break;
13097
13171
 
13098
- case left$2:
13099
- scaleX = leftScale;
13100
- align = "right";
13101
- break;
13172
+ case left$2:
13173
+ scaleX = leftScale;
13174
+ align = "right";
13175
+ break;
13102
13176
 
13103
- case topLeft$1:
13104
- scaleY = topScale;
13105
- scaleX = leftScale;
13106
- align = "bottom-right";
13107
- break;
13177
+ case topLeft$1:
13178
+ scaleY = topScale;
13179
+ scaleX = leftScale;
13180
+ align = "bottom-right";
13181
+ break;
13108
13182
 
13109
- case topRight$1:
13110
- scaleY = topScale;
13111
- scaleX = rightScale;
13112
- align = "bottom-left";
13113
- break;
13183
+ case topRight$1:
13184
+ scaleY = topScale;
13185
+ scaleX = rightScale;
13186
+ align = "bottom-left";
13187
+ break;
13114
13188
 
13115
- case bottomRight:
13116
- scaleY = bottomScale;
13117
- scaleX = rightScale;
13118
- align = "top-left";
13119
- break;
13189
+ case bottomRight:
13190
+ scaleY = bottomScale;
13191
+ scaleX = rightScale;
13192
+ align = "top-left";
13193
+ break;
13120
13194
 
13121
- case bottomLeft:
13122
- scaleY = bottomScale;
13123
- scaleX = leftScale;
13124
- align = "top-right";
13125
- }
13126
- if (lockRatio) {
13127
- if (lockRatio === "corner" && direction % 2) {
13128
- lockRatio = false;
13129
- } else {
13130
- let scale;
13131
- switch (direction) {
13132
- case top$1:
13133
- case bottom$1:
13134
- scale = scaleY;
13135
- break;
13195
+ case bottomLeft:
13196
+ scaleY = bottomScale;
13197
+ scaleX = leftScale;
13198
+ align = "top-right";
13199
+ }
13200
+ if (lockRatio) {
13201
+ if (lockRatio === "corner" && direction % 2) {
13202
+ lockRatio = false;
13203
+ } else {
13204
+ let scale;
13205
+ switch (direction) {
13206
+ case top$1:
13207
+ case bottom$1:
13208
+ scale = scaleY;
13209
+ break;
13136
13210
 
13137
- case left$2:
13138
- case right$2:
13139
- scale = scaleX;
13140
- break;
13211
+ case left$2:
13212
+ case right$2:
13213
+ scale = scaleX;
13214
+ break;
13141
13215
 
13142
- default:
13143
- scale = Math.sqrt(Math.abs(scaleX * scaleY));
13216
+ default:
13217
+ scale = Math.sqrt(Math.abs(scaleX * scaleY));
13218
+ }
13219
+ scaleX = scaleX < 0 ? -scale : scale;
13220
+ scaleY = scaleY < 0 ? -scale : scale;
13144
13221
  }
13145
- scaleX = scaleX < 0 ? -scale : scale;
13146
- scaleY = scaleY < 0 ? -scale : scale;
13147
13222
  }
13148
13223
  }
13149
13224
  const useScaleX = scaleX !== 1, useScaleY = scaleY !== 1;
@@ -13431,6 +13506,9 @@ class EditBox extends Group {
13431
13506
  const {moveable: moveable, resizeable: resizeable, rotateable: rotateable} = this.mergeConfig;
13432
13507
  return isString(moveable) || isString(resizeable) || isString(rotateable);
13433
13508
  }
13509
+ get canDragLimitAnimate() {
13510
+ return this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds;
13511
+ }
13434
13512
  constructor(editor) {
13435
13513
  super();
13436
13514
  this.view = new Group;
@@ -13664,10 +13742,9 @@ class EditBox extends Group {
13664
13742
  onDragStart(e) {
13665
13743
  this.dragging = true;
13666
13744
  const point = this.dragPoint = e.current, {pointType: pointType} = point;
13667
- const {editor: editor, dragStartData: dragStartData} = this, {target: target} = this, {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable, hideOnMove: hideOnMove} = this.mergeConfig;
13745
+ const {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = this.mergeConfig;
13668
13746
  if (pointType === "move") {
13669
13747
  moveable && (this.moving = true);
13670
- editor.opacity = hideOnMove ? 0 : 1;
13671
13748
  } else {
13672
13749
  if (pointType.includes("rotate") || this.isHoldRotateKey(e) || !resizeable) {
13673
13750
  rotateable && (this.rotating = true);
@@ -13676,23 +13753,7 @@ class EditBox extends Group {
13676
13753
  } else if (pointType === "resize") resizeable && (this.resizing = true);
13677
13754
  if (pointType === "skew") skewable && (this.skewing = true);
13678
13755
  }
13679
- dragStartData.x = e.x;
13680
- dragStartData.y = e.y;
13681
- dragStartData.point = {
13682
- x: target.x,
13683
- y: target.y
13684
- };
13685
- dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
13686
- dragStartData.rotation = target.rotation;
13687
- if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = editor.leafList.keys;
13688
- }
13689
- onDragEnd(e) {
13690
- if (this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds) this.transformTool.onMove(e);
13691
- this.dragPoint = null;
13692
- this.resetDoing();
13693
- const {pointType: pointType} = e.current;
13694
- if (pointType === "move") this.editor.opacity = 1;
13695
- if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = null;
13756
+ this.onTransformStart(e);
13696
13757
  }
13697
13758
  onDrag(e) {
13698
13759
  const {transformTool: transformTool, moving: moving, resizing: resizing, rotating: rotating, skewing: skewing} = this;
@@ -13707,37 +13768,59 @@ class EditBox extends Group {
13707
13768
  }
13708
13769
  updatePointCursor(this, e);
13709
13770
  }
13710
- resetDoing() {
13711
- if (this.canUse) this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
13771
+ onDragEnd(e) {
13772
+ this.onTransformEnd(e);
13773
+ this.dragPoint = null;
13774
+ }
13775
+ onTransformStart(e) {
13776
+ if (this.canUse) {
13777
+ if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
13778
+ if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
13779
+ const {dragStartData: dragStartData, target: target} = this;
13780
+ dragStartData.x = e.x;
13781
+ dragStartData.y = e.y;
13782
+ dragStartData.totalOffset = getPointData();
13783
+ dragStartData.point = {
13784
+ x: target.x,
13785
+ y: target.y
13786
+ };
13787
+ dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
13788
+ dragStartData.rotation = target.rotation;
13789
+ }
13790
+ }
13791
+ onTransformEnd(e) {
13792
+ if (this.canUse) {
13793
+ if (this.canDragLimitAnimate && (e instanceof DragEvent || e instanceof MoveEvent)) this.transformTool.onMove(e);
13794
+ if (this.resizing) ResizeEvent.resizingKeys = null;
13795
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
13796
+ this.editor.opacity = 1;
13797
+ this.update();
13798
+ }
13712
13799
  }
13713
13800
  onMove(e) {
13714
13801
  if (this.canGesture && e.moveType !== "drag") {
13715
13802
  e.stop();
13716
- if (isString(this.mergeConfig.moveable)) {
13803
+ if (isString(this.mergedConfig.moveable)) {
13717
13804
  this.gesturing = this.moving = true;
13718
- this.transformTool.onMove(e);
13805
+ e.type === MoveEvent.START ? this.onTransformStart(e) : this.transformTool.onMove(e);
13719
13806
  }
13720
13807
  }
13721
13808
  }
13722
- onMoveEnd(e) {
13723
- if (this.moving) this.transformTool.onMove(e);
13724
- this.resetDoing();
13725
- }
13726
13809
  onScale(e) {
13727
13810
  if (this.canGesture) {
13728
13811
  e.stop();
13729
- if (isString(this.mergeConfig.resizeable)) {
13812
+ if (isString(this.mergedConfig.resizeable)) {
13730
13813
  this.gesturing = this.resizing = true;
13731
- this.transformTool.onScale(e);
13814
+ e.type === ZoomEvent.START ? this.onTransformStart(e) : this.transformTool.onScale(e);
13732
13815
  }
13733
13816
  }
13734
13817
  }
13735
13818
  onRotate(e) {
13736
13819
  if (this.canGesture) {
13737
13820
  e.stop();
13738
- if (isString(this.mergeConfig.rotateable)) {
13821
+ if (isString(this.mergedConfig.rotateable)) {
13739
13822
  this.gesturing = this.rotating = true;
13740
- this.transformTool.onRotate(e);
13823
+ e.type === RotateEvent.START ? this.onTransformStart(e) : this.transformTool.onRotate(e);
13741
13824
  }
13742
13825
  }
13743
13826
  }
@@ -13750,8 +13833,7 @@ class EditBox extends Group {
13750
13833
  updatePointCursor(this, e);
13751
13834
  }
13752
13835
  onArrow(e) {
13753
- const {editor: editor, transformTool: transformTool} = this;
13754
- if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
13836
+ if (this.canUse && this.mergeConfig.keyEvent) {
13755
13837
  let x = 0, y = 0;
13756
13838
  const distance = e.shiftKey ? 10 : 1;
13757
13839
  switch (e.code) {
@@ -13770,7 +13852,7 @@ class EditBox extends Group {
13770
13852
  case "ArrowRight":
13771
13853
  x = distance;
13772
13854
  }
13773
- if (x || y) transformTool.move(x, y);
13855
+ if (x || y) this.transformTool.move(x, y);
13774
13856
  }
13775
13857
  }
13776
13858
  onDoubleTap(e) {
@@ -13811,7 +13893,7 @@ class EditBox extends Group {
13811
13893
  const {rect: rect, editor: editor, __eventIds: events} = this;
13812
13894
  events.push(rect.on_([ [ PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
13813
13895
  this.waitLeafer(() => {
13814
- events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ MoveEvent.END, this.onMoveEnd, this ], [ ZoomEvent.END, this.resetDoing, this ], [ RotateEvent.END, this.resetDoing, this ] ]));
13896
+ events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ [ MoveEvent.START, MoveEvent.BEFORE_MOVE ], this.onMove, this, true ], [ [ ZoomEvent.START, ZoomEvent.BEFORE_ZOOM ], this.onScale, this, true ], [ [ RotateEvent.START, RotateEvent.BEFORE_ROTATE ], this.onRotate, this, true ], [ [ MoveEvent.END, ZoomEvent.END, RotateEvent.END ], this.onTransformEnd, this ] ]));
13815
13897
  });
13816
13898
  }
13817
13899
  __removeListenEvents() {
@@ -14209,56 +14291,61 @@ class TransformTool {
14209
14291
  const isMoveEnd = e.type === MoveEvent.END || e.type === DragEvent.END;
14210
14292
  const axisDrag = isString(target.draggable);
14211
14293
  const checkLimitMove = !dragLimitAnimate || isMoveEnd || axisDrag;
14294
+ const total = {
14295
+ x: e.totalX,
14296
+ y: e.totalY
14297
+ };
14212
14298
  if (e instanceof MoveEvent) {
14213
- move = e.getLocalMove(target);
14214
- if (checkLimitMove) DragEvent.limitMove(target, move);
14215
- } else {
14216
- const total = {
14217
- x: e.totalX,
14218
- y: e.totalY
14219
- };
14220
- if (e.shiftKey) {
14221
- if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
14222
- }
14223
- move = DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
14299
+ PointHelper.move(total, target.getWorldPointByLocal(dragStartData.totalOffset, null, true));
14300
+ }
14301
+ if (e.shiftKey) {
14302
+ if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
14224
14303
  }
14304
+ move = DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
14225
14305
  if (move.x || move.y) {
14226
14306
  if (dragLimitAnimate && !axisDrag && isMoveEnd) LeafHelper.animateMove(this, move, isNumber(dragLimitAnimate) ? dragLimitAnimate : .3); else this.move(move);
14227
14307
  }
14228
14308
  }
14229
14309
  onScale(e) {
14230
14310
  const {target: target, mergeConfig: mergeConfig, single: single, dragStartData: dragStartData} = this.editBox;
14231
- let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig;
14311
+ let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig, totalMove;
14232
14312
  if (e instanceof ZoomEvent) {
14233
- this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
14313
+ around = target.getBoxPoint(e);
14314
+ totalMove = e.totalScale;
14234
14315
  } else {
14235
- const {direction: direction} = e.current;
14236
- if (e.shiftKey || target.lockRatio) lockRatio = true;
14237
- const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, e.getInnerTotal(target), lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale");
14238
- if (this.editTool && this.editTool.onScaleWithDrag) {
14239
- data.drag = e;
14240
- this.scaleWithDrag(data);
14241
- } else {
14242
- this.scaleOf(data.origin, data.scaleX, data.scaleY);
14243
- }
14316
+ totalMove = e.getInnerTotal(target);
14317
+ }
14318
+ const {direction: direction} = e.current;
14319
+ if (e.shiftKey || target.lockRatio) lockRatio = true;
14320
+ const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, totalMove, lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale");
14321
+ const targetX = target.x, targetY = target.y;
14322
+ if (e instanceof DragEvent && this.editTool && this.editTool.onScaleWithDrag) {
14323
+ data.drag = e;
14324
+ this.scaleWithDrag(data);
14325
+ } else {
14326
+ this.scaleOf(data.origin, data.scaleX, data.scaleY);
14244
14327
  }
14328
+ PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
14245
14329
  }
14246
14330
  onRotate(e) {
14247
14331
  const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData} = this.editBox;
14248
- const {around: around, rotateAround: rotateAround, rotateGap: rotateGap} = mergeConfig;
14332
+ const {around: around, rotateAround: rotateAround, rotateGap: rotateGap, diagonalRotateKey: diagonalRotateKey} = mergeConfig;
14249
14333
  const {direction: direction} = e.current;
14250
14334
  let origin, rotation;
14251
14335
  if (e instanceof RotateEvent) {
14252
14336
  rotation = e.rotation;
14253
14337
  origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
14254
14338
  } else {
14255
- const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : rotateAround || target.around || target.origin || around || "center");
14339
+ const isDiagonalRotate = diagonalRotateKey ? e.isHoldKeys(diagonalRotateKey) : e.shiftKey;
14340
+ const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, isDiagonalRotate ? null : rotateAround || target.around || target.origin || around || "center");
14256
14341
  rotation = dragStartData.rotation + data.rotation - target.rotation;
14257
14342
  origin = data.origin;
14258
14343
  }
14259
14344
  rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
14260
14345
  if (!rotation) return;
14346
+ const targetX = target.x, targetY = target.y;
14261
14347
  this.rotateOf(origin, rotation);
14348
+ PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
14262
14349
  }
14263
14350
  onSkew(e) {
14264
14351
  const {target: target, mergeConfig: mergeConfig} = this.editBox;
@@ -15001,7 +15088,7 @@ let LineEditTool = class LineEditTool extends EditTool {
15001
15088
 
15002
15089
  LineEditTool = __decorate([ registerEditTool() ], LineEditTool);
15003
15090
 
15004
- 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;
15091
+ 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;
15005
15092
 
15006
15093
  const PathScaler = {
15007
15094
  scale(data, scaleX, scaleY) {
@@ -15011,7 +15098,7 @@ const PathScaler = {
15011
15098
  while (i < len) {
15012
15099
  command = data[i];
15013
15100
  switch (command) {
15014
- case M$3:
15101
+ case M$4:
15015
15102
  case L$3:
15016
15103
  scalePoints(data, scaleX, scaleY, i, 1);
15017
15104
  i += 3;
@@ -15465,28 +15552,24 @@ let TextEditor = class TextEditor extends InnerEditor {
15465
15552
  const data = text.__;
15466
15553
  if (data.__autoWidth) {
15467
15554
  width += 20;
15468
- if (data.autoSizeAlign) {
15469
- switch (data.textAlign) {
15470
- case "center":
15471
- offsetX = -width / 2;
15472
- break;
15555
+ switch (data.textAlign) {
15556
+ case "center":
15557
+ offsetX = data.autoSizeAlign ? -width / 2 : -10;
15558
+ break;
15473
15559
 
15474
- case "right":
15475
- offsetX = -width;
15476
- }
15560
+ case "right":
15561
+ offsetX = data.autoSizeAlign ? -width : -20;
15477
15562
  }
15478
15563
  }
15479
15564
  if (data.__autoHeight) {
15480
15565
  height += 20;
15481
- if (data.autoSizeAlign) {
15482
- switch (data.verticalAlign) {
15483
- case "middle":
15484
- offsetY = -height / 2;
15485
- break;
15566
+ switch (data.verticalAlign) {
15567
+ case "middle":
15568
+ offsetY = data.autoSizeAlign ? -height / 2 : -10;
15569
+ break;
15486
15570
 
15487
- case "bottom":
15488
- offsetY = -height;
15489
- }
15571
+ case "bottom":
15572
+ offsetY = data.autoSizeAlign ? -height : -20;
15490
15573
  }
15491
15574
  }
15492
15575
  const {x: x, y: y} = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
@@ -15605,6 +15688,13 @@ register("design", design);
15605
15688
  register("document", document$1);
15606
15689
 
15607
15690
  const MultiTouchHelper = {
15691
+ state: {
15692
+ type: "none",
15693
+ typeCount: 0,
15694
+ startTime: 0,
15695
+ totalData: null,
15696
+ center: {}
15697
+ },
15608
15698
  getData(list) {
15609
15699
  const a = list[0], b = list[1];
15610
15700
  const lastCenter = PointHelper.getCenter(a.from, b.from);
@@ -15623,9 +15713,53 @@ const MultiTouchHelper = {
15623
15713
  rotation: rotation,
15624
15714
  center: center
15625
15715
  };
15716
+ },
15717
+ getType(data, config) {
15718
+ const moveScore = Math.hypot(data.move.x, data.move.y) / (config.move || 5);
15719
+ const scaleScore = Math.abs(data.scale - 1) / (config.scale || .03);
15720
+ const rotateScore = Math.abs(data.rotation) / (config.rotation || 2);
15721
+ if (moveScore < 1 && scaleScore < 1 && rotateScore < 1) return "none";
15722
+ if (moveScore >= scaleScore && moveScore >= rotateScore) return "move";
15723
+ if (scaleScore >= rotateScore) return "zoom";
15724
+ return "rotate";
15725
+ },
15726
+ detect(data, config) {
15727
+ const {state: state} = M$3;
15728
+ const type = M$3.getType(data, config);
15729
+ if (!state.totalData) {
15730
+ state.startTime = Date.now();
15731
+ state.center = data.center;
15732
+ }
15733
+ M$3.add(data, state.totalData);
15734
+ state.totalData = data;
15735
+ if (type === state.type) {
15736
+ state.typeCount++;
15737
+ if (state.typeCount >= (config.count || 3) && type !== "none") return type;
15738
+ } else {
15739
+ state.type = type;
15740
+ state.typeCount = 1;
15741
+ }
15742
+ if (Date.now() - state.startTime >= (config.time || 160)) return M$3.getType(state.totalData, config);
15743
+ return "none";
15744
+ },
15745
+ add(data, add) {
15746
+ if (!add) return;
15747
+ PointHelper.move(data.move, add.move);
15748
+ data.scale *= add.scale;
15749
+ data.rotation += add.rotation;
15750
+ data.center = add.center;
15751
+ },
15752
+ reset() {
15753
+ const {state: state} = M$3;
15754
+ state.type = "none";
15755
+ state.typeCount = 0;
15756
+ state.startTime = 0;
15757
+ state.totalData = null;
15626
15758
  }
15627
15759
  };
15628
15760
 
15761
+ const M$3 = MultiTouchHelper;
15762
+
15629
15763
  const {abs: abs$2, max: max} = Math, {sign: sign, within: within$2} = MathHelper;
15630
15764
 
15631
15765
  const WheelEventHelper = {
@@ -15665,9 +15799,20 @@ const WheelEventHelper = {
15665
15799
  }
15666
15800
  };
15667
15801
 
15802
+ let totalX, totalY, totalScale, totalRotation;
15803
+
15668
15804
  class Transformer {
15669
15805
  get transforming() {
15670
- return !!(this.moveData || this.zoomData || this.rotateData);
15806
+ return this.moving || this.zooming || this.rotating;
15807
+ }
15808
+ get moving() {
15809
+ return !!this.moveData;
15810
+ }
15811
+ get zooming() {
15812
+ return !!this.zoomData;
15813
+ }
15814
+ get rotating() {
15815
+ return !!this.rotateData;
15671
15816
  }
15672
15817
  constructor(interaction) {
15673
15818
  this.interaction = interaction;
@@ -15677,13 +15822,18 @@ class Transformer {
15677
15822
  if (!data.moveType) data.moveType = "move";
15678
15823
  if (!this.moveData) {
15679
15824
  this.setPath(data);
15825
+ totalX = 0, totalY = 0;
15680
15826
  this.moveData = Object.assign(Object.assign({}, data), {
15681
15827
  moveX: 0,
15682
- moveY: 0
15828
+ moveY: 0,
15829
+ totalX: totalX,
15830
+ totalY: totalY
15683
15831
  });
15684
15832
  interaction.emit(MoveEvent.START, this.moveData);
15685
15833
  }
15686
15834
  data.path = this.moveData.path;
15835
+ data.totalX = totalX = totalX + data.moveX;
15836
+ data.totalY = totalY = totalY + data.moveY;
15687
15837
  interaction.emit(MoveEvent.BEFORE_MOVE, data);
15688
15838
  interaction.emit(MoveEvent.MOVE, data);
15689
15839
  this.transformEndWait();
@@ -15692,12 +15842,15 @@ class Transformer {
15692
15842
  const {interaction: interaction} = this;
15693
15843
  if (!this.zoomData) {
15694
15844
  this.setPath(data);
15845
+ totalScale = 1;
15695
15846
  this.zoomData = Object.assign(Object.assign({}, data), {
15696
- scale: 1
15847
+ scale: 1,
15848
+ totalScale: totalScale
15697
15849
  });
15698
15850
  interaction.emit(ZoomEvent.START, this.zoomData);
15699
15851
  }
15700
15852
  data.path = this.zoomData.path;
15853
+ data.totalScale = totalScale = totalScale * data.scale;
15701
15854
  interaction.emit(ZoomEvent.BEFORE_ZOOM, data);
15702
15855
  interaction.emit(ZoomEvent.ZOOM, data);
15703
15856
  this.transformEndWait();
@@ -15706,12 +15859,15 @@ class Transformer {
15706
15859
  const {interaction: interaction} = this;
15707
15860
  if (!this.rotateData) {
15708
15861
  this.setPath(data);
15862
+ totalRotation = 0;
15709
15863
  this.rotateData = Object.assign(Object.assign({}, data), {
15710
- rotation: 0
15864
+ rotation: 0,
15865
+ totalRotation: totalRotation
15711
15866
  });
15712
15867
  interaction.emit(RotateEvent.START, this.rotateData);
15713
15868
  }
15714
15869
  data.path = this.rotateData.path;
15870
+ data.totalRotation = totalRotation = totalRotation + data.rotation;
15715
15871
  interaction.emit(RotateEvent.BEFORE_ROTATE, data);
15716
15872
  interaction.emit(RotateEvent.ROTATE, data);
15717
15873
  this.transformEndWait();
@@ -15730,9 +15886,16 @@ class Transformer {
15730
15886
  }
15731
15887
  transformEnd() {
15732
15888
  const {interaction: interaction, moveData: moveData, zoomData: zoomData, rotateData: rotateData} = this;
15733
- if (moveData) interaction.emit(MoveEvent.END, moveData);
15734
- if (zoomData) interaction.emit(ZoomEvent.END, zoomData);
15735
- if (rotateData) interaction.emit(RotateEvent.END, rotateData);
15889
+ if (moveData) interaction.emit(MoveEvent.END, Object.assign(Object.assign({}, moveData), {
15890
+ totalX: totalX,
15891
+ totalY: totalY
15892
+ }));
15893
+ if (zoomData) interaction.emit(ZoomEvent.END, Object.assign(Object.assign({}, zoomData), {
15894
+ totalScale: totalScale
15895
+ }));
15896
+ if (rotateData) interaction.emit(RotateEvent.END, Object.assign(Object.assign({}, rotateData), {
15897
+ totalRotation: totalRotation
15898
+ }));
15736
15899
  this.reset();
15737
15900
  }
15738
15901
  reset() {
@@ -15830,14 +15993,39 @@ interaction.wheel = function(data) {
15830
15993
  };
15831
15994
 
15832
15995
  interaction.multiTouch = function(data, list) {
15833
- if (this.config.multiTouch.disabled) return;
15834
- const {move: move, rotation: rotation, scale: scale, center: center} = MultiTouchHelper.getData(list);
15835
- Object.assign(data, center);
15836
- data.multiTouch = true;
15996
+ const {disabled: disabled, singleGesture: singleGesture} = this.config.multiTouch;
15997
+ if (disabled) return;
15837
15998
  this.pointerWaitCancel();
15838
- this.rotate(getRotateEventData(rotation, data));
15839
- this.zoom(getZoomEventData(scale, data));
15840
- this.move(getMoveEventData(move, data));
15999
+ let gestureData = MultiTouchHelper.getData(list);
16000
+ let {moving: moving, zooming: zooming, rotating: rotating} = this.transformer;
16001
+ if (singleGesture) {
16002
+ if (!this.transformer.transforming) {
16003
+ const type = MultiTouchHelper.detect(gestureData, isObject(singleGesture) ? singleGesture : {});
16004
+ switch (type) {
16005
+ case "move":
16006
+ moving = true;
16007
+ break;
16008
+
16009
+ case "zoom":
16010
+ zooming = true;
16011
+ break;
16012
+
16013
+ case "rotate":
16014
+ rotating = true;
16015
+ break;
16016
+
16017
+ default:
16018
+ return;
16019
+ }
16020
+ MultiTouchHelper.reset();
16021
+ }
16022
+ if (!moving) gestureData.center = MultiTouchHelper.state.center;
16023
+ } else moving = zooming = rotating = true;
16024
+ Object.assign(data, gestureData.center);
16025
+ data.multiTouch = true;
16026
+ if (rotating) this.rotate(getRotateEventData(gestureData.rotation, data));
16027
+ if (zooming) this.zoom(getZoomEventData(gestureData.scale, data));
16028
+ if (moving) this.move(getMoveEventData(gestureData.move, data));
15841
16029
  };
15842
16030
 
15843
16031
  const dragger = Dragger.prototype;
@@ -18855,6 +19043,18 @@ UI.addAttr("placeholderStyle", undefined, stateStyleType);
18855
19043
 
18856
19044
  UI.addAttr("button", false, dataType);
18857
19045
 
19046
+ ui$1.set = function(data, transition) {
19047
+ if (data) {
19048
+ if (transition) {
19049
+ if (transition === "temp") {
19050
+ this.lockNormalStyle = true;
19051
+ Object.assign(this, data);
19052
+ this.lockNormalStyle = false;
19053
+ } else this.animate(data, transition);
19054
+ } else Object.assign(this, data);
19055
+ }
19056
+ };
19057
+
18858
19058
  ui$1.focus = function(value = true) {
18859
19059
  this.waitLeafer(() => {
18860
19060
  let {focusData: focusData} = this.app.interaction;
@@ -19451,4 +19651,4 @@ Plugin.add("bright");
19451
19651
 
19452
19652
  UI.addAttr("bright", false, dimType);
19453
19653
 
19454
- 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, 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, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, 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, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, 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, 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$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
19654
+ 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, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, 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, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, 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, 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$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };