leafer-ui 1.0.10 → 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.
@@ -108,7 +108,7 @@ const MathHelper = {
108
108
  return rotation - oldRotation;
109
109
  },
110
110
  float(num, maxLength) {
111
- const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
111
+ const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
112
112
  num = round(num * a) / a;
113
113
  return num === -0 ? 0 : num;
114
114
  },
@@ -1411,14 +1411,14 @@ const UICreator = {
1411
1411
  list: {},
1412
1412
  register(UI) {
1413
1413
  const { __tag: tag } = UI.prototype;
1414
- if (list$2[tag])
1414
+ if (list$1[tag])
1415
1415
  debug$f.repeat(tag);
1416
- list$2[tag] = UI;
1416
+ list$1[tag] = UI;
1417
1417
  },
1418
1418
  get(tag, data, x, y, width, height) {
1419
- if (!list$2[tag])
1419
+ if (!list$1[tag])
1420
1420
  debug$f.error('not register ' + tag);
1421
- const ui = new list$2[tag](data);
1421
+ const ui = new list$1[tag](data);
1422
1422
  if (x !== undefined) {
1423
1423
  ui.x = x;
1424
1424
  if (y)
@@ -1431,7 +1431,7 @@ const UICreator = {
1431
1431
  return ui;
1432
1432
  }
1433
1433
  };
1434
- const { list: list$2 } = UICreator;
1434
+ const { list: list$1 } = UICreator;
1435
1435
 
1436
1436
  const debug$e = Debug.get('EventCreator');
1437
1437
  const EventCreator = {
@@ -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) {
@@ -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();
@@ -4048,11 +4063,11 @@ function defineDataProcessor(target, key, defaultValue) {
4048
4063
  }
4049
4064
 
4050
4065
  const debug$9 = new Debug('rewrite');
4051
- const list$1 = [];
4066
+ const list = [];
4052
4067
  const excludeNames = ['destroy', 'constructor'];
4053
4068
  function rewrite(method) {
4054
4069
  return (target, key) => {
4055
- list$1.push({ name: target.constructor.name + '.' + key, run: () => { target[key] = method; } });
4070
+ list.push({ name: target.constructor.name + '.' + key, run: () => { target[key] = method; } });
4056
4071
  };
4057
4072
  }
4058
4073
  function rewriteAble() {
@@ -4061,13 +4076,13 @@ function rewriteAble() {
4061
4076
  };
4062
4077
  }
4063
4078
  function doRewrite(error) {
4064
- if (list$1.length) {
4065
- list$1.forEach(item => {
4079
+ if (list.length) {
4080
+ list.forEach(item => {
4066
4081
  if (error)
4067
4082
  debug$9.error(item.name, '需在Class上装饰@rewriteAble()');
4068
4083
  item.run();
4069
4084
  });
4070
- list$1.length = 0;
4085
+ list.length = 0;
4071
4086
  }
4072
4087
  }
4073
4088
  setTimeout(() => doRewrite(true));
@@ -4165,20 +4180,17 @@ const LeafHelper = {
4165
4180
  }
4166
4181
  return true;
4167
4182
  },
4168
- moveWorld(t, x, y = 0, isInnerPoint) {
4183
+ moveWorld(t, x, y = 0, isInnerPoint, transition) {
4169
4184
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4170
4185
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
4171
- L.moveLocal(t, local.x, local.y);
4186
+ L.moveLocal(t, local.x, local.y, transition);
4172
4187
  },
4173
- moveLocal(t, x, y = 0) {
4174
- if (typeof x === 'object') {
4175
- t.x += x.x;
4176
- t.y += x.y;
4177
- }
4178
- else {
4179
- t.x += x;
4180
- t.y += y;
4181
- }
4188
+ moveLocal(t, x, y = 0, transition) {
4189
+ if (typeof x === 'object')
4190
+ y = x.y, x = x.x;
4191
+ x += t.x;
4192
+ y += t.y;
4193
+ transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4182
4194
  },
4183
4195
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4184
4196
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -5437,8 +5449,8 @@ let Leaf = class Leaf {
5437
5449
  canvas.clearRect(r.x, r.y, r.width, r.height);
5438
5450
  canvas.restore();
5439
5451
  }
5440
- __updateMask(value) {
5441
- 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);
5442
5454
  }
5443
5455
  __renderMask(_canvas, _options) { }
5444
5456
  __getNowWorld(options) {
@@ -5558,11 +5570,11 @@ let Leaf = class Leaf {
5558
5570
  transform(matrix, resize) {
5559
5571
  transform(this, matrix, resize);
5560
5572
  }
5561
- move(x, y) {
5562
- moveLocal(this, x, y);
5573
+ move(x, y, transition) {
5574
+ moveLocal(this, x, y, transition);
5563
5575
  }
5564
- moveInner(x, y) {
5565
- moveWorld(this, x, y, true);
5576
+ moveInner(x, y, transition) {
5577
+ moveWorld(this, x, y, true, transition);
5566
5578
  }
5567
5579
  scaleOf(origin, scaleX, scaleY, resize) {
5568
5580
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
@@ -5576,8 +5588,8 @@ let Leaf = class Leaf {
5576
5588
  transformWorld(worldTransform, resize) {
5577
5589
  transformWorld(this, worldTransform, resize);
5578
5590
  }
5579
- moveWorld(x, y) {
5580
- moveWorld(this, x, y);
5591
+ moveWorld(x, y, transition) {
5592
+ moveWorld(this, x, y, false, transition);
5581
5593
  }
5582
5594
  scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5583
5595
  zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
@@ -5681,6 +5693,7 @@ Leaf = __decorate([
5681
5693
  const { setListWithFn } = BoundsHelper;
5682
5694
  const { sort } = BranchHelper;
5683
5695
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5696
+ const debug$7 = new Debug('Branch');
5684
5697
  let Branch = class Branch extends Leaf {
5685
5698
  __updateStrokeSpread() {
5686
5699
  const { children } = this;
@@ -5721,8 +5734,8 @@ let Branch = class Branch extends Leaf {
5721
5734
  }
5722
5735
  }
5723
5736
  add(child, index) {
5724
- if (child === this)
5725
- return;
5737
+ if (child === this || child.destroyed)
5738
+ return debug$7.warn('add self or destroyed');
5726
5739
  const noIndex = index === undefined;
5727
5740
  if (!child.__) {
5728
5741
  if (child instanceof Array)
@@ -5736,8 +5749,9 @@ let Branch = class Branch extends Leaf {
5736
5749
  noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
5737
5750
  if (child.isBranch)
5738
5751
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5739
- child.__layout.boxChanged || child.__layout.boxChange();
5740
- child.__layout.matrixChanged || child.__layout.matrixChange();
5752
+ const childLayout = child.__layout;
5753
+ childLayout.boxChanged || childLayout.boxChange();
5754
+ childLayout.matrixChanged || childLayout.matrixChange();
5741
5755
  if (child.__bubbleMap)
5742
5756
  child.__emitLifeEvent(ChildEvent.ADD);
5743
5757
  if (this.leafer) {
@@ -5975,9 +5989,9 @@ class LeafLevelList {
5975
5989
  }
5976
5990
  }
5977
5991
 
5978
- const version = "1.0.10";
5992
+ const version = "1.1.1";
5979
5993
 
5980
- const debug$7 = Debug.get('LeaferCanvas');
5994
+ const debug$6 = Debug.get('LeaferCanvas');
5981
5995
  class LeaferCanvas extends LeaferCanvasBase {
5982
5996
  set zIndex(zIndex) {
5983
5997
  const { style } = this.view;
@@ -6049,7 +6063,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6049
6063
  }
6050
6064
  }
6051
6065
  else {
6052
- debug$7.error(`no id: ${inputView}`);
6066
+ debug$6.error(`no id: ${inputView}`);
6053
6067
  this.__createView();
6054
6068
  }
6055
6069
  }
@@ -6086,7 +6100,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6086
6100
  }
6087
6101
  else {
6088
6102
  this.checkAutoBounds(this.view);
6089
- debug$7.warn('no parent');
6103
+ debug$6.warn('no parent');
6090
6104
  }
6091
6105
  }
6092
6106
  catch (_a) {
@@ -6422,7 +6436,7 @@ class LayoutBlockData {
6422
6436
  }
6423
6437
 
6424
6438
  const { updateAllMatrix, updateAllChange } = LeafHelper;
6425
- const debug$6 = Debug.get('Layouter');
6439
+ const debug$5 = Debug.get('Layouter');
6426
6440
  class Layouter {
6427
6441
  constructor(target, userConfig) {
6428
6442
  this.totalTimes = 0;
@@ -6457,7 +6471,7 @@ class Layouter {
6457
6471
  target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
6458
6472
  }
6459
6473
  catch (e) {
6460
- debug$6.error(e);
6474
+ debug$5.error(e);
6461
6475
  }
6462
6476
  this.layoutedBlocks = null;
6463
6477
  }
@@ -6471,9 +6485,9 @@ class Layouter {
6471
6485
  }
6472
6486
  layoutOnce() {
6473
6487
  if (this.layouting)
6474
- return debug$6.warn('layouting');
6488
+ return debug$5.warn('layouting');
6475
6489
  if (this.times > 3)
6476
- return debug$6.warn('layout max times');
6490
+ return debug$5.warn('layout max times');
6477
6491
  this.times++;
6478
6492
  this.totalTimes++;
6479
6493
  this.layouting = true;
@@ -6577,7 +6591,7 @@ class Layouter {
6577
6591
  }
6578
6592
  }
6579
6593
 
6580
- const debug$5 = Debug.get('Renderer');
6594
+ const debug$4 = Debug.get('Renderer');
6581
6595
  class Renderer {
6582
6596
  get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
6583
6597
  constructor(target, canvas, userConfig) {
@@ -6593,29 +6607,29 @@ class Renderer {
6593
6607
  if (userConfig)
6594
6608
  this.config = DataHelper.default(userConfig, this.config);
6595
6609
  this.__listenEvents();
6596
- this.__requestRender();
6597
6610
  }
6598
6611
  start() {
6599
6612
  this.running = true;
6613
+ this.update(false);
6600
6614
  }
6601
6615
  stop() {
6602
6616
  this.running = false;
6603
6617
  }
6604
- update() {
6605
- this.changed = true;
6618
+ update(change = true) {
6619
+ if (!this.changed)
6620
+ this.changed = change;
6621
+ this.__requestRender();
6606
6622
  }
6607
6623
  requestLayout() {
6608
6624
  this.target.emit(LayoutEvent.REQUEST);
6609
6625
  }
6610
6626
  render(callback) {
6611
- if (!(this.running && this.canvas.view)) {
6612
- this.changed = true;
6613
- return;
6614
- }
6627
+ if (!(this.running && this.canvas.view))
6628
+ return this.update();
6615
6629
  const { target } = this;
6616
6630
  this.times = 0;
6617
6631
  this.totalBounds = new Bounds();
6618
- debug$5.log(target.innerName, '--->');
6632
+ debug$4.log(target.innerName, '--->');
6619
6633
  try {
6620
6634
  if (!target.isApp)
6621
6635
  target.app.emit(RenderEvent.CHILD_START, target);
@@ -6626,9 +6640,9 @@ class Renderer {
6626
6640
  }
6627
6641
  catch (e) {
6628
6642
  this.rendering = false;
6629
- debug$5.error(e);
6643
+ debug$4.error(e);
6630
6644
  }
6631
- debug$5.log('-------------|');
6645
+ debug$4.log('-------------|');
6632
6646
  }
6633
6647
  renderAgain() {
6634
6648
  if (this.rendering) {
@@ -6640,9 +6654,9 @@ class Renderer {
6640
6654
  }
6641
6655
  renderOnce(callback) {
6642
6656
  if (this.rendering)
6643
- return debug$5.warn('rendering');
6657
+ return debug$4.warn('rendering');
6644
6658
  if (this.times > 3)
6645
- return debug$5.warn('render max times');
6659
+ return debug$4.warn('render max times');
6646
6660
  this.times++;
6647
6661
  this.totalTimes++;
6648
6662
  this.rendering = true;
@@ -6679,7 +6693,7 @@ class Renderer {
6679
6693
  partRender() {
6680
6694
  const { canvas, updateBlocks: list } = this;
6681
6695
  if (!list)
6682
- return debug$5.warn('PartRender: need update attr');
6696
+ return debug$4.warn('PartRender: need update attr');
6683
6697
  this.mergeBlocks();
6684
6698
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6685
6699
  this.clipRender(block); });
@@ -6745,16 +6759,17 @@ class Renderer {
6745
6759
  }
6746
6760
  }
6747
6761
  __requestRender() {
6748
- const startTime = Date.now();
6762
+ if (this.requestTime)
6763
+ return;
6764
+ const requestTime = this.requestTime = Date.now();
6749
6765
  Platform.requestRender(() => {
6750
- this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
6766
+ this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
6767
+ this.requestTime = 0;
6751
6768
  if (this.running) {
6752
6769
  if (this.changed && this.canvas.view)
6753
6770
  this.render();
6754
6771
  this.target.emit(RenderEvent.NEXT);
6755
6772
  }
6756
- if (this.target)
6757
- this.__requestRender();
6758
6773
  });
6759
6774
  }
6760
6775
  __onResize(e) {
@@ -6770,7 +6785,7 @@ class Renderer {
6770
6785
  }
6771
6786
  }
6772
6787
  this.addBlock(new Bounds(0, 0, 1, 1));
6773
- this.changed = true;
6788
+ this.update();
6774
6789
  }
6775
6790
  __onLayoutEnd(event) {
6776
6791
  if (event.data)
@@ -6781,7 +6796,7 @@ class Renderer {
6781
6796
  empty = (!leaf.__world.width || !leaf.__world.height);
6782
6797
  if (empty) {
6783
6798
  if (!leaf.isLeafer)
6784
- debug$5.tip(leaf.innerName, ': empty');
6799
+ debug$4.tip(leaf.innerName, ': empty');
6785
6800
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
6786
6801
  }
6787
6802
  return empty;
@@ -7156,7 +7171,7 @@ const Transition = {
7156
7171
 
7157
7172
  const { parse, objectToCanvasData } = PathConvert;
7158
7173
  const emptyPaint = {};
7159
- const debug$4 = Debug.get('UIData');
7174
+ const debug$3 = Debug.get('UIData');
7160
7175
  class UIData extends LeafData {
7161
7176
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
7162
7177
  get __strokeWidth() {
@@ -7178,7 +7193,7 @@ class UIData extends LeafData {
7178
7193
  return true;
7179
7194
  return t.fill && this.__hasStroke;
7180
7195
  }
7181
- get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
7196
+ get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7182
7197
  get __autoWidth() { return !this._width; }
7183
7198
  get __autoHeight() { return !this._height; }
7184
7199
  get __autoSide() { return !this._width || !this._height; }
@@ -7193,7 +7208,7 @@ class UIData extends LeafData {
7193
7208
  if (value < 0) {
7194
7209
  this._width = -value;
7195
7210
  this.__leaf.scaleX *= -1;
7196
- debug$4.warn('width < 0, instead -scaleX ', this);
7211
+ debug$3.warn('width < 0, instead -scaleX ', this);
7197
7212
  }
7198
7213
  else
7199
7214
  this._width = value;
@@ -7202,7 +7217,7 @@ class UIData extends LeafData {
7202
7217
  if (value < 0) {
7203
7218
  this._height = -value;
7204
7219
  this.__leaf.scaleY *= -1;
7205
- debug$4.warn('height < 0, instead -scaleY', this);
7220
+ debug$3.warn('height < 0, instead -scaleY', this);
7206
7221
  }
7207
7222
  else
7208
7223
  this._height = value;
@@ -7292,7 +7307,7 @@ class GroupData extends UIData {
7292
7307
 
7293
7308
  class BoxData extends GroupData {
7294
7309
  get __boxStroke() { return !this.__pathInputed; }
7295
- get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
7310
+ get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7296
7311
  get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7297
7312
  }
7298
7313
 
@@ -7578,11 +7593,15 @@ let UI = UI_1 = class UI extends Leaf {
7578
7593
  super(data);
7579
7594
  }
7580
7595
  reset(_data) { }
7581
- set(data, isTemp) {
7582
- if (isTemp) {
7583
- this.lockNormalStyle = true;
7584
- Object.assign(this, data);
7585
- this.lockNormalStyle = false;
7596
+ set(data, transition) {
7597
+ if (transition) {
7598
+ if (transition === 'temp') {
7599
+ this.lockNormalStyle = true;
7600
+ Object.assign(this, data);
7601
+ this.lockNormalStyle = false;
7602
+ }
7603
+ else
7604
+ this.animate(data, transition);
7586
7605
  }
7587
7606
  else
7588
7607
  Object.assign(this, data);
@@ -7892,17 +7911,17 @@ let Group = class Group extends UI {
7892
7911
  if (!this.children)
7893
7912
  this.children = [];
7894
7913
  }
7895
- set(data, isTemp) {
7914
+ set(data, transition) {
7896
7915
  if (data.children) {
7897
7916
  const { children } = data;
7898
7917
  delete data.children;
7899
7918
  this.children ? this.clear() : this.__setBranch();
7900
- super.set(data, isTemp);
7919
+ super.set(data, transition);
7901
7920
  children.forEach(child => this.add(child));
7902
7921
  data.children = children;
7903
7922
  }
7904
7923
  else
7905
- super.set(data, isTemp);
7924
+ super.set(data, transition);
7906
7925
  }
7907
7926
  toJSON(options) {
7908
7927
  const data = super.toJSON(options);
@@ -7934,7 +7953,7 @@ Group = __decorate([
7934
7953
  ], Group);
7935
7954
 
7936
7955
  var Leafer_1;
7937
- const debug$3 = Debug.get('Leafer');
7956
+ const debug$2 = Debug.get('Leafer');
7938
7957
  let Leafer = Leafer_1 = class Leafer extends Group {
7939
7958
  get __tag() { return 'Leafer'; }
7940
7959
  get isApp() { return false; }
@@ -7948,20 +7967,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7948
7967
  constructor(userConfig, data) {
7949
7968
  super(data);
7950
7969
  this.config = {
7951
- type: 'design',
7952
7970
  start: true,
7953
7971
  hittable: true,
7954
7972
  smooth: true,
7955
- lazySpeard: 100,
7956
- zoom: {
7957
- min: 0.01,
7958
- max: 256
7959
- },
7960
- move: {
7961
- holdSpaceKey: true,
7962
- holdMiddleKey: true,
7963
- autoDistance: 2
7964
- }
7973
+ lazySpeard: 100
7965
7974
  };
7966
7975
  this.leafs = 0;
7967
7976
  this.__eventIds = [];
@@ -7978,23 +7987,27 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7978
7987
  init(userConfig, parentApp) {
7979
7988
  if (this.canvas)
7980
7989
  return;
7981
- this.__setLeafer(this);
7982
- if (userConfig)
7983
- DataHelper.assign(this.config, userConfig);
7984
7990
  let start;
7985
7991
  const { config } = this;
7986
- this.initType(config.type);
7992
+ this.__setLeafer(this);
7993
+ if (parentApp) {
7994
+ this.parentApp = parentApp;
7995
+ this.__bindApp(parentApp);
7996
+ start = parentApp.running;
7997
+ }
7998
+ if (userConfig) {
7999
+ this.parent = parentApp;
8000
+ this.initType(userConfig.type);
8001
+ this.parent = undefined;
8002
+ DataHelper.assign(config, userConfig);
8003
+ }
7987
8004
  const canvas = this.canvas = Creator.canvas(config);
7988
8005
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7989
8006
  if (this.isApp)
7990
8007
  this.__setApp();
7991
8008
  this.__checkAutoLayout(config, parentApp);
7992
8009
  this.view = canvas.view;
7993
- if (parentApp) {
7994
- this.__bindApp(parentApp);
7995
- start = parentApp.running;
7996
- }
7997
- else {
8010
+ if (!parentApp) {
7998
8011
  this.selector = Creator.selector(this);
7999
8012
  this.interaction = Creator.interaction(this, canvas, this.selector, config);
8000
8013
  if (this.interaction) {
@@ -8015,8 +8028,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8015
8028
  }
8016
8029
  onInit() { }
8017
8030
  initType(_type) { }
8018
- set(data) {
8019
- this.waitInit(() => { super.set(data); });
8031
+ set(data, transition) {
8032
+ this.waitInit(() => { super.set(data, transition); });
8020
8033
  }
8021
8034
  start() {
8022
8035
  clearTimeout(this.__startTimer);
@@ -8051,7 +8064,11 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8051
8064
  forceRender(bounds) {
8052
8065
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
8053
8066
  if (this.viewReady)
8054
- this.renderer.update();
8067
+ this.renderer.render();
8068
+ }
8069
+ requestRender(change = false) {
8070
+ if (this.renderer)
8071
+ this.renderer.update(change);
8055
8072
  }
8056
8073
  updateCursor(cursor) {
8057
8074
  const i = this.interaction;
@@ -8098,7 +8115,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8098
8115
  if (this.canvas) {
8099
8116
  if (canvasSizeAttrs.includes(attrName)) {
8100
8117
  if (!newValue)
8101
- debug$3.warn(attrName + ' is 0');
8118
+ debug$2.warn(attrName + ' is 0');
8102
8119
  this.__changeCanvasSize(attrName, newValue);
8103
8120
  }
8104
8121
  else if (attrName === 'fill') {
@@ -8159,8 +8176,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8159
8176
  const { imageReady } = this;
8160
8177
  if (imageReady && !this.viewCompleted)
8161
8178
  this.__checkViewCompleted();
8162
- if (!imageReady)
8179
+ if (!imageReady) {
8163
8180
  this.viewCompleted = false;
8181
+ this.requestRender();
8182
+ }
8164
8183
  }
8165
8184
  }
8166
8185
  __checkViewCompleted(emit = true) {
@@ -8218,6 +8237,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8218
8237
  }
8219
8238
  else
8220
8239
  list.push(item);
8240
+ this.requestRender();
8221
8241
  }
8222
8242
  zoom(_zoomType, _padding, _fixedScale) {
8223
8243
  return needPlugin('view');
@@ -8271,14 +8291,14 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8271
8291
  this.canvasManager.destroy();
8272
8292
  }
8273
8293
  this.canvas.destroy();
8274
- this.config.view = this.view = null;
8294
+ this.config.view = this.view = this.parentApp = null;
8275
8295
  if (this.userConfig)
8276
8296
  this.userConfig.view = null;
8277
8297
  super.destroy();
8278
8298
  setTimeout(() => { ImageManager.clearRecycled(); }, 100);
8279
8299
  }
8280
8300
  catch (e) {
8281
- debug$3.error(e);
8301
+ debug$2.error(e);
8282
8302
  }
8283
8303
  }
8284
8304
  };
@@ -8998,9 +9018,9 @@ let App = class App extends Leafer {
8998
9018
  if (ground)
8999
9019
  this.ground = this.addLeafer(ground);
9000
9020
  if (tree || editor)
9001
- this.tree = this.addLeafer(tree);
9021
+ this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
9002
9022
  if (sky || editor)
9003
- this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
9023
+ this.sky = this.addLeafer(sky);
9004
9024
  if (editor)
9005
9025
  this.sky.add(this.editor = Creator.editor(editor));
9006
9026
  }
@@ -9205,10 +9225,8 @@ let DragEvent = class DragEvent extends PointerEvent {
9205
9225
  this.data = data;
9206
9226
  }
9207
9227
  static getValidMove(leaf, start, total) {
9208
- const { draggable, dragBounds, x, y } = leaf;
9209
- const move = leaf.getLocalPoint(total, null, true);
9210
- move.x += start.x - x;
9211
- move.y += start.y - y;
9228
+ const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
9229
+ PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9212
9230
  if (dragBounds)
9213
9231
  this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
9214
9232
  if (draggable === 'x')
@@ -9218,8 +9236,7 @@ let DragEvent = class DragEvent extends PointerEvent {
9218
9236
  return move;
9219
9237
  }
9220
9238
  static getMoveInDragBounds(childBox, dragBounds, move, change) {
9221
- const x = childBox.x + move.x, y = childBox.y + move.y;
9222
- const right = x + childBox.width, bottom = y + childBox.height;
9239
+ const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
9223
9240
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9224
9241
  if (!change)
9225
9242
  move = Object.assign({}, move);
@@ -9271,9 +9288,7 @@ let DragEvent = class DragEvent extends PointerEvent {
9271
9288
  return this.getLocalMove(relative, true);
9272
9289
  }
9273
9290
  getPageBounds() {
9274
- const total = this.getPageTotal();
9275
- const start = this.getPagePoint();
9276
- const bounds = {};
9291
+ const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
9277
9292
  BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
9278
9293
  BoundsHelper.unsign(bounds);
9279
9294
  return bounds;
@@ -9359,184 +9374,7 @@ KeyEvent = __decorate([
9359
9374
  registerUIEvent()
9360
9375
  ], KeyEvent);
9361
9376
 
9362
- function addInteractionWindow(leafer) {
9363
- if (leafer.isApp)
9364
- return;
9365
- leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => {
9366
- leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
9367
- }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
9368
- const { zoomLayer } = leafer;
9369
- const changeScale = leafer.getValidScale(e.scale);
9370
- if (changeScale !== 1) {
9371
- PointHelper.scaleOf(zoomLayer, e, changeScale);
9372
- zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
9373
- }
9374
- }));
9375
- }
9376
-
9377
- function document$1(leafer) {
9378
- addInteractionWindow(leafer);
9379
- const { move, zoom } = leafer.config;
9380
- move.scroll = 'limit';
9381
- zoom.min = 1;
9382
- }
9383
-
9384
- function block(leafer) {
9385
- const { config } = leafer;
9386
- (config.wheel || (config.wheel = {})).preventDefault = false;
9387
- (config.touch || (config.touch = {})).preventDefault = 'auto';
9388
- }
9389
-
9390
- const debug$2 = Debug.get('LeaferTypeCreator');
9391
- const LeaferTypeCreator = {
9392
- list: {},
9393
- register(name, fn) {
9394
- list[name] && debug$2.repeat(name);
9395
- list[name] = fn;
9396
- },
9397
- run(name, leafer) {
9398
- const fn = list[name];
9399
- fn && fn(leafer);
9400
- }
9401
- };
9402
- const { list, register } = LeaferTypeCreator;
9403
- register('design', addInteractionWindow);
9404
- register('document', document$1);
9405
- register('block', block);
9406
-
9407
- const leafer = Leafer.prototype;
9408
- leafer.initType = function (type) {
9409
- LeaferTypeCreator.run(type, this);
9410
- };
9411
- leafer.getValidMove = function (moveX, moveY) {
9412
- const { scroll, disabled } = this.app.config.move;
9413
- if (scroll) {
9414
- Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
9415
- if (scroll === 'limit') {
9416
- const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
9417
- const right = x + width - this.width, bottom = y + height - this.height;
9418
- if (x >= 0 && right <= 0)
9419
- moveX = 0;
9420
- else if (moveX > 0) {
9421
- if (x + moveX > 0)
9422
- moveX = -x;
9423
- }
9424
- else if (moveX < 0 && right + moveX < 0)
9425
- moveX = -right;
9426
- if (y >= 0 && bottom <= 0)
9427
- moveY = 0;
9428
- else if (moveY > 0) {
9429
- if (y + moveY > 0)
9430
- moveY = -y;
9431
- }
9432
- else if (moveY < 0 && bottom + moveY < 0)
9433
- moveY = -bottom;
9434
- }
9435
- }
9436
- return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
9437
- };
9438
- leafer.getValidScale = function (changeScale) {
9439
- const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
9440
- if (absScale < min)
9441
- changeScale = min / scaleX;
9442
- else if (absScale > max)
9443
- changeScale = max / scaleX;
9444
- return disabled ? 1 : changeScale;
9445
- };
9446
-
9447
- class Transformer {
9448
- get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
9449
- constructor(interaction) {
9450
- this.interaction = interaction;
9451
- }
9452
- move(data) {
9453
- const { interaction } = this;
9454
- if (!data.moveType)
9455
- data.moveType = 'move';
9456
- if (!this.moveData) {
9457
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9458
- data.path = path;
9459
- this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
9460
- interaction.cancelHover();
9461
- interaction.emit(MoveEvent.START, this.moveData);
9462
- }
9463
- data.path = this.moveData.path;
9464
- interaction.emit(MoveEvent.BEFORE_MOVE, data);
9465
- interaction.emit(MoveEvent.MOVE, data);
9466
- this.transformEndWait();
9467
- }
9468
- zoom(data) {
9469
- const { interaction } = this;
9470
- if (!this.zoomData) {
9471
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9472
- data.path = path;
9473
- this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
9474
- interaction.cancelHover();
9475
- interaction.emit(ZoomEvent.START, this.zoomData);
9476
- }
9477
- data.path = this.zoomData.path;
9478
- interaction.emit(ZoomEvent.BEFORE_ZOOM, data);
9479
- interaction.emit(ZoomEvent.ZOOM, data);
9480
- this.transformEndWait();
9481
- }
9482
- rotate(data) {
9483
- const { interaction } = this;
9484
- if (!this.rotateData) {
9485
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9486
- data.path = path;
9487
- this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
9488
- interaction.cancelHover();
9489
- interaction.emit(RotateEvent.START, this.rotateData);
9490
- }
9491
- data.path = this.rotateData.path;
9492
- interaction.emit(RotateEvent.BEFORE_ROTATE, data);
9493
- interaction.emit(RotateEvent.ROTATE, data);
9494
- this.transformEndWait();
9495
- }
9496
- transformEndWait() {
9497
- clearTimeout(this.transformTimer);
9498
- this.transformTimer = setTimeout(() => {
9499
- this.transformEnd();
9500
- }, this.interaction.config.pointer.transformTime);
9501
- }
9502
- transformEnd() {
9503
- this.moveEnd();
9504
- this.zoomEnd();
9505
- this.rotateEnd();
9506
- }
9507
- moveEnd() {
9508
- if (this.moveData) {
9509
- this.interaction.emit(MoveEvent.END, this.moveData);
9510
- this.moveData = null;
9511
- }
9512
- }
9513
- zoomEnd() {
9514
- if (this.zoomData) {
9515
- this.interaction.emit(ZoomEvent.END, this.zoomData);
9516
- this.zoomData = null;
9517
- }
9518
- }
9519
- rotateEnd() {
9520
- if (this.rotateData) {
9521
- this.interaction.emit(RotateEvent.END, this.rotateData);
9522
- this.rotateData = null;
9523
- }
9524
- }
9525
- destroy() {
9526
- this.zoomData = this.moveData = this.rotateData = null;
9527
- }
9528
- }
9529
-
9530
9377
  const InteractionHelper = {
9531
- getMoveEventData(center, move, event) {
9532
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, moveX: move.x, moveY: move.y });
9533
- },
9534
- getRotateEventData(center, angle, event) {
9535
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, rotation: angle });
9536
- },
9537
- getZoomEventData(center, scale, event) {
9538
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, scale });
9539
- },
9540
9378
  getDragEventData(startPoint, lastPoint, event) {
9541
9379
  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 });
9542
9380
  },
@@ -9545,18 +9383,14 @@ const InteractionHelper = {
9545
9383
  data });
9546
9384
  },
9547
9385
  getSwipeDirection(angle) {
9548
- if (angle < -45 && angle > -135) {
9386
+ if (angle < -45 && angle > -135)
9549
9387
  return SwipeEvent.UP;
9550
- }
9551
- else if (angle > 45 && angle < 135) {
9388
+ else if (angle > 45 && angle < 135)
9552
9389
  return SwipeEvent.DOWN;
9553
- }
9554
- else if (angle <= 45 && angle >= -45) {
9390
+ else if (angle <= 45 && angle >= -45)
9555
9391
  return SwipeEvent.RIGHT;
9556
- }
9557
- else {
9392
+ else
9558
9393
  return SwipeEvent.LEFT;
9559
- }
9560
9394
  },
9561
9395
  getSwipeEventData(startPoint, lastDragData, event) {
9562
9396
  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)) });
@@ -9629,9 +9463,8 @@ class Dragger {
9629
9463
  interaction.emit(MoveEvent.START, this.dragData);
9630
9464
  }
9631
9465
  }
9632
- if (!this.moving) {
9466
+ if (!this.moving)
9633
9467
  this.dragStart(data, canDrag);
9634
- }
9635
9468
  this.drag(data);
9636
9469
  }
9637
9470
  dragStart(data, canDrag) {
@@ -9709,16 +9542,9 @@ class Dragger {
9709
9542
  dragEnd(data, speed) {
9710
9543
  if (!this.dragging && !this.moving)
9711
9544
  return;
9712
- const { moveX, moveY } = this.dragData;
9713
- if (this.interaction.config.move.dragAnimate && this.canAnimate && this.moving && (Math.abs(moveX) > 1 || Math.abs(moveY) > 1)) {
9714
- data = Object.assign({}, data);
9715
- speed = (speed || (data.pointerType === 'touch' ? 2 : 1)) * 0.9;
9716
- PointHelper.move(data, moveX * speed, moveY * speed);
9717
- this.drag(data);
9718
- this.animate(() => { this.dragEnd(data, 1); });
9719
- }
9720
- else
9721
- this.dragEndReal(data);
9545
+ if (this.checkDragEndAnimate(data, speed))
9546
+ return;
9547
+ this.dragEndReal(data);
9722
9548
  }
9723
9549
  dragEndReal(data) {
9724
9550
  const { interaction, downData, dragData } = this;
@@ -9745,12 +9571,6 @@ class Dragger {
9745
9571
  this.dragReset();
9746
9572
  this.animate(null, 'off');
9747
9573
  }
9748
- animate(func, off) {
9749
- const animateWait = func || this.animateWait;
9750
- if (animateWait)
9751
- this.interaction.target.nextRender(animateWait, null, off);
9752
- this.animateWait = func;
9753
- }
9754
9574
  swipe(data, downData, dragData, endDragData) {
9755
9575
  const { interaction } = this;
9756
9576
  if (PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
@@ -9767,39 +9587,11 @@ class Dragger {
9767
9587
  dragReset() {
9768
9588
  DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9769
9589
  }
9770
- checkDragOut(data) {
9771
- const { interaction } = this;
9772
- this.autoMoveCancel();
9773
- if (this.dragging && !interaction.shrinkCanvasBounds.hitPoint(data))
9774
- this.autoMoveOnDragOut(data);
9775
- }
9776
- autoMoveOnDragOut(data) {
9777
- const { interaction, downData, canDragOut } = this;
9778
- const { autoDistance, dragOut } = interaction.config.move;
9779
- if (!dragOut || !canDragOut || !autoDistance)
9780
- return;
9781
- const bounds = interaction.shrinkCanvasBounds;
9782
- const { x, y } = bounds;
9783
- const right = BoundsHelper.maxX(bounds);
9784
- const bottom = BoundsHelper.maxY(bounds);
9785
- const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
9786
- const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
9787
- let totalX = 0, totalY = 0;
9788
- this.autoMoveTimer = setInterval(() => {
9789
- totalX += moveX;
9790
- totalY += moveY;
9791
- PointHelper.move(downData, moveX, moveY);
9792
- PointHelper.move(this.dragData, moveX, moveY);
9793
- interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
9794
- interaction.pointerMoveReal(data);
9795
- }, 10);
9796
- }
9797
- autoMoveCancel() {
9798
- if (this.autoMoveTimer) {
9799
- clearInterval(this.autoMoveTimer);
9800
- this.autoMoveTimer = 0;
9801
- }
9802
- }
9590
+ checkDragEndAnimate(_data, _speed) { return false; }
9591
+ animate(_func, _off) { }
9592
+ checkDragOut(_data) { }
9593
+ autoMoveOnDragOut(_data) { }
9594
+ autoMoveCancel() { }
9803
9595
  destroy() {
9804
9596
  this.dragReset();
9805
9597
  }
@@ -9869,28 +9661,12 @@ function exclude(leaf, excludePath) {
9869
9661
  return excludePath && excludePath.has(leaf);
9870
9662
  }
9871
9663
 
9872
- const MultiTouchHelper = {
9873
- getData(list) {
9874
- const a = list[0];
9875
- const b = list[1];
9876
- const lastCenter = PointHelper.getCenter(a.from, b.from);
9877
- const center = PointHelper.getCenter(a.to, b.to);
9878
- const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
9879
- const lastDistance = PointHelper.getDistance(a.from, b.from);
9880
- const distance = PointHelper.getDistance(a.to, b.to);
9881
- const scale = distance / lastDistance;
9882
- const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
9883
- return { move, scale, angle, center };
9884
- }
9885
- };
9886
-
9887
9664
  const config = {
9888
9665
  wheel: {
9889
9666
  zoomSpeed: 0.5,
9890
9667
  moveSpeed: 0.5,
9891
9668
  rotateSpeed: 0.5,
9892
9669
  delta: { x: 80 / 4, y: 8.0 },
9893
- preventDefault: true
9894
9670
  },
9895
9671
  pointer: {
9896
9672
  hitRadius: 5,
@@ -9901,17 +9677,18 @@ const config = {
9901
9677
  dragHover: true,
9902
9678
  dragDistance: 2,
9903
9679
  swipeDistance: 20,
9904
- preventDefaultMenu: true
9905
9680
  },
9906
9681
  touch: {
9907
- preventDefault: true
9682
+ preventDefault: 'auto'
9908
9683
  },
9909
9684
  multiTouch: {},
9685
+ move: { autoDistance: 2 },
9686
+ zoom: {},
9910
9687
  cursor: true,
9911
9688
  keyEvent: true
9912
9689
  };
9913
9690
 
9914
- const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1, pathCanDrag: pathCanDrag$1, pathHasOutside } = InteractionHelper;
9691
+ const { pathHasEventType, pathCanDrag: pathCanDrag$1, pathHasOutside } = InteractionHelper;
9915
9692
  class InteractionBase {
9916
9693
  get dragging() { return this.dragger.dragging; }
9917
9694
  get transforming() { return this.transformer.transforming; }
@@ -9933,7 +9710,7 @@ class InteractionBase {
9933
9710
  this.canvas = canvas;
9934
9711
  this.selector = selector;
9935
9712
  this.defaultPath = new LeafList(target);
9936
- this.transformer = new Transformer(this);
9713
+ this.createTransformer();
9937
9714
  this.dragger = new Dragger(this);
9938
9715
  if (userConfig)
9939
9716
  this.config = DataHelper.default(userConfig, this.config);
@@ -10034,14 +9811,6 @@ class InteractionBase {
10034
9811
  data.isCancel = true;
10035
9812
  this.pointerUp(data);
10036
9813
  }
10037
- multiTouch(data, list) {
10038
- if (this.config.multiTouch.disabled)
10039
- return;
10040
- const { move, angle, scale, center } = MultiTouchHelper.getData(list);
10041
- this.rotate(getRotateEventData$1(center, angle, data));
10042
- this.zoom(getZoomEventData$1(center, scale, data));
10043
- this.move(getMoveEventData$1(center, move, data));
10044
- }
10045
9814
  menu(data) {
10046
9815
  this.findPath(data);
10047
9816
  this.emit(PointerEvent.MENU, data);
@@ -10055,18 +9824,13 @@ class InteractionBase {
10055
9824
  this.waitRightTap = this.waitMenuTap = false;
10056
9825
  }
10057
9826
  }
10058
- move(data) {
10059
- this.transformer.move(data);
10060
- }
10061
- zoom(data) {
10062
- this.transformer.zoom(data);
10063
- }
10064
- rotate(data) {
10065
- this.transformer.rotate(data);
10066
- }
10067
- transformEnd() {
10068
- this.transformer.transformEnd();
10069
- }
9827
+ createTransformer() { }
9828
+ move(_data) { }
9829
+ zoom(_data) { }
9830
+ rotate(_data) { }
9831
+ transformEnd() { }
9832
+ wheel(_data) { }
9833
+ multiTouch(_data, _list) { }
10070
9834
  keyDown(data) {
10071
9835
  if (!this.config.keyEvent)
10072
9836
  return;
@@ -10304,8 +10068,9 @@ class InteractionBase {
10304
10068
  this.longPressed = false;
10305
10069
  }
10306
10070
  __onResize() {
10071
+ const { dragOut } = this.m;
10307
10072
  this.shrinkCanvasBounds = new Bounds(this.canvas.bounds);
10308
- this.shrinkCanvasBounds.spread(-2);
10073
+ this.shrinkCanvasBounds.spread(-(typeof dragOut === 'number' ? dragOut : 2));
10309
10074
  }
10310
10075
  __listenEvents() {
10311
10076
  const { target } = this;
@@ -10325,7 +10090,8 @@ class InteractionBase {
10325
10090
  this.stop();
10326
10091
  this.__removeListenEvents();
10327
10092
  this.dragger.destroy();
10328
- this.transformer.destroy();
10093
+ if (this.transformer)
10094
+ this.transformer.destroy();
10329
10095
  this.downData = this.overPath = this.enterPath = null;
10330
10096
  }
10331
10097
  }
@@ -10561,46 +10327,6 @@ const PointerEventHelper = {
10561
10327
  }
10562
10328
  };
10563
10329
 
10564
- const WheelEventHelper = {
10565
- getMove(e, config) {
10566
- let { moveSpeed } = config;
10567
- let { deltaX, deltaY } = e;
10568
- if (e.shiftKey && !deltaX) {
10569
- deltaX = deltaY;
10570
- deltaY = 0;
10571
- }
10572
- if (deltaX > 50)
10573
- deltaX = Math.max(50, deltaX / 3);
10574
- if (deltaY > 50)
10575
- deltaY = Math.max(50, deltaY / 3);
10576
- return { x: -deltaX * moveSpeed * 2, y: -deltaY * moveSpeed * 2 };
10577
- },
10578
- getScale(e, config) {
10579
- let zoom;
10580
- let scale = 1;
10581
- let { zoomMode, zoomSpeed } = config;
10582
- const delta = e.deltaY || e.deltaX;
10583
- if (zoomMode) {
10584
- zoom = (zoomMode === 'mouse') ? true : (!e.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta));
10585
- if (e.shiftKey || e.metaKey || e.ctrlKey)
10586
- zoom = true;
10587
- }
10588
- else {
10589
- zoom = !e.shiftKey && (e.metaKey || e.ctrlKey);
10590
- }
10591
- if (zoom) {
10592
- zoomSpeed = MathHelper.within(zoomSpeed, 0, 1);
10593
- const min = e.deltaY ? config.delta.y : config.delta.x;
10594
- scale = 1 - delta / (min * 4) * zoomSpeed;
10595
- if (scale < 0.5)
10596
- scale = 0.5;
10597
- if (scale >= 1.5)
10598
- scale = 1.5;
10599
- }
10600
- return scale;
10601
- }
10602
- };
10603
-
10604
10330
  const KeyEventHelper = {
10605
10331
  convert(e) {
10606
10332
  const base = InteractionHelper.getBase(e);
@@ -10609,7 +10335,7 @@ const KeyEventHelper = {
10609
10335
  }
10610
10336
  };
10611
10337
 
10612
- const { getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag } = InteractionHelper;
10338
+ const { pathCanDrag } = InteractionHelper;
10613
10339
  class Interaction extends InteractionBase {
10614
10340
  __listenEvents() {
10615
10341
  super.__listenEvents();
@@ -10819,13 +10545,7 @@ class Interaction extends InteractionBase {
10819
10545
  }
10820
10546
  onWheel(e) {
10821
10547
  this.preventDefaultWheel(e);
10822
- const { wheel } = this.config;
10823
- if (wheel.disabled)
10824
- return;
10825
- const scale = wheel.getScale ? wheel.getScale(e, wheel) : WheelEventHelper.getScale(e, wheel);
10826
- const local = this.getLocal(e);
10827
- const eventBase = InteractionHelper.getBase(e);
10828
- scale !== 1 ? this.zoom(getZoomEventData(local, scale, eventBase)) : this.move(getMoveEventData(local, wheel.getMove ? wheel.getMove(e, wheel) : WheelEventHelper.getMove(e, wheel), eventBase));
10548
+ this.wheel(Object.assign(Object.assign(Object.assign({}, InteractionHelper.getBase(e)), this.getLocal(e)), { deltaX: e.deltaX, deltaY: e.deltaY }));
10829
10549
  }
10830
10550
  onGesturestart(e) {
10831
10551
  if (this.useMultiTouch)
@@ -10838,14 +10558,12 @@ class Interaction extends InteractionBase {
10838
10558
  if (this.useMultiTouch)
10839
10559
  return;
10840
10560
  this.preventDefaultWheel(e);
10841
- const local = this.getLocal(e);
10842
10561
  const eventBase = InteractionHelper.getBase(e);
10843
- const changeScale = e.scale / this.lastGestureScale;
10844
- const changeAngle = e.rotation - this.lastGestureRotation;
10845
- let { rotateSpeed } = this.config.wheel;
10846
- rotateSpeed = MathHelper.within(rotateSpeed, 0, 1);
10847
- this.zoom(getZoomEventData(local, changeScale * changeScale, eventBase));
10848
- this.rotate(getRotateEventData(local, changeAngle / Math.PI * 180 * (rotateSpeed / 4 + 0.1), eventBase));
10562
+ Object.assign(eventBase, this.getLocal(e));
10563
+ const scale = (e.scale / this.lastGestureScale);
10564
+ const rotation = (e.rotation - this.lastGestureRotation) / Math.PI * 180 * (MathHelper.within(this.config.wheel.rotateSpeed, 0, 1) / 4 + 0.1);
10565
+ this.zoom(Object.assign(Object.assign({}, eventBase), { scale: scale * scale }));
10566
+ this.rotate(Object.assign(Object.assign({}, eventBase), { rotation }));
10849
10567
  this.lastGestureScale = e.scale;
10850
10568
  this.lastGestureRotation = e.rotation;
10851
10569
  }
@@ -11013,6 +10731,8 @@ function stroke(stroke, ui, canvas) {
11013
10731
  case 'center':
11014
10732
  canvas.setStroke(stroke, __strokeWidth, options);
11015
10733
  canvas.stroke();
10734
+ if (options.__useArrow)
10735
+ strokeArrow(ui, canvas);
11016
10736
  break;
11017
10737
  case 'inside':
11018
10738
  canvas.save();
@@ -11050,6 +10770,8 @@ function strokes(strokes, ui, canvas) {
11050
10770
  case 'center':
11051
10771
  canvas.setStroke(undefined, __strokeWidth, options);
11052
10772
  drawStrokesStyle(strokes, false, ui, canvas);
10773
+ if (options.__useArrow)
10774
+ strokeArrow(ui, canvas);
11053
10775
  break;
11054
10776
  case 'inside':
11055
10777
  canvas.save();
@@ -11075,6 +10797,14 @@ function strokes(strokes, ui, canvas) {
11075
10797
  }
11076
10798
  }
11077
10799
  }
10800
+ function strokeArrow(ui, canvas) {
10801
+ if (ui.__.dashPattern) {
10802
+ canvas.beginPath();
10803
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10804
+ canvas.dashPattern = null;
10805
+ canvas.stroke();
10806
+ }
10807
+ }
11078
10808
 
11079
10809
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
11080
10810
  function shape(ui, current, options) {
@@ -12553,4 +12283,4 @@ Object.assign(Creator, {
12553
12283
  });
12554
12284
  useCanvas();
12555
12285
 
12556
- export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, 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, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, affectRenderBoundsType, affectStrokeBoundsType, 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, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
12286
+ export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, 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, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };