@leafer-editor/worker 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -430,7 +430,7 @@ const MatrixHelper = {
430
430
  const M$9 = MatrixHelper;
431
431
 
432
432
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
433
- const { sin: sin$4, cos: cos$4, abs: abs$5, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
433
+ const { sin: sin$4, cos: cos$4, abs: abs$6, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
434
434
  const PointHelper = {
435
435
  defaultPoint: getPointData(),
436
436
  tempPoint: {},
@@ -519,8 +519,8 @@ const PointHelper = {
519
519
  return getDistanceFrom(t.x, t.y, point.x, point.y);
520
520
  },
521
521
  getDistanceFrom(x1, y1, x2, y2) {
522
- const x = abs$5(x2 - x1);
523
- const y = abs$5(y2 - y1);
522
+ const x = abs$6(x2 - x1);
523
+ const y = abs$6(y2 - y1);
524
524
  return sqrt$2(x * x + y * y);
525
525
  },
526
526
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
@@ -1374,7 +1374,7 @@ function getNameList(name) {
1374
1374
  }
1375
1375
  const D$6 = Debug;
1376
1376
 
1377
- const debug$g = Debug.get('RunTime');
1377
+ const debug$h = Debug.get('RunTime');
1378
1378
  const Run = {
1379
1379
  currentId: 0,
1380
1380
  currentName: '',
@@ -1392,7 +1392,7 @@ const Run = {
1392
1392
  const time = R.idMap[id], name = R.nameMap[id];
1393
1393
  const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
1394
1394
  R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
1395
- debug$g.log(name, duration, 'ms');
1395
+ debug$h.log(name, duration, 'ms');
1396
1396
  },
1397
1397
  endOfName(name, microsecond) {
1398
1398
  const id = R.nameToIdMap[name];
@@ -1406,18 +1406,18 @@ function needPlugin(name) {
1406
1406
  console.error('need plugin: @leafer-in/' + name);
1407
1407
  }
1408
1408
 
1409
- const debug$f = Debug.get('UICreator');
1409
+ const debug$g = Debug.get('UICreator');
1410
1410
  const UICreator = {
1411
1411
  list: {},
1412
1412
  register(UI) {
1413
1413
  const { __tag: tag } = UI.prototype;
1414
1414
  if (list$3[tag])
1415
- debug$f.repeat(tag);
1415
+ debug$g.repeat(tag);
1416
1416
  list$3[tag] = UI;
1417
1417
  },
1418
1418
  get(tag, data, x, y, width, height) {
1419
1419
  if (!list$3[tag])
1420
- debug$f.error('not register ' + tag);
1420
+ debug$g.error('not register ' + tag);
1421
1421
  const ui = new list$3[tag](data);
1422
1422
  if (x !== undefined) {
1423
1423
  ui.x = x;
@@ -1433,7 +1433,7 @@ const UICreator = {
1433
1433
  };
1434
1434
  const { list: list$3 } = UICreator;
1435
1435
 
1436
- const debug$e = Debug.get('EventCreator');
1436
+ const debug$f = Debug.get('EventCreator');
1437
1437
  const EventCreator = {
1438
1438
  nameList: {},
1439
1439
  register(Event) {
@@ -1441,7 +1441,7 @@ const EventCreator = {
1441
1441
  Object.keys(Event).forEach(key => {
1442
1442
  name = Event[key];
1443
1443
  if (typeof name === 'string')
1444
- nameList[name] && debug$e.repeat(name), nameList[name] = Event;
1444
+ nameList[name] && debug$f.repeat(name), nameList[name] = Event;
1445
1445
  });
1446
1446
  },
1447
1447
  changeName(oldName, newName) {
@@ -1513,17 +1513,19 @@ const DataHelper = {
1513
1513
  assign(t, defaultData);
1514
1514
  return t;
1515
1515
  },
1516
- assign(t, merge) {
1516
+ assign(t, merge, exclude) {
1517
1517
  let value;
1518
1518
  Object.keys(merge).forEach(key => {
1519
- var _a;
1519
+ var _a, _b;
1520
1520
  value = merge[key];
1521
- if ((value === null || value === void 0 ? void 0 : value.constructor) === Object) {
1522
- (((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) ? assign(t[key], merge[key]) : t[key] = merge[key];
1523
- }
1524
- else {
1525
- t[key] = merge[key];
1521
+ if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object)
1522
+ return assign(t[key], merge[key], exclude && exclude[key]);
1523
+ if (exclude && (key in exclude)) {
1524
+ if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object)
1525
+ assign(t[key] = {}, merge[key], exclude[key]);
1526
+ return;
1526
1527
  }
1528
+ t[key] = merge[key];
1527
1529
  });
1528
1530
  },
1529
1531
  copyAttrs(t, from, include) {
@@ -2327,7 +2329,7 @@ const RectHelper = {
2327
2329
  }
2328
2330
  };
2329
2331
 
2330
- const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$4, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2332
+ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$5, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2331
2333
  const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2332
2334
  const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
2333
2335
  const { M: M$8, L: L$9, C: C$8, Q: Q$7, Z: Z$7 } = PathCommandMap;
@@ -2400,7 +2402,7 @@ const BezierHelper = {
2400
2402
  let totalRadian = endRadian - startRadian;
2401
2403
  if (totalRadian < 0)
2402
2404
  totalRadian += PI2;
2403
- if (totalRadian === PI$2 || (abs$4(BAx + BAy) < 1.e-12) || (abs$4(CBx + CBy) < 1.e-12)) {
2405
+ if (totalRadian === PI$2 || (abs$5(BAx + BAy) < 1.e-12) || (abs$5(CBx + CBy) < 1.e-12)) {
2404
2406
  if (data)
2405
2407
  data.push(L$9, x1, y1);
2406
2408
  if (setPointBounds) {
@@ -2442,7 +2444,7 @@ const BezierHelper = {
2442
2444
  totalRadian -= PI2;
2443
2445
  if (anticlockwise)
2444
2446
  totalRadian -= PI2;
2445
- const parts = ceil$1(abs$4(totalRadian / PI_2));
2447
+ const parts = ceil$1(abs$5(totalRadian / PI_2));
2446
2448
  const partRadian = totalRadian / parts;
2447
2449
  const partRadian4Sin = sin$3(partRadian / 4);
2448
2450
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -2595,7 +2597,7 @@ const EllipseHelper = {
2595
2597
  const { M: M$7, m, L: L$8, l, H, h, V, v, C: C$7, c, S, s, Q: Q$6, q, T, t, A, a, Z: Z$6, z, N: N$5, D: D$5, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5 } = PathCommandMap;
2596
2598
  const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2597
2599
  const { ellipticalArc } = EllipseHelper;
2598
- const debug$d = Debug.get('PathConvert');
2600
+ const debug$e = Debug.get('PathConvert');
2599
2601
  const setEndPoint$1 = {};
2600
2602
  const PathConvert = {
2601
2603
  current: { dot: 0 },
@@ -2836,7 +2838,7 @@ const PathConvert = {
2836
2838
  i += 6;
2837
2839
  break;
2838
2840
  default:
2839
- debug$d.error(`command: ${command} [index:${i}]`, old);
2841
+ debug$e.error(`command: ${command} [index:${i}]`, old);
2840
2842
  return data;
2841
2843
  }
2842
2844
  lastCommand = command;
@@ -2883,7 +2885,7 @@ const { current, pushData, copyData } = PathConvert;
2883
2885
 
2884
2886
  const { M: M$6, L: L$7, C: C$6, Q: Q$5, Z: Z$5, N: N$4, D: D$4, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4 } = PathCommandMap;
2885
2887
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2886
- const { tan, min, abs: abs$3 } = Math;
2888
+ const { tan, min, abs: abs$4 } = Math;
2887
2889
  const startPoint = {};
2888
2890
  const PathCommandDataHelper = {
2889
2891
  beginPath(data) {
@@ -2946,7 +2948,7 @@ const PathCommandDataHelper = {
2946
2948
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
2947
2949
  if (lastX !== undefined) {
2948
2950
  const maxRadius = tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2) * (getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / 2);
2949
- data.push(U$4, x1, y1, x2, y2, min(radius, abs$3(maxRadius)));
2951
+ data.push(U$4, x1, y1, x2, y2, min(radius, abs$4(maxRadius)));
2950
2952
  }
2951
2953
  else {
2952
2954
  data.push(U$4, x1, y1, x2, y2, radius);
@@ -3061,7 +3063,7 @@ class PathCreator {
3061
3063
  }
3062
3064
 
3063
3065
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$4, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$4, P: P$3, U: U$3 } = PathCommandMap;
3064
- const debug$c = Debug.get('PathDrawer');
3066
+ const debug$d = Debug.get('PathDrawer');
3065
3067
  const PathDrawer = {
3066
3068
  drawPathByData(drawer, data) {
3067
3069
  if (!data)
@@ -3124,7 +3126,7 @@ const PathDrawer = {
3124
3126
  i += 6;
3125
3127
  break;
3126
3128
  default:
3127
- debug$c.error(`command: ${command} [index:${i}]`, data);
3129
+ debug$d.error(`command: ${command} [index:${i}]`, data);
3128
3130
  return;
3129
3131
  }
3130
3132
  }
@@ -3134,7 +3136,7 @@ const PathDrawer = {
3134
3136
  const { M: M$4, L: L$5, C: C$4, Q: Q$3, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$3, O: O$3, P: P$2, U: U$2 } = PathCommandMap;
3135
3137
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3136
3138
  const { addPointBounds, copy: copy$b, addPoint: addPoint$1, setPoint: setPoint$3, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3137
- const debug$b = Debug.get('PathBounds');
3139
+ const debug$c = Debug.get('PathBounds');
3138
3140
  let radius, radiusX, radiusY;
3139
3141
  const tempPointBounds = {};
3140
3142
  const setPointBounds = {};
@@ -3242,7 +3244,7 @@ const PathBounds = {
3242
3244
  i += 6;
3243
3245
  break;
3244
3246
  default:
3245
- debug$b.error(`command: ${command} [index:${i}]`, data);
3247
+ debug$c.error(`command: ${command} [index:${i}]`, data);
3246
3248
  return;
3247
3249
  }
3248
3250
  }
@@ -3358,7 +3360,7 @@ const FileHelper = {
3358
3360
  const F$2 = FileHelper;
3359
3361
  F$2.opacityTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
3360
3362
 
3361
- const debug$a = Debug.get('TaskProcessor');
3363
+ const debug$b = Debug.get('TaskProcessor');
3362
3364
  class TaskItem {
3363
3365
  constructor(task) {
3364
3366
  this.parallel = true;
@@ -3373,7 +3375,7 @@ class TaskItem {
3373
3375
  yield this.task();
3374
3376
  }
3375
3377
  catch (error) {
3376
- debug$a.error(error);
3378
+ debug$b.error(error);
3377
3379
  }
3378
3380
  });
3379
3381
  }
@@ -3891,6 +3893,8 @@ function opacityType(defaultValue) {
3891
3893
  return decorateLeafAttr(defaultValue, (key) => attr({
3892
3894
  set(value) {
3893
3895
  this.__setAttr(key, value) && (this.__layout.opacityChanged || this.__layout.opacityChange());
3896
+ if (this.mask)
3897
+ checkMask(this);
3894
3898
  }
3895
3899
  }));
3896
3900
  }
@@ -3907,9 +3911,20 @@ function visibleType(defaultValue) {
3907
3911
  this.__runAnimation('in');
3908
3912
  }
3909
3913
  doVisible(this, key, value, oldValue);
3914
+ if (this.mask)
3915
+ checkMask(this);
3910
3916
  }
3911
3917
  }));
3912
3918
  }
3919
+ function checkMask(leaf) {
3920
+ const { parent } = leaf;
3921
+ if (parent) {
3922
+ const { __hasMask } = parent;
3923
+ parent.__updateMask();
3924
+ if (__hasMask !== parent.__hasMask)
3925
+ parent.forceUpdate();
3926
+ }
3927
+ }
3913
3928
  function doVisible(leaf, key, value, oldValue) {
3914
3929
  if (leaf.__setAttr(key, value)) {
3915
3930
  leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
@@ -4047,7 +4062,7 @@ function defineDataProcessor(target, key, defaultValue) {
4047
4062
  defineKey(data, key, property);
4048
4063
  }
4049
4064
 
4050
- const debug$9 = new Debug('rewrite');
4065
+ const debug$a = new Debug('rewrite');
4051
4066
  const list$2 = [];
4052
4067
  const excludeNames = ['destroy', 'constructor'];
4053
4068
  function rewrite(method) {
@@ -4064,7 +4079,7 @@ function doRewrite(error) {
4064
4079
  if (list$2.length) {
4065
4080
  list$2.forEach(item => {
4066
4081
  if (error)
4067
- debug$9.error(item.name, '需在Class上装饰@rewriteAble()');
4082
+ debug$a.error(item.name, '需在Class上装饰@rewriteAble()');
4068
4083
  item.run();
4069
4084
  });
4070
4085
  list$2.length = 0;
@@ -4972,13 +4987,13 @@ const { on, on_, off, off_, once, emit: emit$2, emitEvent: emitEvent$1, hasEvent
4972
4987
  const LeafEventer = { on, on_, off, off_, once, emit: emit$2, emitEvent: emitEvent$1, hasEvent, destroyEventer: destroy };
4973
4988
 
4974
4989
  const { isFinite } = Number;
4975
- const debug$8 = Debug.get('setAttr');
4990
+ const debug$9 = Debug.get('setAttr');
4976
4991
  const LeafDataProxy = {
4977
4992
  __setAttr(name, newValue, checkFiniteNumber) {
4978
4993
  if (this.leaferIsCreated) {
4979
4994
  const oldValue = this.__.__getInput(name);
4980
4995
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4981
- debug$8.warn(this.innerName, name, newValue);
4996
+ debug$9.warn(this.innerName, name, newValue);
4982
4997
  newValue = undefined;
4983
4998
  }
4984
4999
  if (typeof newValue === 'object' || oldValue !== newValue) {
@@ -5434,8 +5449,8 @@ let Leaf = class Leaf {
5434
5449
  canvas.clearRect(r.x, r.y, r.width, r.height);
5435
5450
  canvas.restore();
5436
5451
  }
5437
- __updateMask(value) {
5438
- this.__hasMask = value ? true : this.children.some(item => item.__.mask);
5452
+ __updateMask(_value) {
5453
+ this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
5439
5454
  }
5440
5455
  __renderMask(_canvas, _options) { }
5441
5456
  __getNowWorld(options) {
@@ -5675,9 +5690,10 @@ Leaf = __decorate([
5675
5690
  useModule(LeafRender)
5676
5691
  ], Leaf);
5677
5692
 
5678
- const { setListWithFn } = BoundsHelper;
5693
+ const { setListWithFn: setListWithFn$1 } = BoundsHelper;
5679
5694
  const { sort } = BranchHelper;
5680
5695
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5696
+ const debug$8 = new Debug('Branch');
5681
5697
  let Branch = class Branch extends Leaf {
5682
5698
  __updateStrokeSpread() {
5683
5699
  const { children } = this;
@@ -5696,13 +5712,13 @@ let Branch = class Branch extends Leaf {
5696
5712
  return 0;
5697
5713
  }
5698
5714
  __updateBoxBounds() {
5699
- setListWithFn(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds);
5715
+ setListWithFn$1(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds);
5700
5716
  }
5701
5717
  __updateStrokeBounds() {
5702
- setListWithFn(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalStrokeBounds : localStrokeBounds);
5718
+ setListWithFn$1(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalStrokeBounds : localStrokeBounds);
5703
5719
  }
5704
5720
  __updateRenderBounds() {
5705
- setListWithFn(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds);
5721
+ setListWithFn$1(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds);
5706
5722
  }
5707
5723
  __updateSortChildren() {
5708
5724
  let affectSort;
@@ -5718,8 +5734,8 @@ let Branch = class Branch extends Leaf {
5718
5734
  }
5719
5735
  }
5720
5736
  add(child, index) {
5721
- if (child === this)
5722
- return;
5737
+ if (child === this || child.destroyed)
5738
+ return debug$8.warn('add self or destroyed');
5723
5739
  const noIndex = index === undefined;
5724
5740
  if (!child.__) {
5725
5741
  if (child instanceof Array)
@@ -5733,8 +5749,9 @@ let Branch = class Branch extends Leaf {
5733
5749
  noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
5734
5750
  if (child.isBranch)
5735
5751
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5736
- child.__layout.boxChanged || child.__layout.boxChange();
5737
- child.__layout.matrixChanged || child.__layout.matrixChange();
5752
+ const childLayout = child.__layout;
5753
+ childLayout.boxChanged || childLayout.boxChange();
5754
+ childLayout.matrixChanged || childLayout.matrixChange();
5738
5755
  if (child.__bubbleMap)
5739
5756
  child.__emitLifeEvent(ChildEvent.ADD);
5740
5757
  if (this.leafer) {
@@ -5972,7 +5989,7 @@ class LeafLevelList {
5972
5989
  }
5973
5990
  }
5974
5991
 
5975
- const version = "1.1.0";
5992
+ const version = "1.1.1";
5976
5993
 
5977
5994
  class LeaferCanvas extends LeaferCanvasBase {
5978
5995
  get allowBackgroundColor() { return true; }
@@ -6210,7 +6227,7 @@ function updateChange(updateList) {
6210
6227
  });
6211
6228
  }
6212
6229
 
6213
- const { worldBounds } = LeafBoundsHelper;
6230
+ const { worldBounds: worldBounds$1 } = LeafBoundsHelper;
6214
6231
  const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
6215
6232
  class LayoutBlockData {
6216
6233
  constructor(list) {
@@ -6222,7 +6239,7 @@ class LayoutBlockData {
6222
6239
  this.updatedList = list;
6223
6240
  }
6224
6241
  setBefore() {
6225
- this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
6242
+ this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds$1);
6226
6243
  }
6227
6244
  setAfter() {
6228
6245
  const { list } = this.updatedList;
@@ -6230,7 +6247,7 @@ class LayoutBlockData {
6230
6247
  this.afterBounds.set(bigBounds);
6231
6248
  }
6232
6249
  else {
6233
- this.afterBounds.setListWithFn(list, worldBounds);
6250
+ this.afterBounds.setListWithFn(list, worldBounds$1);
6234
6251
  }
6235
6252
  this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
6236
6253
  }
@@ -6417,25 +6434,25 @@ class Renderer {
6417
6434
  if (userConfig)
6418
6435
  this.config = DataHelper.default(userConfig, this.config);
6419
6436
  this.__listenEvents();
6420
- this.__requestRender();
6421
6437
  }
6422
6438
  start() {
6423
6439
  this.running = true;
6440
+ this.update(false);
6424
6441
  }
6425
6442
  stop() {
6426
6443
  this.running = false;
6427
6444
  }
6428
- update() {
6429
- this.changed = true;
6445
+ update(change = true) {
6446
+ if (!this.changed)
6447
+ this.changed = change;
6448
+ this.__requestRender();
6430
6449
  }
6431
6450
  requestLayout() {
6432
6451
  this.target.emit(LayoutEvent.REQUEST);
6433
6452
  }
6434
6453
  render(callback) {
6435
- if (!(this.running && this.canvas.view)) {
6436
- this.changed = true;
6437
- return;
6438
- }
6454
+ if (!(this.running && this.canvas.view))
6455
+ return this.update();
6439
6456
  const { target } = this;
6440
6457
  this.times = 0;
6441
6458
  this.totalBounds = new Bounds();
@@ -6569,16 +6586,17 @@ class Renderer {
6569
6586
  }
6570
6587
  }
6571
6588
  __requestRender() {
6572
- const startTime = Date.now();
6589
+ if (this.requestTime)
6590
+ return;
6591
+ const requestTime = this.requestTime = Date.now();
6573
6592
  Platform.requestRender(() => {
6574
- this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
6593
+ this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
6594
+ this.requestTime = 0;
6575
6595
  if (this.running) {
6576
6596
  if (this.changed && this.canvas.view)
6577
6597
  this.render();
6578
6598
  this.target.emit(RenderEvent.NEXT);
6579
6599
  }
6580
- if (this.target)
6581
- this.__requestRender();
6582
6600
  });
6583
6601
  }
6584
6602
  __onResize(e) {
@@ -6594,7 +6612,7 @@ class Renderer {
6594
6612
  }
6595
6613
  }
6596
6614
  this.addBlock(new Bounds(0, 0, 1, 1));
6597
- this.changed = true;
6615
+ this.update();
6598
6616
  }
6599
6617
  __onLayoutEnd(event) {
6600
6618
  if (event.data)
@@ -7002,7 +7020,7 @@ class UIData extends LeafData {
7002
7020
  return true;
7003
7021
  return t.fill && this.__hasStroke;
7004
7022
  }
7005
- get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
7023
+ get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7006
7024
  get __autoWidth() { return !this._width; }
7007
7025
  get __autoHeight() { return !this._height; }
7008
7026
  get __autoSide() { return !this._width || !this._height; }
@@ -7116,7 +7134,7 @@ class GroupData extends UIData {
7116
7134
 
7117
7135
  class BoxData extends GroupData {
7118
7136
  get __boxStroke() { return !this.__pathInputed; }
7119
- get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
7137
+ get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7120
7138
  get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7121
7139
  }
7122
7140
 
@@ -7776,20 +7794,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7776
7794
  constructor(userConfig, data) {
7777
7795
  super(data);
7778
7796
  this.config = {
7779
- type: 'design',
7780
7797
  start: true,
7781
7798
  hittable: true,
7782
7799
  smooth: true,
7783
- lazySpeard: 100,
7784
- zoom: {
7785
- min: 0.01,
7786
- max: 256
7787
- },
7788
- move: {
7789
- holdSpaceKey: true,
7790
- holdMiddleKey: true,
7791
- autoDistance: 2
7792
- }
7800
+ lazySpeard: 100
7793
7801
  };
7794
7802
  this.leafs = 0;
7795
7803
  this.__eventIds = [];
@@ -7806,23 +7814,27 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7806
7814
  init(userConfig, parentApp) {
7807
7815
  if (this.canvas)
7808
7816
  return;
7809
- this.__setLeafer(this);
7810
- if (userConfig)
7811
- DataHelper.assign(this.config, userConfig);
7812
7817
  let start;
7813
7818
  const { config } = this;
7814
- this.initType(config.type);
7819
+ this.__setLeafer(this);
7820
+ if (parentApp) {
7821
+ this.parentApp = parentApp;
7822
+ this.__bindApp(parentApp);
7823
+ start = parentApp.running;
7824
+ }
7825
+ if (userConfig) {
7826
+ this.parent = parentApp;
7827
+ this.initType(userConfig.type);
7828
+ this.parent = undefined;
7829
+ DataHelper.assign(config, userConfig);
7830
+ }
7815
7831
  const canvas = this.canvas = Creator.canvas(config);
7816
7832
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7817
7833
  if (this.isApp)
7818
7834
  this.__setApp();
7819
7835
  this.__checkAutoLayout(config, parentApp);
7820
7836
  this.view = canvas.view;
7821
- if (parentApp) {
7822
- this.__bindApp(parentApp);
7823
- start = parentApp.running;
7824
- }
7825
- else {
7837
+ if (!parentApp) {
7826
7838
  this.selector = Creator.selector(this);
7827
7839
  this.interaction = Creator.interaction(this, canvas, this.selector, config);
7828
7840
  if (this.interaction) {
@@ -7879,7 +7891,11 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7879
7891
  forceRender(bounds) {
7880
7892
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7881
7893
  if (this.viewReady)
7882
- this.renderer.update();
7894
+ this.renderer.render();
7895
+ }
7896
+ requestRender(change = false) {
7897
+ if (this.renderer)
7898
+ this.renderer.update(change);
7883
7899
  }
7884
7900
  updateCursor(cursor) {
7885
7901
  const i = this.interaction;
@@ -7987,8 +8003,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7987
8003
  const { imageReady } = this;
7988
8004
  if (imageReady && !this.viewCompleted)
7989
8005
  this.__checkViewCompleted();
7990
- if (!imageReady)
8006
+ if (!imageReady) {
7991
8007
  this.viewCompleted = false;
8008
+ this.requestRender();
8009
+ }
7992
8010
  }
7993
8011
  }
7994
8012
  __checkViewCompleted(emit = true) {
@@ -8046,6 +8064,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8046
8064
  }
8047
8065
  else
8048
8066
  list.push(item);
8067
+ this.requestRender();
8049
8068
  }
8050
8069
  zoom(_zoomType, _padding, _fixedScale) {
8051
8070
  return needPlugin('view');
@@ -8099,7 +8118,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8099
8118
  this.canvasManager.destroy();
8100
8119
  }
8101
8120
  this.canvas.destroy();
8102
- this.config.view = this.view = null;
8121
+ this.config.view = this.view = this.parentApp = null;
8103
8122
  if (this.userConfig)
8104
8123
  this.userConfig.view = null;
8105
8124
  super.destroy();
@@ -8826,9 +8845,9 @@ let App = class App extends Leafer {
8826
8845
  if (ground)
8827
8846
  this.ground = this.addLeafer(ground);
8828
8847
  if (tree || editor)
8829
- this.tree = this.addLeafer(tree);
8848
+ this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
8830
8849
  if (sky || editor)
8831
- this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
8850
+ this.sky = this.addLeafer(sky);
8832
8851
  if (editor)
8833
8852
  this.sky.add(this.editor = Creator.editor(editor));
8834
8853
  }
@@ -9182,184 +9201,7 @@ KeyEvent = __decorate([
9182
9201
  registerUIEvent()
9183
9202
  ], KeyEvent);
9184
9203
 
9185
- function addInteractionWindow(leafer) {
9186
- if (leafer.isApp)
9187
- return;
9188
- leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => {
9189
- leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
9190
- }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
9191
- const { zoomLayer } = leafer;
9192
- const changeScale = leafer.getValidScale(e.scale);
9193
- if (changeScale !== 1) {
9194
- PointHelper.scaleOf(zoomLayer, e, changeScale);
9195
- zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
9196
- }
9197
- }));
9198
- }
9199
-
9200
- function document$1(leafer) {
9201
- addInteractionWindow(leafer);
9202
- const { move, zoom } = leafer.config;
9203
- move.scroll = 'limit';
9204
- zoom.min = 1;
9205
- }
9206
-
9207
- function block(leafer) {
9208
- const { config } = leafer;
9209
- (config.wheel || (config.wheel = {})).preventDefault = false;
9210
- (config.touch || (config.touch = {})).preventDefault = 'auto';
9211
- }
9212
-
9213
- const debug$3 = Debug.get('LeaferTypeCreator');
9214
- const LeaferTypeCreator = {
9215
- list: {},
9216
- register(name, fn) {
9217
- list$1[name] && debug$3.repeat(name);
9218
- list$1[name] = fn;
9219
- },
9220
- run(name, leafer) {
9221
- const fn = list$1[name];
9222
- fn && fn(leafer);
9223
- }
9224
- };
9225
- const { list: list$1, register } = LeaferTypeCreator;
9226
- register('design', addInteractionWindow);
9227
- register('document', document$1);
9228
- register('block', block);
9229
-
9230
- const leafer = Leafer.prototype;
9231
- leafer.initType = function (type) {
9232
- LeaferTypeCreator.run(type, this);
9233
- };
9234
- leafer.getValidMove = function (moveX, moveY) {
9235
- const { scroll, disabled } = this.app.config.move;
9236
- if (scroll) {
9237
- Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
9238
- if (scroll === 'limit') {
9239
- const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
9240
- const right = x + width - this.width, bottom = y + height - this.height;
9241
- if (x >= 0 && right <= 0)
9242
- moveX = 0;
9243
- else if (moveX > 0) {
9244
- if (x + moveX > 0)
9245
- moveX = -x;
9246
- }
9247
- else if (moveX < 0 && right + moveX < 0)
9248
- moveX = -right;
9249
- if (y >= 0 && bottom <= 0)
9250
- moveY = 0;
9251
- else if (moveY > 0) {
9252
- if (y + moveY > 0)
9253
- moveY = -y;
9254
- }
9255
- else if (moveY < 0 && bottom + moveY < 0)
9256
- moveY = -bottom;
9257
- }
9258
- }
9259
- return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
9260
- };
9261
- leafer.getValidScale = function (changeScale) {
9262
- const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
9263
- if (absScale < min)
9264
- changeScale = min / scaleX;
9265
- else if (absScale > max)
9266
- changeScale = max / scaleX;
9267
- return disabled ? 1 : changeScale;
9268
- };
9269
-
9270
- class Transformer {
9271
- get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
9272
- constructor(interaction) {
9273
- this.interaction = interaction;
9274
- }
9275
- move(data) {
9276
- const { interaction } = this;
9277
- if (!data.moveType)
9278
- data.moveType = 'move';
9279
- if (!this.moveData) {
9280
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9281
- data.path = path;
9282
- this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
9283
- interaction.cancelHover();
9284
- interaction.emit(MoveEvent.START, this.moveData);
9285
- }
9286
- data.path = this.moveData.path;
9287
- interaction.emit(MoveEvent.BEFORE_MOVE, data);
9288
- interaction.emit(MoveEvent.MOVE, data);
9289
- this.transformEndWait();
9290
- }
9291
- zoom(data) {
9292
- const { interaction } = this;
9293
- if (!this.zoomData) {
9294
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9295
- data.path = path;
9296
- this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
9297
- interaction.cancelHover();
9298
- interaction.emit(ZoomEvent.START, this.zoomData);
9299
- }
9300
- data.path = this.zoomData.path;
9301
- interaction.emit(ZoomEvent.BEFORE_ZOOM, data);
9302
- interaction.emit(ZoomEvent.ZOOM, data);
9303
- this.transformEndWait();
9304
- }
9305
- rotate(data) {
9306
- const { interaction } = this;
9307
- if (!this.rotateData) {
9308
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9309
- data.path = path;
9310
- this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
9311
- interaction.cancelHover();
9312
- interaction.emit(RotateEvent.START, this.rotateData);
9313
- }
9314
- data.path = this.rotateData.path;
9315
- interaction.emit(RotateEvent.BEFORE_ROTATE, data);
9316
- interaction.emit(RotateEvent.ROTATE, data);
9317
- this.transformEndWait();
9318
- }
9319
- transformEndWait() {
9320
- clearTimeout(this.transformTimer);
9321
- this.transformTimer = setTimeout(() => {
9322
- this.transformEnd();
9323
- }, this.interaction.config.pointer.transformTime);
9324
- }
9325
- transformEnd() {
9326
- this.moveEnd();
9327
- this.zoomEnd();
9328
- this.rotateEnd();
9329
- }
9330
- moveEnd() {
9331
- if (this.moveData) {
9332
- this.interaction.emit(MoveEvent.END, this.moveData);
9333
- this.moveData = null;
9334
- }
9335
- }
9336
- zoomEnd() {
9337
- if (this.zoomData) {
9338
- this.interaction.emit(ZoomEvent.END, this.zoomData);
9339
- this.zoomData = null;
9340
- }
9341
- }
9342
- rotateEnd() {
9343
- if (this.rotateData) {
9344
- this.interaction.emit(RotateEvent.END, this.rotateData);
9345
- this.rotateData = null;
9346
- }
9347
- }
9348
- destroy() {
9349
- this.zoomData = this.moveData = this.rotateData = null;
9350
- }
9351
- }
9352
-
9353
9204
  const InteractionHelper = {
9354
- getMoveEventData(center, move, event) {
9355
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, moveX: move.x, moveY: move.y });
9356
- },
9357
- getRotateEventData(center, angle, event) {
9358
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, rotation: angle });
9359
- },
9360
- getZoomEventData(center, scale, event) {
9361
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, scale });
9362
- },
9363
9205
  getDragEventData(startPoint, lastPoint, event) {
9364
9206
  return Object.assign(Object.assign({}, event), { x: event.x, y: event.y, moveX: event.x - lastPoint.x, moveY: event.y - lastPoint.y, totalX: event.x - startPoint.x, totalY: event.y - startPoint.y });
9365
9207
  },
@@ -9368,18 +9210,14 @@ const InteractionHelper = {
9368
9210
  data });
9369
9211
  },
9370
9212
  getSwipeDirection(angle) {
9371
- if (angle < -45 && angle > -135) {
9213
+ if (angle < -45 && angle > -135)
9372
9214
  return SwipeEvent.UP;
9373
- }
9374
- else if (angle > 45 && angle < 135) {
9215
+ else if (angle > 45 && angle < 135)
9375
9216
  return SwipeEvent.DOWN;
9376
- }
9377
- else if (angle <= 45 && angle >= -45) {
9217
+ else if (angle <= 45 && angle >= -45)
9378
9218
  return SwipeEvent.RIGHT;
9379
- }
9380
- else {
9219
+ else
9381
9220
  return SwipeEvent.LEFT;
9382
- }
9383
9221
  },
9384
9222
  getSwipeEventData(startPoint, lastDragData, event) {
9385
9223
  return Object.assign(Object.assign({}, event), { moveX: lastDragData.moveX, moveY: lastDragData.moveY, totalX: event.x - startPoint.x, totalY: event.y - startPoint.y, type: I.getSwipeDirection(PointHelper.getAngle(startPoint, event)) });
@@ -9452,9 +9290,8 @@ class Dragger {
9452
9290
  interaction.emit(MoveEvent.START, this.dragData);
9453
9291
  }
9454
9292
  }
9455
- if (!this.moving) {
9293
+ if (!this.moving)
9456
9294
  this.dragStart(data, canDrag);
9457
- }
9458
9295
  this.drag(data);
9459
9296
  }
9460
9297
  dragStart(data, canDrag) {
@@ -9532,16 +9369,9 @@ class Dragger {
9532
9369
  dragEnd(data, speed) {
9533
9370
  if (!this.dragging && !this.moving)
9534
9371
  return;
9535
- const { moveX, moveY } = this.dragData;
9536
- if (this.interaction.config.move.dragAnimate && this.canAnimate && this.moving && (Math.abs(moveX) > 1 || Math.abs(moveY) > 1)) {
9537
- data = Object.assign({}, data);
9538
- speed = (speed || (data.pointerType === 'touch' ? 2 : 1)) * 0.9;
9539
- PointHelper.move(data, moveX * speed, moveY * speed);
9540
- this.drag(data);
9541
- this.animate(() => { this.dragEnd(data, 1); });
9542
- }
9543
- else
9544
- this.dragEndReal(data);
9372
+ if (this.checkDragEndAnimate(data, speed))
9373
+ return;
9374
+ this.dragEndReal(data);
9545
9375
  }
9546
9376
  dragEndReal(data) {
9547
9377
  const { interaction, downData, dragData } = this;
@@ -9568,12 +9398,6 @@ class Dragger {
9568
9398
  this.dragReset();
9569
9399
  this.animate(null, 'off');
9570
9400
  }
9571
- animate(func, off) {
9572
- const animateWait = func || this.animateWait;
9573
- if (animateWait)
9574
- this.interaction.target.nextRender(animateWait, null, off);
9575
- this.animateWait = func;
9576
- }
9577
9401
  swipe(data, downData, dragData, endDragData) {
9578
9402
  const { interaction } = this;
9579
9403
  if (PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
@@ -9590,45 +9414,17 @@ class Dragger {
9590
9414
  dragReset() {
9591
9415
  DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9592
9416
  }
9593
- checkDragOut(data) {
9594
- const { interaction } = this;
9595
- this.autoMoveCancel();
9596
- if (this.dragging && !interaction.shrinkCanvasBounds.hitPoint(data))
9597
- this.autoMoveOnDragOut(data);
9598
- }
9599
- autoMoveOnDragOut(data) {
9600
- const { interaction, downData, canDragOut } = this;
9601
- const { autoDistance, dragOut } = interaction.config.move;
9602
- if (!dragOut || !canDragOut || !autoDistance)
9603
- return;
9604
- const bounds = interaction.shrinkCanvasBounds;
9605
- const { x, y } = bounds;
9606
- const right = BoundsHelper.maxX(bounds);
9607
- const bottom = BoundsHelper.maxY(bounds);
9608
- const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
9609
- const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
9610
- let totalX = 0, totalY = 0;
9611
- this.autoMoveTimer = setInterval(() => {
9612
- totalX += moveX;
9613
- totalY += moveY;
9614
- PointHelper.move(downData, moveX, moveY);
9615
- PointHelper.move(this.dragData, moveX, moveY);
9616
- interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
9617
- interaction.pointerMoveReal(data);
9618
- }, 10);
9619
- }
9620
- autoMoveCancel() {
9621
- if (this.autoMoveTimer) {
9622
- clearInterval(this.autoMoveTimer);
9623
- this.autoMoveTimer = 0;
9624
- }
9625
- }
9417
+ checkDragEndAnimate(_data, _speed) { return false; }
9418
+ animate(_func, _off) { }
9419
+ checkDragOut(_data) { }
9420
+ autoMoveOnDragOut(_data) { }
9421
+ autoMoveCancel() { }
9626
9422
  destroy() {
9627
9423
  this.dragReset();
9628
9424
  }
9629
9425
  }
9630
9426
 
9631
- const debug$2 = Debug.get('emit');
9427
+ const debug$3 = Debug.get('emit');
9632
9428
  function emit$1(type, data, path, excludePath) {
9633
9429
  if (!path && !data.path)
9634
9430
  return;
@@ -9658,7 +9454,7 @@ function emit$1(type, data, path, excludePath) {
9658
9454
  }
9659
9455
  }
9660
9456
  catch (e) {
9661
- debug$2.error(e);
9457
+ debug$3.error(e);
9662
9458
  }
9663
9459
  }
9664
9460
  const allowTypes = ['move', 'zoom', 'rotate', 'key'];
@@ -9692,28 +9488,12 @@ function exclude(leaf, excludePath) {
9692
9488
  return excludePath && excludePath.has(leaf);
9693
9489
  }
9694
9490
 
9695
- const MultiTouchHelper = {
9696
- getData(list) {
9697
- const a = list[0];
9698
- const b = list[1];
9699
- const lastCenter = PointHelper.getCenter(a.from, b.from);
9700
- const center = PointHelper.getCenter(a.to, b.to);
9701
- const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
9702
- const lastDistance = PointHelper.getDistance(a.from, b.from);
9703
- const distance = PointHelper.getDistance(a.to, b.to);
9704
- const scale = distance / lastDistance;
9705
- const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
9706
- return { move, scale, angle, center };
9707
- }
9708
- };
9709
-
9710
9491
  const config$1 = {
9711
9492
  wheel: {
9712
9493
  zoomSpeed: 0.5,
9713
9494
  moveSpeed: 0.5,
9714
9495
  rotateSpeed: 0.5,
9715
9496
  delta: { x: 80 / 4, y: 8.0 },
9716
- preventDefault: true
9717
9497
  },
9718
9498
  pointer: {
9719
9499
  hitRadius: 5,
@@ -9724,17 +9504,18 @@ const config$1 = {
9724
9504
  dragHover: true,
9725
9505
  dragDistance: 2,
9726
9506
  swipeDistance: 20,
9727
- preventDefaultMenu: true
9728
9507
  },
9729
9508
  touch: {
9730
- preventDefault: true
9509
+ preventDefault: 'auto'
9731
9510
  },
9732
9511
  multiTouch: {},
9512
+ move: { autoDistance: 2 },
9513
+ zoom: {},
9733
9514
  cursor: true,
9734
9515
  keyEvent: true
9735
9516
  };
9736
9517
 
9737
- const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag, pathHasOutside } = InteractionHelper;
9518
+ const { pathHasEventType, pathCanDrag, pathHasOutside } = InteractionHelper;
9738
9519
  class InteractionBase {
9739
9520
  get dragging() { return this.dragger.dragging; }
9740
9521
  get transforming() { return this.transformer.transforming; }
@@ -9756,7 +9537,7 @@ class InteractionBase {
9756
9537
  this.canvas = canvas;
9757
9538
  this.selector = selector;
9758
9539
  this.defaultPath = new LeafList(target);
9759
- this.transformer = new Transformer(this);
9540
+ this.createTransformer();
9760
9541
  this.dragger = new Dragger(this);
9761
9542
  if (userConfig)
9762
9543
  this.config = DataHelper.default(userConfig, this.config);
@@ -9857,14 +9638,6 @@ class InteractionBase {
9857
9638
  data.isCancel = true;
9858
9639
  this.pointerUp(data);
9859
9640
  }
9860
- multiTouch(data, list) {
9861
- if (this.config.multiTouch.disabled)
9862
- return;
9863
- const { move, angle, scale, center } = MultiTouchHelper.getData(list);
9864
- this.rotate(getRotateEventData(center, angle, data));
9865
- this.zoom(getZoomEventData(center, scale, data));
9866
- this.move(getMoveEventData(center, move, data));
9867
- }
9868
9641
  menu(data) {
9869
9642
  this.findPath(data);
9870
9643
  this.emit(PointerEvent.MENU, data);
@@ -9878,18 +9651,13 @@ class InteractionBase {
9878
9651
  this.waitRightTap = this.waitMenuTap = false;
9879
9652
  }
9880
9653
  }
9881
- move(data) {
9882
- this.transformer.move(data);
9883
- }
9884
- zoom(data) {
9885
- this.transformer.zoom(data);
9886
- }
9887
- rotate(data) {
9888
- this.transformer.rotate(data);
9889
- }
9890
- transformEnd() {
9891
- this.transformer.transformEnd();
9892
- }
9654
+ createTransformer() { }
9655
+ move(_data) { }
9656
+ zoom(_data) { }
9657
+ rotate(_data) { }
9658
+ transformEnd() { }
9659
+ wheel(_data) { }
9660
+ multiTouch(_data, _list) { }
9893
9661
  keyDown(data) {
9894
9662
  if (!this.config.keyEvent)
9895
9663
  return;
@@ -10127,8 +9895,9 @@ class InteractionBase {
10127
9895
  this.longPressed = false;
10128
9896
  }
10129
9897
  __onResize() {
9898
+ const { dragOut } = this.m;
10130
9899
  this.shrinkCanvasBounds = new Bounds(this.canvas.bounds);
10131
- this.shrinkCanvasBounds.spread(-2);
9900
+ this.shrinkCanvasBounds.spread(-(typeof dragOut === 'number' ? dragOut : 2));
10132
9901
  }
10133
9902
  __listenEvents() {
10134
9903
  const { target } = this;
@@ -10148,7 +9917,8 @@ class InteractionBase {
10148
9917
  this.stop();
10149
9918
  this.__removeListenEvents();
10150
9919
  this.dragger.destroy();
10151
- this.transformer.destroy();
9920
+ if (this.transformer)
9921
+ this.transformer.destroy();
10152
9922
  this.downData = this.overPath = this.enterPath = null;
10153
9923
  }
10154
9924
  }
@@ -10874,13 +10644,13 @@ function ignoreRender(ui, value) {
10874
10644
  }
10875
10645
 
10876
10646
  const { get: get$1, scale: scale$2, copy: copy$4 } = MatrixHelper;
10877
- const { ceil, abs: abs$2 } = Math;
10647
+ const { ceil, abs: abs$3 } = Math;
10878
10648
  function createPattern(ui, paint, pixelRatio) {
10879
10649
  let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
10880
10650
  const id = scaleX + '-' + scaleY + '-' + pixelRatio;
10881
10651
  if (paint.patternId !== id && !ui.destroyed) {
10882
- scaleX = abs$2(scaleX);
10883
- scaleY = abs$2(scaleY);
10652
+ scaleX = abs$3(scaleX);
10653
+ scaleY = abs$3(scaleY);
10884
10654
  const { image, data } = paint;
10885
10655
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
10886
10656
  if (sx) {
@@ -10936,7 +10706,7 @@ function createPattern(ui, paint, pixelRatio) {
10936
10706
  }
10937
10707
  }
10938
10708
 
10939
- const { abs: abs$1 } = Math;
10709
+ const { abs: abs$2 } = Math;
10940
10710
  function checkImage(ui, canvas, paint, allowPaint) {
10941
10711
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
10942
10712
  const { pixelRatio } = canvas;
@@ -10948,8 +10718,8 @@ function checkImage(ui, canvas, paint, allowPaint) {
10948
10718
  if (allowPaint) {
10949
10719
  if (!data.repeat) {
10950
10720
  let { width, height } = data;
10951
- width *= abs$1(scaleX) * pixelRatio;
10952
- height *= abs$1(scaleY) * pixelRatio;
10721
+ width *= abs$2(scaleX) * pixelRatio;
10722
+ height *= abs$2(scaleY) * pixelRatio;
10953
10723
  if (data.scaleX) {
10954
10724
  width *= data.scaleX;
10955
10725
  height *= data.scaleY;
@@ -11428,15 +11198,15 @@ const { trimRight } = TextRowHelper;
11428
11198
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11429
11199
  let word, row, wordWidth, rowWidth, realWidth;
11430
11200
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11431
- let textDrawData, rows = [], bounds$1, findMaxWidth;
11201
+ let textDrawData, rows = [], bounds$3, findMaxWidth;
11432
11202
  function createRows(drawData, content, style) {
11433
11203
  textDrawData = drawData;
11434
11204
  rows = drawData.rows;
11435
- bounds$1 = drawData.bounds;
11436
- findMaxWidth = !bounds$1.width && !style.autoSizeAlign;
11205
+ bounds$3 = drawData.bounds;
11206
+ findMaxWidth = !bounds$3.width && !style.autoSizeAlign;
11437
11207
  const { __letterSpacing, paraIndent, textCase } = style;
11438
11208
  const { canvas } = Platform;
11439
- const { width, height } = bounds$1;
11209
+ const { width, height } = bounds$3;
11440
11210
  const charMode = width || height || __letterSpacing || (textCase !== 'none');
11441
11211
  if (charMode) {
11442
11212
  const wrap = style.textWrap !== 'none';
@@ -11550,7 +11320,7 @@ function addRow() {
11550
11320
  startCharSize = 0;
11551
11321
  }
11552
11322
  row.width = rowWidth;
11553
- if (bounds$1.width)
11323
+ if (bounds$3.width)
11554
11324
  trimRight(row);
11555
11325
  else if (findMaxWidth)
11556
11326
  setMaxWidth();
@@ -11987,7 +11757,7 @@ function checkLazy(leaf) {
11987
11757
  }
11988
11758
 
11989
11759
  const canvas = LeaferCanvasBase.prototype;
11990
- const debug$1 = Debug.get('@leafer-ui/export');
11760
+ const debug$2 = Debug.get('@leafer-ui/export');
11991
11761
  canvas.export = function (filename, options) {
11992
11762
  const { quality, blob } = FileHelper.getExportOptions(options);
11993
11763
  if (filename.includes('.'))
@@ -12002,7 +11772,7 @@ canvas.toBlob = function (type, quality) {
12002
11772
  Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
12003
11773
  resolve(blob);
12004
11774
  }).catch((e) => {
12005
- debug$1.error(e);
11775
+ debug$2.error(e);
12006
11776
  resolve(null);
12007
11777
  });
12008
11778
  });
@@ -12015,7 +11785,7 @@ canvas.saveAs = function (filename, quality) {
12015
11785
  Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
12016
11786
  resolve(true);
12017
11787
  }).catch((e) => {
12018
- debug$1.error(e);
11788
+ debug$2.error(e);
12019
11789
  resolve(false);
12020
11790
  });
12021
11791
  });
@@ -12305,9 +12075,12 @@ function targetAttr(fn) {
12305
12075
  };
12306
12076
  }
12307
12077
 
12308
- const matrix = MatrixHelper.get();
12309
- const { abs } = Math;
12078
+ const { abs: abs$1 } = Math;
12310
12079
  const { copy: copy$2, scale: scale$1 } = MatrixHelper;
12080
+ const { setListWithFn } = BoundsHelper;
12081
+ const { worldBounds } = LeafBoundsHelper;
12082
+ const matrix = getMatrixData();
12083
+ const bounds$2 = getBoundsData();
12311
12084
  class Stroker extends UI {
12312
12085
  constructor() {
12313
12086
  super();
@@ -12318,6 +12091,17 @@ class Stroker extends UI {
12318
12091
  setTarget(target, style) {
12319
12092
  this.set(style);
12320
12093
  this.target = target;
12094
+ this.update();
12095
+ }
12096
+ update() {
12097
+ const { list } = this;
12098
+ if (list.length) {
12099
+ setListWithFn(bounds$2, list, worldBounds);
12100
+ this.set(bounds$2);
12101
+ }
12102
+ else {
12103
+ this.width = this.height = 1;
12104
+ }
12321
12105
  }
12322
12106
  __draw(canvas, options) {
12323
12107
  const { list } = this;
@@ -12327,8 +12111,8 @@ class Stroker extends UI {
12327
12111
  for (let i = 0; i < list.length; i++) {
12328
12112
  leaf = list[i];
12329
12113
  const { worldTransform, worldRenderBounds } = leaf;
12330
- if (bounds && bounds.hit(worldRenderBounds, options.matrix)) {
12331
- const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
12114
+ if (!bounds || bounds.hit(worldRenderBounds, options.matrix)) {
12115
+ const aScaleX = abs$1(worldTransform.scaleX), aScaleY = abs$1(worldTransform.scaleY);
12332
12116
  if (aScaleX !== aScaleY) {
12333
12117
  copy$2(matrix, worldTransform);
12334
12118
  scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
@@ -12345,7 +12129,7 @@ class Stroker extends UI {
12345
12129
  leaf.__drawPath(canvas);
12346
12130
  else
12347
12131
  leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12348
- data.strokeWidth = strokeWidth / abs(worldTransform.scaleX);
12132
+ data.strokeWidth = strokeWidth / abs$1(worldTransform.scaleX);
12349
12133
  }
12350
12134
  if (stroke)
12351
12135
  typeof stroke === 'string' ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
@@ -12367,7 +12151,6 @@ __decorate([
12367
12151
  function onTarget$1(stroker) {
12368
12152
  const value = stroker.target;
12369
12153
  stroker.list = value ? (value instanceof Array ? value : [value]) : [];
12370
- stroker.forceUpdate();
12371
12154
  }
12372
12155
 
12373
12156
  class SelectArea extends Group {
@@ -12452,8 +12235,8 @@ class EditSelect extends Group {
12452
12235
  }
12453
12236
  }
12454
12237
  update() {
12455
- if (this.targetStroker.target)
12456
- this.targetStroker.forceUpdate();
12238
+ this.hoverStroker.update();
12239
+ this.targetStroker.update();
12457
12240
  }
12458
12241
  onPointerMove(e) {
12459
12242
  const { app, editor } = this;
@@ -13271,11 +13054,11 @@ const config = {
13271
13054
  skewable: true
13272
13055
  };
13273
13056
 
13274
- const bounds = new Bounds();
13057
+ const bounds$1 = new Bounds();
13275
13058
  function simulate(editor) {
13276
13059
  const { simulateTarget, list } = editor;
13277
13060
  const { zoomLayer } = list[0].leafer.zoomLayer;
13278
- simulateTarget.safeChange(() => simulateTarget.reset(bounds.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page')).get()));
13061
+ simulateTarget.safeChange(() => simulateTarget.reset(bounds$1.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page')).get()));
13279
13062
  zoomLayer.add(simulateTarget);
13280
13063
  }
13281
13064
 
@@ -13371,7 +13154,7 @@ const EditorHelper = {
13371
13154
  }
13372
13155
  };
13373
13156
 
13374
- const debug = Debug.get('EditToolCreator');
13157
+ const debug$1 = Debug.get('EditToolCreator');
13375
13158
  function registerEditTool() {
13376
13159
  return (target) => {
13377
13160
  EditToolCreator.register(target);
@@ -13382,14 +13165,14 @@ const EditToolCreator = {
13382
13165
  list: {},
13383
13166
  register(EditTool) {
13384
13167
  const { tag } = EditTool.prototype;
13385
- list[tag] && debug.repeat(tag);
13386
- list[tag] = EditTool;
13168
+ list$1[tag] && debug$1.repeat(tag);
13169
+ list$1[tag] = EditTool;
13387
13170
  },
13388
13171
  get(tag, editor) {
13389
- return new list[tag](editor);
13172
+ return new list$1[tag](editor);
13390
13173
  }
13391
13174
  };
13392
- const { list } = EditToolCreator;
13175
+ const { list: list$1 } = EditToolCreator;
13393
13176
 
13394
13177
  class InnerEditorEvent extends EditorEvent {
13395
13178
  constructor(type, data) {
@@ -14106,6 +13889,349 @@ UI.setEditInner = function (editorName) {
14106
13889
  });
14107
13890
  };
14108
13891
 
13892
+ function addViewport(leafer, mergeConfig, custom) {
13893
+ addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);
13894
+ if (leafer.isApp || custom)
13895
+ return;
13896
+ leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => {
13897
+ leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
13898
+ }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
13899
+ const { zoomLayer } = leafer;
13900
+ const changeScale = leafer.getValidScale(e.scale);
13901
+ if (changeScale !== 1) {
13902
+ PointHelper.scaleOf(zoomLayer, e, changeScale);
13903
+ zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
13904
+ }
13905
+ }));
13906
+ }
13907
+ function addViewportConfig(leafer, mergeConfig) {
13908
+ if (mergeConfig)
13909
+ DataHelper.assign(leafer.config, mergeConfig);
13910
+ DataHelper.assign(leafer.config, {
13911
+ wheel: { preventDefault: true },
13912
+ touch: { preventDefault: true },
13913
+ pointer: { preventDefaultMenu: true }
13914
+ }, leafer.userConfig);
13915
+ }
13916
+
13917
+ function custom(leafer) {
13918
+ addViewport(leafer, null, true);
13919
+ }
13920
+
13921
+ function design(leafer) {
13922
+ addViewport(leafer, {
13923
+ zoom: {
13924
+ min: 0.01,
13925
+ max: 256
13926
+ },
13927
+ move: {
13928
+ holdSpaceKey: true,
13929
+ holdMiddleKey: true,
13930
+ }
13931
+ });
13932
+ }
13933
+
13934
+ function document$1(leafer) {
13935
+ addViewport(leafer, {
13936
+ zoom: { min: 1 },
13937
+ move: { scroll: 'limit' }
13938
+ });
13939
+ }
13940
+
13941
+ const debug = Debug.get('LeaferTypeCreator');
13942
+ const LeaferTypeCreator = {
13943
+ list: {},
13944
+ register(name, fn) {
13945
+ list[name] && debug.repeat(name);
13946
+ list[name] = fn;
13947
+ },
13948
+ run(name, leafer) {
13949
+ const fn = list[name];
13950
+ fn && fn(leafer);
13951
+ }
13952
+ };
13953
+ const { list, register } = LeaferTypeCreator;
13954
+ register('viewport', addViewport);
13955
+ register('custom', custom);
13956
+ register('design', design);
13957
+ register('document', document$1);
13958
+
13959
+ const MultiTouchHelper = {
13960
+ getData(list) {
13961
+ const a = list[0], b = list[1];
13962
+ const lastCenter = PointHelper.getCenter(a.from, b.from);
13963
+ const center = PointHelper.getCenter(a.to, b.to);
13964
+ const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
13965
+ const lastDistance = PointHelper.getDistance(a.from, b.from);
13966
+ const distance = PointHelper.getDistance(a.to, b.to);
13967
+ const scale = distance / lastDistance;
13968
+ const rotation = PointHelper.getRotation(a.from, b.from, a.to, b.to);
13969
+ return { move, scale, rotation, center };
13970
+ }
13971
+ };
13972
+
13973
+ const WheelEventHelper = {
13974
+ getMove(event, config) {
13975
+ let { moveSpeed } = config;
13976
+ let { deltaX, deltaY } = event;
13977
+ if (event.shiftKey && !deltaX) {
13978
+ deltaX = deltaY;
13979
+ deltaY = 0;
13980
+ }
13981
+ if (deltaX > 50)
13982
+ deltaX = Math.max(50, deltaX / 3);
13983
+ if (deltaY > 50)
13984
+ deltaY = Math.max(50, deltaY / 3);
13985
+ return { x: -deltaX * moveSpeed * 2, y: -deltaY * moveSpeed * 2 };
13986
+ },
13987
+ getScale(event, config) {
13988
+ let zoom;
13989
+ let scale = 1;
13990
+ let { zoomMode, zoomSpeed } = config;
13991
+ const delta = event.deltaY || event.deltaX;
13992
+ if (zoomMode) {
13993
+ zoom = (zoomMode === 'mouse') ? true : (!event.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta));
13994
+ if (event.shiftKey || event.metaKey || event.ctrlKey)
13995
+ zoom = true;
13996
+ }
13997
+ else {
13998
+ zoom = !event.shiftKey && (event.metaKey || event.ctrlKey);
13999
+ }
14000
+ if (zoom) {
14001
+ zoomSpeed = MathHelper.within(zoomSpeed, 0, 1);
14002
+ const min = event.deltaY ? config.delta.y : config.delta.x;
14003
+ scale = 1 - delta / (min * 4) * zoomSpeed;
14004
+ if (scale < 0.5)
14005
+ scale = 0.5;
14006
+ if (scale >= 1.5)
14007
+ scale = 1.5;
14008
+ }
14009
+ return scale;
14010
+ }
14011
+ };
14012
+
14013
+ class Transformer {
14014
+ get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
14015
+ constructor(interaction) {
14016
+ this.interaction = interaction;
14017
+ }
14018
+ move(data) {
14019
+ const { interaction } = this;
14020
+ if (!data.moveType)
14021
+ data.moveType = 'move';
14022
+ if (!this.moveData) {
14023
+ this.setPath(data);
14024
+ this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
14025
+ interaction.emit(MoveEvent.START, this.moveData);
14026
+ }
14027
+ data.path = this.moveData.path;
14028
+ interaction.emit(MoveEvent.BEFORE_MOVE, data);
14029
+ interaction.emit(MoveEvent.MOVE, data);
14030
+ this.transformEndWait();
14031
+ }
14032
+ zoom(data) {
14033
+ const { interaction } = this;
14034
+ if (!this.zoomData) {
14035
+ this.setPath(data);
14036
+ this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
14037
+ interaction.emit(ZoomEvent.START, this.zoomData);
14038
+ }
14039
+ data.path = this.zoomData.path;
14040
+ interaction.emit(ZoomEvent.BEFORE_ZOOM, data);
14041
+ interaction.emit(ZoomEvent.ZOOM, data);
14042
+ this.transformEndWait();
14043
+ }
14044
+ rotate(data) {
14045
+ const { interaction } = this;
14046
+ if (!this.rotateData) {
14047
+ this.setPath(data);
14048
+ this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
14049
+ interaction.emit(RotateEvent.START, this.rotateData);
14050
+ }
14051
+ data.path = this.rotateData.path;
14052
+ interaction.emit(RotateEvent.BEFORE_ROTATE, data);
14053
+ interaction.emit(RotateEvent.ROTATE, data);
14054
+ this.transformEndWait();
14055
+ }
14056
+ setPath(data) {
14057
+ const { interaction } = this;
14058
+ const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
14059
+ data.path = path;
14060
+ interaction.cancelHover();
14061
+ }
14062
+ transformEndWait() {
14063
+ clearTimeout(this.transformTimer);
14064
+ this.transformTimer = setTimeout(() => {
14065
+ this.transformEnd();
14066
+ }, this.interaction.p.transformTime);
14067
+ }
14068
+ transformEnd() {
14069
+ const { interaction, moveData, zoomData, rotateData } = this;
14070
+ if (moveData)
14071
+ interaction.emit(MoveEvent.END, moveData);
14072
+ if (zoomData)
14073
+ interaction.emit(ZoomEvent.END, zoomData);
14074
+ if (rotateData)
14075
+ interaction.emit(RotateEvent.END, rotateData);
14076
+ this.reset();
14077
+ }
14078
+ reset() {
14079
+ this.zoomData = this.moveData = this.rotateData = null;
14080
+ }
14081
+ destroy() {
14082
+ this.reset();
14083
+ }
14084
+ }
14085
+
14086
+ const leafer = Leafer.prototype;
14087
+ const bounds = new Bounds();
14088
+ leafer.initType = function (type) {
14089
+ LeaferTypeCreator.run(type, this);
14090
+ };
14091
+ leafer.getValidMove = function (moveX, moveY) {
14092
+ const { scroll, disabled } = this.app.config.move;
14093
+ if (scroll) {
14094
+ const type = scroll === true ? '' : scroll;
14095
+ if (type.includes('x'))
14096
+ moveX = moveX || moveY, moveY = 0;
14097
+ else if (type.includes('y'))
14098
+ moveY = moveY || moveX, moveX = 0;
14099
+ else
14100
+ Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
14101
+ if (type.includes('limit')) {
14102
+ const { x, y, width, height } = bounds.set(this.__world).addPoint(this.zoomLayer);
14103
+ const right = x + width - this.width, bottom = y + height - this.height;
14104
+ if (x >= 0 && right <= 0)
14105
+ moveX = 0;
14106
+ else if (moveX > 0) {
14107
+ if (x + moveX > 0)
14108
+ moveX = -x;
14109
+ }
14110
+ else if (moveX < 0 && right + moveX < 0)
14111
+ moveX = -right;
14112
+ if (y >= 0 && bottom <= 0)
14113
+ moveY = 0;
14114
+ else if (moveY > 0) {
14115
+ if (y + moveY > 0)
14116
+ moveY = -y;
14117
+ }
14118
+ else if (moveY < 0 && bottom + moveY < 0)
14119
+ moveY = -bottom;
14120
+ }
14121
+ }
14122
+ return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
14123
+ };
14124
+ leafer.getValidScale = function (changeScale) {
14125
+ const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
14126
+ if (min && absScale < min)
14127
+ changeScale = min / scaleX;
14128
+ else if (max && absScale > max)
14129
+ changeScale = max / scaleX;
14130
+ return disabled ? 1 : MathHelper.float(changeScale);
14131
+ };
14132
+
14133
+ function getMoveEventData(move, event) {
14134
+ return Object.assign(Object.assign({}, event), { moveX: move.x, moveY: move.y });
14135
+ }
14136
+ function getRotateEventData(rotation, event) {
14137
+ return Object.assign(Object.assign({}, event), { rotation });
14138
+ }
14139
+ function getZoomEventData(scale, event) {
14140
+ return Object.assign(Object.assign({}, event), { scale });
14141
+ }
14142
+ const interaction = InteractionBase.prototype;
14143
+ interaction.createTransformer = function () {
14144
+ this.transformer = new Transformer(this);
14145
+ };
14146
+ interaction.move = function (data) {
14147
+ this.transformer.move(data);
14148
+ };
14149
+ interaction.zoom = function (data) {
14150
+ this.transformer.zoom(data);
14151
+ };
14152
+ interaction.rotate = function (data) {
14153
+ this.transformer.rotate(data);
14154
+ };
14155
+ interaction.transformEnd = function () {
14156
+ this.transformer.transformEnd();
14157
+ };
14158
+ interaction.wheel = function (data) {
14159
+ const { wheel } = this.config;
14160
+ if (wheel.disabled)
14161
+ return;
14162
+ const scale = wheel.getScale ? wheel.getScale(data, wheel) : WheelEventHelper.getScale(data, wheel);
14163
+ scale !== 1 ? this.zoom(getZoomEventData(scale, data)) : this.move(getMoveEventData(wheel.getMove ? wheel.getMove(data, wheel) : WheelEventHelper.getMove(data, wheel), data));
14164
+ };
14165
+ interaction.multiTouch = function (data, list) {
14166
+ if (this.config.multiTouch.disabled)
14167
+ return;
14168
+ const { move, rotation, scale, center } = MultiTouchHelper.getData(list);
14169
+ Object.assign(data, center);
14170
+ this.rotate(getRotateEventData(rotation, data));
14171
+ this.zoom(getZoomEventData(scale, data));
14172
+ this.move(getMoveEventData(move, data));
14173
+ };
14174
+
14175
+ const dragger = Dragger.prototype;
14176
+ const { abs } = Math;
14177
+ dragger.checkDragEndAnimate = function (data, speed) {
14178
+ const { moveX, moveY } = this.dragData;
14179
+ const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1;
14180
+ const dragAnimate = this.interaction.m.dragAnimate && this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove);
14181
+ if (dragAnimate) {
14182
+ const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70;
14183
+ speed = speed ? 0.95 : inertia;
14184
+ if (absMoveX * speed > maxMove)
14185
+ speed = maxMove / absMoveX;
14186
+ else if (absMoveY * speed > maxMove)
14187
+ speed = maxMove / absMoveY;
14188
+ data = Object.assign({}, data);
14189
+ PointHelper.move(data, moveX * speed, moveY * speed);
14190
+ this.drag(data);
14191
+ this.animate(() => { this.dragEnd(data, 1); });
14192
+ }
14193
+ return dragAnimate;
14194
+ };
14195
+ dragger.animate = function (func, off) {
14196
+ const animateWait = func || this.animateWait;
14197
+ if (animateWait)
14198
+ this.interaction.target.nextRender(animateWait, null, off);
14199
+ this.animateWait = func;
14200
+ };
14201
+ dragger.checkDragOut = function (data) {
14202
+ const { interaction } = this;
14203
+ this.autoMoveCancel();
14204
+ if (this.dragging && !interaction.shrinkCanvasBounds.hitPoint(data))
14205
+ this.autoMoveOnDragOut(data);
14206
+ };
14207
+ dragger.autoMoveOnDragOut = function (data) {
14208
+ const { interaction, downData, canDragOut } = this;
14209
+ const { autoDistance, dragOut } = interaction.m;
14210
+ if (!dragOut || !canDragOut || !autoDistance)
14211
+ return;
14212
+ const bounds = interaction.shrinkCanvasBounds;
14213
+ const { x, y } = bounds;
14214
+ const right = BoundsHelper.maxX(bounds);
14215
+ const bottom = BoundsHelper.maxY(bounds);
14216
+ const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
14217
+ const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
14218
+ let totalX = 0, totalY = 0;
14219
+ this.autoMoveTimer = setInterval(() => {
14220
+ totalX += moveX;
14221
+ totalY += moveY;
14222
+ PointHelper.move(downData, moveX, moveY);
14223
+ PointHelper.move(this.dragData, moveX, moveY);
14224
+ interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
14225
+ interaction.pointerMoveReal(data);
14226
+ }, 10);
14227
+ };
14228
+ dragger.autoMoveCancel = function () {
14229
+ if (this.autoMoveTimer) {
14230
+ clearInterval(this.autoMoveTimer);
14231
+ this.autoMoveTimer = 0;
14232
+ }
14233
+ };
14234
+
14109
14235
  function getZoomScale(scaleX, type) {
14110
14236
  let scale = 1;
14111
14237
  const out = type === 'out', absScale = Math.abs(scaleX);
@@ -14135,7 +14261,7 @@ function getFixBounds(bounds, scaleBounds) {
14135
14261
 
14136
14262
  Leafer.prototype.zoom = function (zoomType, padding, fixed) {
14137
14263
  const { zoomLayer } = this;
14138
- const limitBounds = this.canvas.bounds.clone().shrink(padding ? padding : 30), bounds = new Bounds();
14264
+ const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
14139
14265
  const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
14140
14266
  let changeScale;
14141
14267
  const { scaleX } = this.__;
@@ -14829,4 +14955,4 @@ HTMLText = __decorate([
14829
14955
  registerUI()
14830
14956
  ], HTMLText);
14831
14957
 
14832
- export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, 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, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, 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, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, needPlugin, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
14958
+ export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, 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, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, 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, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, 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, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, needPlugin, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };