@leafer-ui/worker 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -51,6 +51,8 @@ var LeaferUI = (function (exports) {
51
51
  const { round, pow: pow$1, PI: PI$4 } = Math;
52
52
  const MathHelper = {
53
53
  within(value, min, max) {
54
+ if (typeof min === 'object')
55
+ max = min.max, min = min.min;
54
56
  if (min !== undefined && value < min)
55
57
  value = min;
56
58
  if (max !== undefined && value > max)
@@ -112,6 +114,19 @@ var LeaferUI = (function (exports) {
112
114
  const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
113
115
  num = round(num * a) / a;
114
116
  return num === -0 ? 0 : num;
117
+ },
118
+ getScaleData(scale, size, originSize, scaleData) {
119
+ if (!scaleData)
120
+ scaleData = {};
121
+ if (size) {
122
+ scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
123
+ scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
124
+ }
125
+ else if (scale) {
126
+ scaleData.scaleX = typeof scale === 'number' ? scale : scale.x;
127
+ scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
128
+ }
129
+ return scaleData;
115
130
  }
116
131
  };
117
132
  const OneRadian = PI$4 / 180;
@@ -153,10 +168,10 @@ var LeaferUI = (function (exports) {
153
168
  t.e += x;
154
169
  t.f += y;
155
170
  },
156
- translateInner(t, x, y, isMoveOrigin) {
171
+ translateInner(t, x, y, hasOrigin) {
157
172
  t.e += t.a * x + t.c * y;
158
173
  t.f += t.b * x + t.d * y;
159
- if (isMoveOrigin)
174
+ if (hasOrigin)
160
175
  t.e -= x, t.f -= y;
161
176
  },
162
177
  scale(t, scaleX, scaleY = scaleX) {
@@ -315,7 +330,7 @@ var LeaferUI = (function (exports) {
315
330
  to.y -= (f * a - e * b) * s;
316
331
  }
317
332
  },
318
- setLayout(t, layout, origin, bcChanged) {
333
+ setLayout(t, layout, origin, around, bcChanged) {
319
334
  const { x, y, scaleX, scaleY } = layout;
320
335
  if (bcChanged === undefined)
321
336
  bcChanged = layout.rotation || layout.skewX || layout.skewY;
@@ -347,10 +362,10 @@ var LeaferUI = (function (exports) {
347
362
  }
348
363
  t.e = x;
349
364
  t.f = y;
350
- if (origin)
351
- M$6.translateInner(t, -origin.x, -origin.y, true);
365
+ if (origin = origin || around)
366
+ M$6.translateInner(t, -origin.x, -origin.y, !around);
352
367
  },
353
- getLayout(t, origin, firstSkewY) {
368
+ getLayout(t, origin, around, firstSkewY) {
354
369
  const { a, b, c, d, e, f } = t;
355
370
  let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
356
371
  if (b || c) {
@@ -379,9 +394,11 @@ var LeaferUI = (function (exports) {
379
394
  scaleY = d;
380
395
  rotation = skewX = skewY = 0;
381
396
  }
382
- if (origin) {
397
+ if (origin = around || origin) {
383
398
  x += origin.x * a + origin.y * c;
384
399
  y += origin.x * b + origin.y * d;
400
+ if (!around)
401
+ x -= origin.x, y -= origin.y;
385
402
  }
386
403
  return { x, y, scaleX, scaleY, rotation, skewX, skewY };
387
404
  },
@@ -408,7 +425,7 @@ var LeaferUI = (function (exports) {
408
425
  };
409
426
  const M$6 = MatrixHelper;
410
427
 
411
- const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$2 } = MatrixHelper;
428
+ const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
412
429
  const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
413
430
  const PointHelper = {
414
431
  defaultPoint: getPointData(),
@@ -464,7 +481,7 @@ var LeaferUI = (function (exports) {
464
481
  tempToOuterOf(t, matrix) {
465
482
  const { tempPoint: temp } = P$5;
466
483
  copy$b(temp, t);
467
- toOuterPoint$2(matrix, temp, temp);
484
+ toOuterPoint$3(matrix, temp, temp);
468
485
  return temp;
469
486
  },
470
487
  tempToInnerRadiusPointOf(t, matrix) {
@@ -483,7 +500,7 @@ var LeaferUI = (function (exports) {
483
500
  toInnerPoint$2(matrix, t, to);
484
501
  },
485
502
  toOuterOf(t, matrix, to) {
486
- toOuterPoint$2(matrix, t, to);
503
+ toOuterPoint$3(matrix, t, to);
487
504
  },
488
505
  getCenter(t, to) {
489
506
  return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
@@ -709,12 +726,12 @@ var LeaferUI = (function (exports) {
709
726
  toInnerPoint(outer, to, distance) {
710
727
  MatrixHelper.toInnerPoint(this, outer, to, distance);
711
728
  }
712
- setLayout(data, origin) {
713
- MatrixHelper.setLayout(this, data, origin);
729
+ setLayout(data, origin, around) {
730
+ MatrixHelper.setLayout(this, data, origin, around);
714
731
  return this;
715
732
  }
716
- getLayout(origin, firstSkewY) {
717
- return MatrixHelper.getLayout(this, origin, firstSkewY);
733
+ getLayout(origin, around, firstSkewY) {
734
+ return MatrixHelper.getLayout(this, origin, around, firstSkewY);
718
735
  }
719
736
  withScale(scaleX, scaleY) {
720
737
  return MatrixHelper.withScale(this, scaleX, scaleY);
@@ -763,7 +780,7 @@ var LeaferUI = (function (exports) {
763
780
  const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
764
781
 
765
782
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
766
- const { toOuterPoint: toOuterPoint$1 } = MatrixHelper;
783
+ const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
767
784
  const { float, fourNumber } = MathHelper;
768
785
  const { floor, ceil: ceil$2 } = Math;
769
786
  let right$1, bottom$1, boundsRight, boundsBottom;
@@ -783,17 +800,24 @@ var LeaferUI = (function (exports) {
783
800
  t.width = bounds.width;
784
801
  t.height = bounds.height;
785
802
  },
786
- copyAndSpread(t, bounds, spread, isShrink) {
803
+ copyAndSpread(t, bounds, spread, isShrink, side) {
804
+ const { x, y, width, height } = bounds;
787
805
  if (spread instanceof Array) {
788
806
  const four = fourNumber(spread);
789
807
  isShrink
790
- ? B.set(t, bounds.x + four[3], bounds.y + four[0], bounds.width - four[1] - four[3], bounds.height - four[2] - four[0])
791
- : B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0]);
808
+ ? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
809
+ : B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
792
810
  }
793
811
  else {
794
812
  if (isShrink)
795
813
  spread = -spread;
796
- B.set(t, bounds.x - spread, bounds.y - spread, bounds.width + spread * 2, bounds.height + spread * 2);
814
+ B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
815
+ }
816
+ if (side) {
817
+ if (side === 'width')
818
+ t.y = y, t.height = height;
819
+ else
820
+ t.x = x, t.width = width;
797
821
  }
798
822
  },
799
823
  minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
@@ -870,16 +894,16 @@ var LeaferUI = (function (exports) {
870
894
  else {
871
895
  point.x = t.x;
872
896
  point.y = t.y;
873
- toOuterPoint$1(matrix, point, toPoint$5);
897
+ toOuterPoint$2(matrix, point, toPoint$5);
874
898
  setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
875
899
  point.x = t.x + t.width;
876
- toOuterPoint$1(matrix, point, toPoint$5);
900
+ toOuterPoint$2(matrix, point, toPoint$5);
877
901
  addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
878
902
  point.y = t.y + t.height;
879
- toOuterPoint$1(matrix, point, toPoint$5);
903
+ toOuterPoint$2(matrix, point, toPoint$5);
880
904
  addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
881
905
  point.x = t.x;
882
- toOuterPoint$1(matrix, point, toPoint$5);
906
+ toOuterPoint$2(matrix, point, toPoint$5);
883
907
  addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
884
908
  toBounds$4(tempPointBounds$1, to);
885
909
  }
@@ -893,16 +917,16 @@ var LeaferUI = (function (exports) {
893
917
  const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
894
918
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
895
919
  },
896
- getSpread(t, spread) {
920
+ getSpread(t, spread, side) {
897
921
  const n = {};
898
- B.copyAndSpread(n, t, spread);
922
+ B.copyAndSpread(n, t, spread, false, side);
899
923
  return n;
900
924
  },
901
- spread(t, spread) {
902
- B.copyAndSpread(t, t, spread);
925
+ spread(t, spread, side) {
926
+ B.copyAndSpread(t, t, spread, false, side);
903
927
  },
904
- shrink(t, shrink) {
905
- B.copyAndSpread(t, t, shrink, true);
928
+ shrink(t, shrink, side) {
929
+ B.copyAndSpread(t, t, shrink, true, side);
906
930
  },
907
931
  ceil(t) {
908
932
  const { x, y } = t;
@@ -1085,12 +1109,12 @@ var LeaferUI = (function (exports) {
1085
1109
  getFitMatrix(put, baseScale) {
1086
1110
  return BoundsHelper.getFitMatrix(this, put, baseScale);
1087
1111
  }
1088
- spread(fourNumber) {
1089
- BoundsHelper.spread(this, fourNumber);
1112
+ spread(fourNumber, side) {
1113
+ BoundsHelper.spread(this, fourNumber, side);
1090
1114
  return this;
1091
1115
  }
1092
- shrink(fourNumber) {
1093
- BoundsHelper.shrink(this, fourNumber);
1116
+ shrink(fourNumber, side) {
1117
+ BoundsHelper.shrink(this, fourNumber, side);
1094
1118
  return this;
1095
1119
  }
1096
1120
  ceil() {
@@ -2002,7 +2026,7 @@ var LeaferUI = (function (exports) {
2002
2026
  DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
2003
2027
  this.size.pixelRatio || (this.size.pixelRatio = 1);
2004
2028
  this.bounds = new Bounds(0, 0, this.width, this.height);
2005
- if (!this.unreal) {
2029
+ if (this.context && !this.unreal) {
2006
2030
  this.updateViewSize();
2007
2031
  this.smooth = this.config.smooth;
2008
2032
  }
@@ -2175,7 +2199,7 @@ var LeaferUI = (function (exports) {
2175
2199
  this.manager ? this.manager.recycle(this) : this.destroy();
2176
2200
  }
2177
2201
  }
2178
- updateRender() { }
2202
+ updateRender(_bounds) { }
2179
2203
  unrealCanvas() { }
2180
2204
  destroy() {
2181
2205
  this.manager = this.view = this.parentView = null;
@@ -2907,60 +2931,75 @@ var LeaferUI = (function (exports) {
2907
2931
  }
2908
2932
  beginPath() {
2909
2933
  beginPath(this.__path);
2934
+ this.paint();
2910
2935
  return this;
2911
2936
  }
2912
2937
  moveTo(x, y) {
2913
2938
  moveTo$4(this.__path, x, y);
2939
+ this.paint();
2914
2940
  return this;
2915
2941
  }
2916
2942
  lineTo(x, y) {
2917
2943
  lineTo$3(this.__path, x, y);
2944
+ this.paint();
2918
2945
  return this;
2919
2946
  }
2920
2947
  bezierCurveTo(x1, y1, x2, y2, x, y) {
2921
2948
  bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
2949
+ this.paint();
2922
2950
  return this;
2923
2951
  }
2924
2952
  quadraticCurveTo(x1, y1, x, y) {
2925
2953
  quadraticCurveTo(this.__path, x1, y1, x, y);
2954
+ this.paint();
2926
2955
  return this;
2927
2956
  }
2928
2957
  closePath() {
2929
2958
  closePath$3(this.__path);
2959
+ this.paint();
2930
2960
  return this;
2931
2961
  }
2932
2962
  rect(x, y, width, height) {
2933
2963
  rect$2(this.__path, x, y, width, height);
2964
+ this.paint();
2934
2965
  return this;
2935
2966
  }
2936
2967
  roundRect(x, y, width, height, cornerRadius) {
2937
2968
  roundRect$1(this.__path, x, y, width, height, cornerRadius);
2969
+ this.paint();
2938
2970
  return this;
2939
2971
  }
2940
2972
  ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2941
2973
  ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2974
+ this.paint();
2942
2975
  return this;
2943
2976
  }
2944
2977
  arc(x, y, radius, startAngle, endAngle, anticlockwise) {
2945
2978
  arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
2979
+ this.paint();
2946
2980
  return this;
2947
2981
  }
2948
2982
  arcTo(x1, y1, x2, y2, radius) {
2949
2983
  arcTo$2(this.__path, x1, y1, x2, y2, radius);
2984
+ this.paint();
2950
2985
  return this;
2951
2986
  }
2952
2987
  drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2953
2988
  drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2989
+ this.paint();
2954
2990
  return this;
2955
2991
  }
2956
2992
  drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
2957
2993
  drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
2994
+ this.paint();
2958
2995
  return this;
2959
2996
  }
2960
2997
  drawPoints(points, curve, close) {
2961
2998
  drawPoints$2(this.__path, points, curve, close);
2999
+ this.paint();
2962
3000
  return this;
2963
3001
  }
3002
+ paint() { }
2964
3003
  }
2965
3004
 
2966
3005
  const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
@@ -3982,7 +4021,7 @@ var LeaferUI = (function (exports) {
3982
4021
  };
3983
4022
  }
3984
4023
 
3985
- const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
4024
+ const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3986
4025
  const matrix$1 = {};
3987
4026
  const LeafHelper = {
3988
4027
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
@@ -4047,10 +4086,9 @@ var LeaferUI = (function (exports) {
4047
4086
  }
4048
4087
  return true;
4049
4088
  },
4050
- moveWorld(t, x, y = 0) {
4089
+ moveWorld(t, x, y = 0, isInnerPoint) {
4051
4090
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4052
- if (t.parent)
4053
- toInnerPoint$1(t.parent.worldTransform, local, local, true);
4091
+ isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
4054
4092
  L.moveLocal(t, local.x, local.y);
4055
4093
  },
4056
4094
  moveLocal(t, x, y = 0) {
@@ -4069,8 +4107,13 @@ var LeaferUI = (function (exports) {
4069
4107
  zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4070
4108
  copy$7(matrix$1, t.__localMatrix);
4071
4109
  scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
4072
- moveByMatrix(t, matrix$1);
4073
- t.scaleResize(scaleX, scaleY, resize !== true);
4110
+ if (t.origin || t.around) {
4111
+ L.setTransform(t, matrix$1, resize);
4112
+ }
4113
+ else {
4114
+ moveByMatrix(t, matrix$1);
4115
+ t.scaleResize(scaleX, scaleY, resize !== true);
4116
+ }
4074
4117
  },
4075
4118
  rotateOfWorld(t, origin, angle) {
4076
4119
  L.rotateOfLocal(t, getTempLocal(t, origin), angle);
@@ -4078,8 +4121,13 @@ var LeaferUI = (function (exports) {
4078
4121
  rotateOfLocal(t, origin, angle) {
4079
4122
  copy$7(matrix$1, t.__localMatrix);
4080
4123
  rotateOfOuter$2(matrix$1, origin, angle);
4081
- moveByMatrix(t, matrix$1);
4082
- t.rotation = MathHelper.formatRotation(t.rotation + angle);
4124
+ if (t.origin || t.around) {
4125
+ L.setTransform(t, matrix$1);
4126
+ }
4127
+ else {
4128
+ moveByMatrix(t, matrix$1);
4129
+ t.rotation = MathHelper.formatRotation(t.rotation + angle);
4130
+ }
4083
4131
  },
4084
4132
  skewOfWorld(t, origin, skewX, skewY, resize) {
4085
4133
  L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
@@ -4102,7 +4150,7 @@ var LeaferUI = (function (exports) {
4102
4150
  L.setTransform(t, matrix$1, resize);
4103
4151
  },
4104
4152
  setTransform(t, transform, resize) {
4105
- const layout = getLayout(transform);
4153
+ const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around));
4106
4154
  if (resize) {
4107
4155
  const scaleX = layout.scaleX / t.scaleX;
4108
4156
  const scaleY = layout.scaleY / t.scaleY;
@@ -4115,13 +4163,19 @@ var LeaferUI = (function (exports) {
4115
4163
  t.set(layout);
4116
4164
  }
4117
4165
  },
4166
+ getFlipTransform(t, axis) {
4167
+ const m = getMatrixData();
4168
+ const sign = axis === 'x' ? 1 : -1;
4169
+ scaleOfOuter$2(m, L.getLocalOrigin(t, 'center'), -1 * sign, 1 * sign);
4170
+ return m;
4171
+ },
4118
4172
  getLocalOrigin(t, origin) {
4119
4173
  return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
4120
4174
  },
4121
4175
  getInnerOrigin(t, origin) {
4122
- if (typeof origin === 'string')
4123
- AroundHelper.toPoint(origin, t.boxBounds, origin = {});
4124
- return origin;
4176
+ const innerOrigin = {};
4177
+ AroundHelper.toPoint(origin, t.boxBounds, innerOrigin);
4178
+ return innerOrigin;
4125
4179
  },
4126
4180
  getRelativeWorld(t, relative, temp) {
4127
4181
  copy$7(matrix$1, t.worldTransform);
@@ -4548,7 +4602,10 @@ var LeaferUI = (function (exports) {
4548
4602
  on(type, listener, options) {
4549
4603
  let capture, once;
4550
4604
  if (options) {
4551
- if (typeof options === 'boolean') {
4605
+ if (options === 'once') {
4606
+ once = true;
4607
+ }
4608
+ else if (typeof options === 'boolean') {
4552
4609
  capture = options;
4553
4610
  }
4554
4611
  else {
@@ -4579,7 +4636,7 @@ var LeaferUI = (function (exports) {
4579
4636
  if (listener) {
4580
4637
  let capture;
4581
4638
  if (options)
4582
- capture = typeof options === 'boolean' ? options : options.capture;
4639
+ capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
4583
4640
  let events, index;
4584
4641
  const map = __getListenerMap(this, capture);
4585
4642
  typeList.forEach(type => {
@@ -4881,7 +4938,7 @@ var LeaferUI = (function (exports) {
4881
4938
  const layout = this.__layout, local = this.__local, data = this.__;
4882
4939
  if (layout.affectScaleOrRotation) {
4883
4940
  if (layout.scaleChanged || layout.rotationChanged) {
4884
- setLayout(local, data, null, layout.affectRotation);
4941
+ setLayout(local, data, null, null, layout.affectRotation);
4885
4942
  layout.scaleChanged = layout.rotationChanged = false;
4886
4943
  }
4887
4944
  }
@@ -4889,7 +4946,7 @@ var LeaferUI = (function (exports) {
4889
4946
  local.f = data.y + data.offsetY;
4890
4947
  if (data.around || data.origin) {
4891
4948
  toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
4892
- translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.origin);
4949
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
4893
4950
  }
4894
4951
  }
4895
4952
  this.__layout.matrixChanged = false;
@@ -4898,7 +4955,7 @@ var LeaferUI = (function (exports) {
4898
4955
 
4899
4956
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
4900
4957
  const { updateBounds: updateBounds$1 } = BranchHelper;
4901
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
4958
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
4902
4959
  const { toBounds: toBounds$2 } = PathBounds;
4903
4960
  const LeafBounds = {
4904
4961
  __updateWorldBounds() {
@@ -4999,7 +5056,7 @@ var LeaferUI = (function (exports) {
4999
5056
  updateAllMatrix$2(this);
5000
5057
  updateBounds$1(this, this);
5001
5058
  if (this.__.__autoSide)
5002
- this.__updateBoxBounds();
5059
+ this.__updateBoxBounds(true);
5003
5060
  }
5004
5061
  else {
5005
5062
  updateAllMatrix$2(this);
@@ -5017,11 +5074,11 @@ var LeaferUI = (function (exports) {
5017
5074
  },
5018
5075
  __updateStrokeBounds() {
5019
5076
  const layout = this.__layout;
5020
- copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5077
+ copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5021
5078
  },
5022
5079
  __updateRenderBounds() {
5023
5080
  const layout = this.__layout;
5024
- layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5081
+ layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5025
5082
  }
5026
5083
  };
5027
5084
 
@@ -5118,7 +5175,7 @@ var LeaferUI = (function (exports) {
5118
5175
  const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5119
5176
  const { toOuterOf } = BoundsHelper;
5120
5177
  const { copy: copy$4 } = PointHelper;
5121
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5178
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5122
5179
  exports.Leaf = class Leaf {
5123
5180
  get tag() { return this.__tag; }
5124
5181
  set tag(_value) { }
@@ -5144,6 +5201,8 @@ var LeaferUI = (function (exports) {
5144
5201
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5145
5202
  get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
5146
5203
  get pathInputed() { return this.__.__pathInputed; }
5204
+ set event(map) { let event; for (let key in map)
5205
+ event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
5147
5206
  constructor(data) {
5148
5207
  this.innerId = create(LEAF);
5149
5208
  this.reset(data);
@@ -5379,6 +5438,9 @@ var LeaferUI = (function (exports) {
5379
5438
  move(x, y) {
5380
5439
  moveLocal(this, x, y);
5381
5440
  }
5441
+ moveInner(x, y) {
5442
+ moveWorld(this, x, y, true);
5443
+ }
5382
5444
  scaleOf(origin, scaleX, scaleY, resize) {
5383
5445
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
5384
5446
  }
@@ -5403,6 +5465,9 @@ var LeaferUI = (function (exports) {
5403
5465
  skewOfWorld(worldOrigin, skewX, skewY, resize) {
5404
5466
  skewOfWorld(this, worldOrigin, skewX, skewY, resize);
5405
5467
  }
5468
+ flip(axis) {
5469
+ transform(this, getFlipTransform(this, axis));
5470
+ }
5406
5471
  scaleResize(scaleX, scaleY = scaleX, _noResize) {
5407
5472
  this.scaleX *= scaleX;
5408
5473
  this.scaleY *= scaleY;
@@ -5760,7 +5825,7 @@ var LeaferUI = (function (exports) {
5760
5825
  }
5761
5826
  }
5762
5827
 
5763
- const version = "1.0.0-rc.30";
5828
+ const version = "1.0.1";
5764
5829
  const inviteCode = {};
5765
5830
 
5766
5831
  class LeaferCanvas extends LeaferCanvasBase {
@@ -5830,7 +5895,7 @@ var LeaferUI = (function (exports) {
5830
5895
  Platform.name = 'web';
5831
5896
  Platform.isWorker = true;
5832
5897
  Platform.requestRender = function (render) { requestAnimationFrame(render); };
5833
- Platform.devicePixelRatio = 1;
5898
+ defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
5834
5899
  const { userAgent } = navigator;
5835
5900
  if (userAgent.indexOf("Firefox") > -1) {
5836
5901
  Platform.conicGradientRotate90 = true;
@@ -6326,14 +6391,14 @@ var LeaferUI = (function (exports) {
6326
6391
  if (Debug.showRepaint)
6327
6392
  this.canvas.strokeWorld(bounds, 'red');
6328
6393
  this.target.__render(this.canvas, options);
6329
- this.renderBounds = realBounds || bounds;
6394
+ this.renderBounds = realBounds = realBounds || bounds;
6330
6395
  this.renderOptions = options;
6331
- this.totalBounds.isEmpty() ? this.totalBounds = this.renderBounds : this.totalBounds.add(this.renderBounds);
6396
+ this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
6332
6397
  if (Debug.showHitView)
6333
6398
  this.renderHitView(options);
6334
6399
  if (Debug.showBoundsView)
6335
6400
  this.renderBoundsView(options);
6336
- this.canvas.updateRender();
6401
+ this.canvas.updateRender(realBounds);
6337
6402
  }
6338
6403
  renderHitView(_options) { }
6339
6404
  renderBoundsView(_options) { }
@@ -6913,6 +6978,11 @@ var LeaferUI = (function (exports) {
6913
6978
  }
6914
6979
 
6915
6980
  class LeaferData extends GroupData {
6981
+ __getInputData() {
6982
+ const data = super.__getInputData();
6983
+ canvasSizeAttrs.forEach(key => delete data[key]);
6984
+ return data;
6985
+ }
6916
6986
  }
6917
6987
 
6918
6988
  class FrameData extends BoxData {
@@ -6990,6 +7060,11 @@ var LeaferUI = (function (exports) {
6990
7060
  }
6991
7061
 
6992
7062
  class CanvasData extends RectData {
7063
+ __getInputData() {
7064
+ const data = super.__getInputData();
7065
+ data.url = this.__leaf.canvas.toDataURL('image/png');
7066
+ return data;
7067
+ }
6993
7068
  }
6994
7069
 
6995
7070
  const UIBounds = {
@@ -7655,7 +7730,7 @@ var LeaferUI = (function (exports) {
7655
7730
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7656
7731
  if (this.isApp)
7657
7732
  this.__setApp();
7658
- this.__checkAutoLayout(config);
7733
+ this.__checkAutoLayout(config, parentApp);
7659
7734
  this.view = canvas.view;
7660
7735
  if (parentApp) {
7661
7736
  this.__bindApp(parentApp);
@@ -7756,9 +7831,10 @@ var LeaferUI = (function (exports) {
7756
7831
  this.leafer = leafer;
7757
7832
  this.__level = 1;
7758
7833
  }
7759
- __checkAutoLayout(config) {
7760
- if (!config.width || !config.height) {
7761
- this.autoLayout = new AutoBounds(config);
7834
+ __checkAutoLayout(config, parentApp) {
7835
+ if (!parentApp) {
7836
+ if (!config.width || !config.height)
7837
+ this.autoLayout = new AutoBounds(config);
7762
7838
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
7763
7839
  }
7764
7840
  }
@@ -7893,12 +7969,21 @@ var LeaferUI = (function (exports) {
7893
7969
  list.push(item);
7894
7970
  }
7895
7971
  }
7896
- zoom(_zoomType, _padding, _fixedScale) { return undefined; }
7972
+ zoom(_zoomType, _padding, _fixedScale) {
7973
+ return debug$3.error('need @leafer-in/view');
7974
+ }
7897
7975
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
7898
7976
  getValidScale(changeScale) { return changeScale; }
7899
7977
  getWorldPointByClient(clientPoint, updateClient) {
7900
7978
  return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
7901
7979
  }
7980
+ getPagePointByClient(clientPoint, updateClient) {
7981
+ return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
7982
+ }
7983
+ updateClientBounds() {
7984
+ this.canvas && this.canvas.updateClientBounds();
7985
+ }
7986
+ receiveEvent(_event) { }
7902
7987
  __checkUpdateLayout() {
7903
7988
  this.__layout.update();
7904
7989
  }
@@ -7982,7 +8067,7 @@ var LeaferUI = (function (exports) {
7982
8067
  const rect$1 = exports.Rect.prototype;
7983
8068
  const group$1 = exports.Group.prototype;
7984
8069
  const childrenRenderBounds = {};
7985
- const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
8070
+ const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
7986
8071
  exports.Box = class Box extends exports.Group {
7987
8072
  get __tag() { return 'Box'; }
7988
8073
  get isBranchLeaf() { return true; }
@@ -7996,20 +8081,23 @@ var LeaferUI = (function (exports) {
7996
8081
  return this.__updateRectRenderSpread() || -1;
7997
8082
  }
7998
8083
  __updateRectBoxBounds() { }
7999
- __updateBoxBounds() {
8084
+ __updateBoxBounds(secondLayout) {
8000
8085
  const data = this.__;
8001
8086
  if (this.children.length) {
8002
8087
  if (data.__autoSide) {
8003
8088
  if (this.leafer && this.leafer.ready)
8004
8089
  this.leafer.layouter.addExtra(this);
8005
8090
  super.__updateBoxBounds();
8091
+ const { boxBounds } = this.__layout;
8006
8092
  if (!data.__autoSize) {
8007
- const b = this.__layout.boxBounds;
8008
- if (!data.__autoWidth)
8009
- b.height += b.y, b.width = data.width, b.x = b.y = 0;
8010
- if (!data.__autoHeight)
8011
- b.width += b.x, b.height = data.height, b.y = b.x = 0;
8093
+ if (data.__autoWidth)
8094
+ boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
8095
+ else
8096
+ boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
8012
8097
  }
8098
+ if (secondLayout && data.flow && data.padding)
8099
+ copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
8100
+ this.__updateNaturalSize();
8013
8101
  }
8014
8102
  else {
8015
8103
  this.__updateRectBoxBounds();
@@ -8029,13 +8117,13 @@ var LeaferUI = (function (exports) {
8029
8117
  super.__updateRenderBounds();
8030
8118
  copy$3(childrenRenderBounds, renderBounds);
8031
8119
  this.__updateRectRenderBounds();
8032
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8120
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
8033
8121
  }
8034
8122
  else {
8035
8123
  this.__updateRectRenderBounds();
8036
8124
  }
8037
8125
  this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8038
- if (isOverflow && !(this.__.__drawAfterFill = this.__.overflow === 'hide'))
8126
+ if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
8039
8127
  add(renderBounds, childrenRenderBounds);
8040
8128
  }
8041
8129
  __updateRectRenderBounds() { }
@@ -8369,14 +8457,26 @@ var LeaferUI = (function (exports) {
8369
8457
  exports.Image = __decorate([
8370
8458
  registerUI()
8371
8459
  ], exports.Image);
8460
+ const MyImage = exports.Image;
8372
8461
 
8373
8462
  exports.Canvas = class Canvas extends exports.Rect {
8374
8463
  get __tag() { return 'Canvas'; }
8464
+ get ready() { return !this.url; }
8375
8465
  constructor(data) {
8376
8466
  super(data);
8377
8467
  this.canvas = Creator.canvas(this.__);
8378
8468
  this.context = this.canvas.context;
8379
8469
  this.__.__isCanvas = this.__.__drawAfterFill = true;
8470
+ if (data && data.url)
8471
+ this.drawImage(data.url);
8472
+ }
8473
+ drawImage(url) {
8474
+ new LeaferImage({ url }).load((image) => {
8475
+ this.context.drawImage(image.view, 0, 0);
8476
+ this.url = undefined;
8477
+ this.paint();
8478
+ this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
8479
+ });
8380
8480
  }
8381
8481
  draw(ui, offset, scale, rotation) {
8382
8482
  ui.__layout.update();
@@ -8420,8 +8520,7 @@ var LeaferUI = (function (exports) {
8420
8520
  destroy() {
8421
8521
  if (this.canvas) {
8422
8522
  this.canvas.destroy();
8423
- this.canvas = null;
8424
- this.context = null;
8523
+ this.canvas = this.context = null;
8425
8524
  }
8426
8525
  super.destroy();
8427
8526
  }
@@ -8436,7 +8535,7 @@ var LeaferUI = (function (exports) {
8436
8535
  resizeType(100)
8437
8536
  ], exports.Canvas.prototype, "height", void 0);
8438
8537
  __decorate([
8439
- resizeType(Platform.devicePixelRatio)
8538
+ resizeType(1)
8440
8539
  ], exports.Canvas.prototype, "pixelRatio", void 0);
8441
8540
  __decorate([
8442
8541
  resizeType(true)
@@ -8460,13 +8559,13 @@ var LeaferUI = (function (exports) {
8460
8559
  super(data);
8461
8560
  }
8462
8561
  __drawHitPath(canvas) {
8463
- const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
8562
+ const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
8464
8563
  canvas.beginPath();
8465
8564
  if (this.__.__letterSpacing < 0) {
8466
8565
  this.__drawPathByData(canvas);
8467
8566
  }
8468
8567
  else {
8469
- data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
8568
+ data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
8470
8569
  }
8471
8570
  }
8472
8571
  __drawPathByData(drawer, _data) {
@@ -8659,7 +8758,8 @@ var LeaferUI = (function (exports) {
8659
8758
  drawPoints(_points, _curve, _close) { return this; }
8660
8759
  clearPath() { return this; }
8661
8760
  paint() {
8662
- this.pathElement.forceUpdate('path');
8761
+ if (!this.pathElement.__layout.boxChanged)
8762
+ this.pathElement.forceUpdate('path');
8663
8763
  }
8664
8764
  };
8665
8765
  __decorate([
@@ -8669,7 +8769,7 @@ var LeaferUI = (function (exports) {
8669
8769
  penPathType()
8670
8770
  ], exports.Pen.prototype, "path", void 0);
8671
8771
  exports.Pen = __decorate([
8672
- useModule(PathCreator, ['set', 'beginPath', 'path']),
8772
+ useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
8673
8773
  registerUI()
8674
8774
  ], exports.Pen);
8675
8775
  function penPathType() {
@@ -8774,11 +8874,13 @@ var LeaferUI = (function (exports) {
8774
8874
  this.renderer.update();
8775
8875
  }
8776
8876
  __render(canvas, options) {
8777
- if (options.matrix) {
8778
- const { a, b, c, d, e, f } = options.matrix;
8779
- canvas.setTransform(a, b, c, d, e, f);
8877
+ if (canvas.context) {
8878
+ if (options.matrix) {
8879
+ const { a, b, c, d, e, f } = options.matrix;
8880
+ canvas.setTransform(a, b, c, d, e, f);
8881
+ }
8882
+ this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8780
8883
  }
8781
- this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8782
8884
  }
8783
8885
  __onResize(event) {
8784
8886
  this.children.forEach(leafer => leafer.resize(event));
@@ -8890,6 +8992,7 @@ var LeaferUI = (function (exports) {
8890
8992
  exports.PointerEvent = __decorate([
8891
8993
  registerUIEvent()
8892
8994
  ], exports.PointerEvent);
8995
+ const MyPointerEvent = exports.PointerEvent;
8893
8996
 
8894
8997
  const move = {};
8895
8998
  exports.DragEvent = class DragEvent extends exports.PointerEvent {
@@ -8989,6 +9092,7 @@ var LeaferUI = (function (exports) {
8989
9092
  exports.DragEvent = __decorate([
8990
9093
  registerUIEvent()
8991
9094
  ], exports.DragEvent);
9095
+ const MyDragEvent = exports.DragEvent;
8992
9096
 
8993
9097
  exports.DropEvent = class DropEvent extends exports.PointerEvent {
8994
9098
  static setList(data) {
@@ -9070,36 +9174,32 @@ var LeaferUI = (function (exports) {
9070
9174
 
9071
9175
  function document(leafer) {
9072
9176
  addInteractionWindow(leafer);
9073
- leafer.config.move.scroll = 'limit';
9074
- leafer.config.zoom.min = 1;
9177
+ const { move, zoom } = leafer.config;
9178
+ move.scroll = 'limit';
9179
+ zoom.min = 1;
9180
+ }
9181
+
9182
+ function block(leafer) {
9183
+ const { config } = leafer;
9184
+ (config.wheel || (config.wheel = {})).preventDefault = false;
9185
+ (config.touch || (config.touch = {})).preventDefault = 'auto';
9075
9186
  }
9076
9187
 
9077
9188
  const debug$2 = Debug.get('LeaferTypeCreator');
9078
9189
  const LeaferTypeCreator = {
9079
9190
  list: {},
9080
9191
  register(name, fn) {
9081
- if (list[name]) {
9082
- debug$2.repeat(name);
9083
- }
9084
- else {
9085
- list[name] = fn;
9086
- }
9192
+ list[name] ? debug$2.repeat(name) : list[name] = fn;
9087
9193
  },
9088
9194
  run(name, leafer) {
9089
9195
  const fn = list[name];
9090
- if (fn) {
9091
- fn(leafer);
9092
- }
9093
- else {
9094
- debug$2.error('no', name);
9095
- }
9196
+ fn && fn(leafer);
9096
9197
  }
9097
9198
  };
9098
9199
  const { list, register } = LeaferTypeCreator;
9099
- register('draw', () => { });
9100
- register('custom', () => { });
9101
9200
  register('design', addInteractionWindow);
9102
9201
  register('document', document);
9202
+ register('block', block);
9103
9203
 
9104
9204
  const leafer = exports.Leafer.prototype;
9105
9205
  leafer.initType = function (type) {
@@ -9145,11 +9245,14 @@ var LeaferUI = (function (exports) {
9145
9245
  };
9146
9246
 
9147
9247
  class Transformer {
9248
+ get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
9148
9249
  constructor(interaction) {
9149
9250
  this.interaction = interaction;
9150
9251
  }
9151
9252
  move(data) {
9152
9253
  const { interaction } = this;
9254
+ if (!data.moveType)
9255
+ data.moveType = 'move';
9153
9256
  if (!this.moveData) {
9154
9257
  const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9155
9258
  data.path = path;
@@ -9285,7 +9388,13 @@ var LeaferUI = (function (exports) {
9285
9388
  find.add(list[i]);
9286
9389
  }
9287
9390
  return find;
9288
- }
9391
+ },
9392
+ pathCanDrag(path) {
9393
+ return path && path.list.some(item => item.draggable || item.editable || (!item.isLeafer && item.hasEvent(exports.DragEvent.DRAG)));
9394
+ },
9395
+ pathHasOutside(path) {
9396
+ return path && path.list.some(item => item.isOutside);
9397
+ },
9289
9398
  };
9290
9399
  const I = InteractionHelper;
9291
9400
 
@@ -9314,8 +9423,10 @@ var LeaferUI = (function (exports) {
9314
9423
  return;
9315
9424
  }
9316
9425
  if (!this.moving && canDrag) {
9317
- if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty)
9426
+ if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty) {
9427
+ this.dragData.moveType = 'drag';
9318
9428
  interaction.emit(exports.MoveEvent.START, this.dragData);
9429
+ }
9319
9430
  }
9320
9431
  if (!this.moving) {
9321
9432
  this.dragStart(data, canDrag);
@@ -9354,6 +9465,7 @@ var LeaferUI = (function (exports) {
9354
9465
  this.dragData.throughPath = throughPath;
9355
9466
  this.dragData.path = path;
9356
9467
  if (this.moving) {
9468
+ this.dragData.moveType = 'drag';
9357
9469
  interaction.emit(exports.MoveEvent.BEFORE_MOVE, this.dragData);
9358
9470
  interaction.emit(exports.MoveEvent.MOVE, this.dragData);
9359
9471
  }
@@ -9420,6 +9532,7 @@ var LeaferUI = (function (exports) {
9420
9532
  endDragData.path = path;
9421
9533
  if (this.moving) {
9422
9534
  this.moving = false;
9535
+ endDragData.moveType = 'drag';
9423
9536
  interaction.emit(exports.MoveEvent.END, endDragData);
9424
9537
  }
9425
9538
  if (this.dragging) {
@@ -9478,7 +9591,7 @@ var LeaferUI = (function (exports) {
9478
9591
  totalY += moveY;
9479
9592
  PointHelper.move(downData, moveX, moveY);
9480
9593
  PointHelper.move(this.dragData, moveX, moveY);
9481
- interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY }));
9594
+ interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
9482
9595
  interaction.pointerMoveReal(data);
9483
9596
  }, 10);
9484
9597
  }
@@ -9591,22 +9704,27 @@ var LeaferUI = (function (exports) {
9591
9704
  swipeDistance: 20,
9592
9705
  preventDefaultMenu: true
9593
9706
  },
9707
+ touch: {
9708
+ preventDefault: true
9709
+ },
9594
9710
  cursor: true,
9595
9711
  keyEvent: true
9596
9712
  };
9597
9713
 
9598
- const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
9714
+ const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag, pathHasOutside } = InteractionHelper;
9599
9715
  class InteractionBase {
9600
9716
  get dragging() { return this.dragger.dragging; }
9601
- get moveMode() { return this.config.move.drag || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
9717
+ get transforming() { return this.transformer.transforming; }
9718
+ get moveMode() { return this.config.move.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
9719
+ get canHover() { return this.config.pointer.hover && !this.config.mobile; }
9602
9720
  get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
9603
- get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.config.pointer.hover && this.downData && this.isTreePath(this.downData); }
9721
+ get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
9604
9722
  get isHoldMiddleKey() { return this.config.move.holdMiddleKey && this.downData && PointerButton.middle(this.downData); }
9605
9723
  get isHoldRightKey() { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData); }
9606
9724
  get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
9607
9725
  get hitRadius() { return this.config.pointer.hitRadius; }
9608
9726
  constructor(target, canvas, selector, userConfig) {
9609
- this.config = config;
9727
+ this.config = DataHelper.clone(config);
9610
9728
  this.tapCount = 0;
9611
9729
  this.downKeyMap = {};
9612
9730
  this.target = target;
@@ -9693,6 +9811,7 @@ var LeaferUI = (function (exports) {
9693
9811
  if (!downData)
9694
9812
  return;
9695
9813
  PointerButton.defaultLeft(data);
9814
+ data.multiTouch = downData.multiTouch;
9696
9815
  this.findPath(data);
9697
9816
  const upData = Object.assign(Object.assign({}, data), { path: data.path.clone() });
9698
9817
  data.path.addList(downData.path.list);
@@ -9765,7 +9884,7 @@ var LeaferUI = (function (exports) {
9765
9884
  this.updateCursor();
9766
9885
  }
9767
9886
  pointerHover(data) {
9768
- if (this.config.pointer.hover) {
9887
+ if (this.canHover) {
9769
9888
  this.pointerOverOrOut(data);
9770
9889
  this.pointerEnterOrLeave(data);
9771
9890
  }
@@ -9857,11 +9976,11 @@ var LeaferUI = (function (exports) {
9857
9976
  return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
9858
9977
  }
9859
9978
  checkPath(data, useDefaultPath) {
9860
- if (useDefaultPath || this.canMove(data))
9979
+ if (useDefaultPath || (this.moveMode && !pathHasOutside(data.path)))
9861
9980
  data.path = this.defaultPath;
9862
9981
  }
9863
9982
  canMove(data) {
9864
- return this.moveMode && data && data.path.list.every(item => !item.isOutside);
9983
+ return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path);
9865
9984
  }
9866
9985
  isDrag(leaf) {
9867
9986
  return this.dragger.getList().has(leaf);
@@ -9902,7 +10021,7 @@ var LeaferUI = (function (exports) {
9902
10021
  this.hoverData = data;
9903
10022
  }
9904
10023
  updateCursor(data) {
9905
- if (!this.config.cursor || !this.config.pointer.hover)
10024
+ if (!this.config.cursor || !this.canHover)
9906
10025
  return;
9907
10026
  if (!data) {
9908
10027
  this.updateHoverData();
@@ -10556,10 +10675,13 @@ var LeaferUI = (function (exports) {
10556
10675
  const { get: get$2, translate } = MatrixHelper;
10557
10676
  const tempBox = new Bounds();
10558
10677
  const tempPoint = {};
10678
+ const tempScaleData = {};
10559
10679
  function createData(leafPaint, image, paint, box) {
10560
- const { blendMode } = paint;
10680
+ const { blendMode, sync } = paint;
10561
10681
  if (blendMode)
10562
10682
  leafPaint.blendMode = blendMode;
10683
+ if (sync)
10684
+ leafPaint.sync = sync;
10563
10685
  leafPaint.data = getPatternData(paint, box, image);
10564
10686
  }
10565
10687
  function getPatternData(paint, box, image) {
@@ -10579,13 +10701,10 @@ var LeaferUI = (function (exports) {
10579
10701
  x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
10580
10702
  }
10581
10703
  }
10582
- else if (size) {
10583
- scaleX = (typeof size === 'number' ? size : size.width) / width;
10584
- scaleY = (typeof size === 'number' ? size : size.height) / height;
10585
- }
10586
- else if (scale) {
10587
- scaleX = typeof scale === 'number' ? scale : scale.x;
10588
- scaleY = typeof scale === 'number' ? scale : scale.y;
10704
+ else if (scale || size) {
10705
+ MathHelper.getScaleData(scale, size, image, tempScaleData);
10706
+ scaleX = tempScaleData.scaleX;
10707
+ scaleY = tempScaleData.scaleY;
10589
10708
  }
10590
10709
  if (align) {
10591
10710
  const imageBounds = { x, y, width: swapWidth, height: swapHeight };
@@ -10790,7 +10909,7 @@ var LeaferUI = (function (exports) {
10790
10909
  const { abs } = Math;
10791
10910
  function checkImage(ui, canvas, paint, allowPaint) {
10792
10911
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
10793
- if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
10912
+ if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
10794
10913
  return false;
10795
10914
  }
10796
10915
  else {
@@ -10824,7 +10943,7 @@ var LeaferUI = (function (exports) {
10824
10943
  return true;
10825
10944
  }
10826
10945
  else {
10827
- if (!paint.style || Export.running) {
10946
+ if (!paint.style || paint.sync || Export.running) {
10828
10947
  createPattern(ui, paint, canvas.pixelRatio);
10829
10948
  }
10830
10949
  else {
@@ -11694,6 +11813,7 @@ var LeaferUI = (function (exports) {
11694
11813
  export(leaf, filename, options) {
11695
11814
  this.running = true;
11696
11815
  const fileType = FileHelper.fileType(filename);
11816
+ const isDownload = filename.includes('.');
11697
11817
  options = FileHelper.getExportOptions(options);
11698
11818
  return addTask((success) => new Promise((resolve) => {
11699
11819
  const over = (result) => {
@@ -11703,19 +11823,13 @@ var LeaferUI = (function (exports) {
11703
11823
  };
11704
11824
  const { toURL } = Platform;
11705
11825
  const { download } = Platform.origin;
11706
- if (filename === 'json') {
11707
- return over({ data: leaf.toJSON(options.json) });
11708
- }
11709
- else if (fileType === 'json') {
11710
- download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
11711
- return over({ data: true });
11826
+ if (fileType === 'json') {
11827
+ isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
11828
+ return over({ data: isDownload ? true : leaf.toJSON(options.json) });
11712
11829
  }
11713
- if (filename === 'svg') {
11714
- return over({ data: leaf.toSVG() });
11715
- }
11716
- else if (fileType === 'svg') {
11717
- download(toURL(leaf.toSVG(), 'svg'), filename);
11718
- return over({ data: true });
11830
+ if (fileType === 'svg') {
11831
+ isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
11832
+ return over({ data: isDownload ? true : leaf.toSVG() });
11719
11833
  }
11720
11834
  const { leafer } = leaf;
11721
11835
  if (leafer) {
@@ -11724,14 +11838,8 @@ var LeaferUI = (function (exports) {
11724
11838
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
11725
11839
  const { worldTransform, isLeafer, isFrame } = leaf;
11726
11840
  const { slice, trim, onCanvas } = options;
11727
- let scale = options.scale || 1;
11728
- let pixelRatio = options.pixelRatio || 1;
11729
11841
  const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
11730
11842
  const contextSettings = options.contextSettings || leafer.config.contextSettings;
11731
- if (leaf.isApp) {
11732
- scale *= pixelRatio;
11733
- pixelRatio = leaf.app.pixelRatio;
11734
- }
11735
11843
  const screenshot = options.screenshot || leaf.isApp;
11736
11844
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
11737
11845
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
@@ -11765,10 +11873,21 @@ var LeaferUI = (function (exports) {
11765
11873
  }
11766
11874
  renderBounds = leaf.getBounds('render', relative);
11767
11875
  }
11768
- const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
11876
+ const scaleData = { scaleX: 1, scaleY: 1 };
11877
+ MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
11878
+ let pixelRatio = options.pixelRatio || 1;
11879
+ if (leaf.isApp) {
11880
+ scaleData.scaleX *= pixelRatio;
11881
+ scaleData.scaleY *= pixelRatio;
11882
+ pixelRatio = leaf.app.pixelRatio;
11883
+ }
11884
+ const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
11885
+ const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
11769
11886
  let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
11770
- const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
11887
+ let sliceLeaf;
11771
11888
  if (slice) {
11889
+ sliceLeaf = leaf;
11890
+ sliceLeaf.__worldOpacity = 0;
11772
11891
  leaf = leafer;
11773
11892
  renderOptions.bounds = canvas.bounds;
11774
11893
  }
@@ -11783,6 +11902,8 @@ var LeaferUI = (function (exports) {
11783
11902
  leaf.__render(canvas, renderOptions);
11784
11903
  }
11785
11904
  canvas.restore();
11905
+ if (sliceLeaf)
11906
+ sliceLeaf.__updateWorldOpacity();
11786
11907
  if (trim) {
11787
11908
  trimBounds = getTrimBounds(canvas);
11788
11909
  const old = canvas, { width, height } = trimBounds;
@@ -11931,6 +12052,9 @@ var LeaferUI = (function (exports) {
11931
12052
  exports.Matrix = Matrix;
11932
12053
  exports.MatrixHelper = MatrixHelper;
11933
12054
  exports.MultiTouchHelper = MultiTouchHelper;
12055
+ exports.MyDragEvent = MyDragEvent;
12056
+ exports.MyImage = MyImage;
12057
+ exports.MyPointerEvent = MyPointerEvent;
11934
12058
  exports.NeedConvertToCanvasCommandMap = NeedConvertToCanvasCommandMap;
11935
12059
  exports.OneRadian = OneRadian;
11936
12060
  exports.PI2 = PI2;