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.
package/dist/web.js CHANGED
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
111
111
  return rotation - oldRotation;
112
112
  },
113
113
  float(num, maxLength) {
114
- const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
114
+ const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
115
115
  num = round(num * a) / a;
116
116
  return num === -0 ? 0 : num;
117
117
  },
@@ -1414,14 +1414,14 @@ var LeaferUI = (function (exports) {
1414
1414
  list: {},
1415
1415
  register(UI) {
1416
1416
  const { __tag: tag } = UI.prototype;
1417
- if (list$2[tag])
1417
+ if (list$1[tag])
1418
1418
  debug$f.repeat(tag);
1419
- list$2[tag] = UI;
1419
+ list$1[tag] = UI;
1420
1420
  },
1421
1421
  get(tag, data, x, y, width, height) {
1422
- if (!list$2[tag])
1422
+ if (!list$1[tag])
1423
1423
  debug$f.error('not register ' + tag);
1424
- const ui = new list$2[tag](data);
1424
+ const ui = new list$1[tag](data);
1425
1425
  if (x !== undefined) {
1426
1426
  ui.x = x;
1427
1427
  if (y)
@@ -1434,7 +1434,7 @@ var LeaferUI = (function (exports) {
1434
1434
  return ui;
1435
1435
  }
1436
1436
  };
1437
- const { list: list$2 } = UICreator;
1437
+ const { list: list$1 } = UICreator;
1438
1438
 
1439
1439
  const debug$e = Debug.get('EventCreator');
1440
1440
  const EventCreator = {
@@ -1516,17 +1516,19 @@ var LeaferUI = (function (exports) {
1516
1516
  assign(t, defaultData);
1517
1517
  return t;
1518
1518
  },
1519
- assign(t, merge) {
1519
+ assign(t, merge, exclude) {
1520
1520
  let value;
1521
1521
  Object.keys(merge).forEach(key => {
1522
- var _a;
1522
+ var _a, _b;
1523
1523
  value = merge[key];
1524
- if ((value === null || value === void 0 ? void 0 : value.constructor) === Object) {
1525
- (((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) ? assign(t[key], merge[key]) : t[key] = merge[key];
1526
- }
1527
- else {
1528
- t[key] = merge[key];
1524
+ if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object)
1525
+ return assign(t[key], merge[key], exclude && exclude[key]);
1526
+ if (exclude && (key in exclude)) {
1527
+ if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object)
1528
+ assign(t[key] = {}, merge[key], exclude[key]);
1529
+ return;
1529
1530
  }
1531
+ t[key] = merge[key];
1530
1532
  });
1531
1533
  },
1532
1534
  copyAttrs(t, from, include) {
@@ -3894,6 +3896,8 @@ var LeaferUI = (function (exports) {
3894
3896
  return decorateLeafAttr(defaultValue, (key) => attr({
3895
3897
  set(value) {
3896
3898
  this.__setAttr(key, value) && (this.__layout.opacityChanged || this.__layout.opacityChange());
3899
+ if (this.mask)
3900
+ checkMask(this);
3897
3901
  }
3898
3902
  }));
3899
3903
  }
@@ -3910,9 +3914,20 @@ var LeaferUI = (function (exports) {
3910
3914
  this.__runAnimation('in');
3911
3915
  }
3912
3916
  doVisible(this, key, value, oldValue);
3917
+ if (this.mask)
3918
+ checkMask(this);
3913
3919
  }
3914
3920
  }));
3915
3921
  }
3922
+ function checkMask(leaf) {
3923
+ const { parent } = leaf;
3924
+ if (parent) {
3925
+ const { __hasMask } = parent;
3926
+ parent.__updateMask();
3927
+ if (__hasMask !== parent.__hasMask)
3928
+ parent.forceUpdate();
3929
+ }
3930
+ }
3916
3931
  function doVisible(leaf, key, value, oldValue) {
3917
3932
  if (leaf.__setAttr(key, value)) {
3918
3933
  leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
@@ -4051,11 +4066,11 @@ var LeaferUI = (function (exports) {
4051
4066
  }
4052
4067
 
4053
4068
  const debug$9 = new Debug('rewrite');
4054
- const list$1 = [];
4069
+ const list = [];
4055
4070
  const excludeNames = ['destroy', 'constructor'];
4056
4071
  function rewrite(method) {
4057
4072
  return (target, key) => {
4058
- list$1.push({ name: target.constructor.name + '.' + key, run: () => { target[key] = method; } });
4073
+ list.push({ name: target.constructor.name + '.' + key, run: () => { target[key] = method; } });
4059
4074
  };
4060
4075
  }
4061
4076
  function rewriteAble() {
@@ -4064,13 +4079,13 @@ var LeaferUI = (function (exports) {
4064
4079
  };
4065
4080
  }
4066
4081
  function doRewrite(error) {
4067
- if (list$1.length) {
4068
- list$1.forEach(item => {
4082
+ if (list.length) {
4083
+ list.forEach(item => {
4069
4084
  if (error)
4070
4085
  debug$9.error(item.name, '需在Class上装饰@rewriteAble()');
4071
4086
  item.run();
4072
4087
  });
4073
- list$1.length = 0;
4088
+ list.length = 0;
4074
4089
  }
4075
4090
  }
4076
4091
  setTimeout(() => doRewrite(true));
@@ -4168,20 +4183,17 @@ var LeaferUI = (function (exports) {
4168
4183
  }
4169
4184
  return true;
4170
4185
  },
4171
- moveWorld(t, x, y = 0, isInnerPoint) {
4186
+ moveWorld(t, x, y = 0, isInnerPoint, transition) {
4172
4187
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4173
4188
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
4174
- L.moveLocal(t, local.x, local.y);
4189
+ L.moveLocal(t, local.x, local.y, transition);
4175
4190
  },
4176
- moveLocal(t, x, y = 0) {
4177
- if (typeof x === 'object') {
4178
- t.x += x.x;
4179
- t.y += x.y;
4180
- }
4181
- else {
4182
- t.x += x;
4183
- t.y += y;
4184
- }
4191
+ moveLocal(t, x, y = 0, transition) {
4192
+ if (typeof x === 'object')
4193
+ y = x.y, x = x.x;
4194
+ x += t.x;
4195
+ y += t.y;
4196
+ transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4185
4197
  },
4186
4198
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4187
4199
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -5440,8 +5452,8 @@ var LeaferUI = (function (exports) {
5440
5452
  canvas.clearRect(r.x, r.y, r.width, r.height);
5441
5453
  canvas.restore();
5442
5454
  }
5443
- __updateMask(value) {
5444
- this.__hasMask = value ? true : this.children.some(item => item.__.mask);
5455
+ __updateMask(_value) {
5456
+ this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
5445
5457
  }
5446
5458
  __renderMask(_canvas, _options) { }
5447
5459
  __getNowWorld(options) {
@@ -5561,11 +5573,11 @@ var LeaferUI = (function (exports) {
5561
5573
  transform(matrix, resize) {
5562
5574
  transform(this, matrix, resize);
5563
5575
  }
5564
- move(x, y) {
5565
- moveLocal(this, x, y);
5576
+ move(x, y, transition) {
5577
+ moveLocal(this, x, y, transition);
5566
5578
  }
5567
- moveInner(x, y) {
5568
- moveWorld(this, x, y, true);
5579
+ moveInner(x, y, transition) {
5580
+ moveWorld(this, x, y, true, transition);
5569
5581
  }
5570
5582
  scaleOf(origin, scaleX, scaleY, resize) {
5571
5583
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
@@ -5579,8 +5591,8 @@ var LeaferUI = (function (exports) {
5579
5591
  transformWorld(worldTransform, resize) {
5580
5592
  transformWorld(this, worldTransform, resize);
5581
5593
  }
5582
- moveWorld(x, y) {
5583
- moveWorld(this, x, y);
5594
+ moveWorld(x, y, transition) {
5595
+ moveWorld(this, x, y, false, transition);
5584
5596
  }
5585
5597
  scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5586
5598
  zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
@@ -5684,6 +5696,7 @@ var LeaferUI = (function (exports) {
5684
5696
  const { setListWithFn } = BoundsHelper;
5685
5697
  const { sort } = BranchHelper;
5686
5698
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5699
+ const debug$7 = new Debug('Branch');
5687
5700
  exports.Branch = class Branch extends exports.Leaf {
5688
5701
  __updateStrokeSpread() {
5689
5702
  const { children } = this;
@@ -5724,8 +5737,8 @@ var LeaferUI = (function (exports) {
5724
5737
  }
5725
5738
  }
5726
5739
  add(child, index) {
5727
- if (child === this)
5728
- return;
5740
+ if (child === this || child.destroyed)
5741
+ return debug$7.warn('add self or destroyed');
5729
5742
  const noIndex = index === undefined;
5730
5743
  if (!child.__) {
5731
5744
  if (child instanceof Array)
@@ -5739,8 +5752,9 @@ var LeaferUI = (function (exports) {
5739
5752
  noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
5740
5753
  if (child.isBranch)
5741
5754
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5742
- child.__layout.boxChanged || child.__layout.boxChange();
5743
- child.__layout.matrixChanged || child.__layout.matrixChange();
5755
+ const childLayout = child.__layout;
5756
+ childLayout.boxChanged || childLayout.boxChange();
5757
+ childLayout.matrixChanged || childLayout.matrixChange();
5744
5758
  if (child.__bubbleMap)
5745
5759
  child.__emitLifeEvent(ChildEvent.ADD);
5746
5760
  if (this.leafer) {
@@ -5978,9 +5992,9 @@ var LeaferUI = (function (exports) {
5978
5992
  }
5979
5993
  }
5980
5994
 
5981
- const version = "1.0.10";
5995
+ const version = "1.1.1";
5982
5996
 
5983
- const debug$7 = Debug.get('LeaferCanvas');
5997
+ const debug$6 = Debug.get('LeaferCanvas');
5984
5998
  class LeaferCanvas extends LeaferCanvasBase {
5985
5999
  set zIndex(zIndex) {
5986
6000
  const { style } = this.view;
@@ -6052,7 +6066,7 @@ var LeaferUI = (function (exports) {
6052
6066
  }
6053
6067
  }
6054
6068
  else {
6055
- debug$7.error(`no id: ${inputView}`);
6069
+ debug$6.error(`no id: ${inputView}`);
6056
6070
  this.__createView();
6057
6071
  }
6058
6072
  }
@@ -6089,7 +6103,7 @@ var LeaferUI = (function (exports) {
6089
6103
  }
6090
6104
  else {
6091
6105
  this.checkAutoBounds(this.view);
6092
- debug$7.warn('no parent');
6106
+ debug$6.warn('no parent');
6093
6107
  }
6094
6108
  }
6095
6109
  catch (_a) {
@@ -6425,7 +6439,7 @@ var LeaferUI = (function (exports) {
6425
6439
  }
6426
6440
 
6427
6441
  const { updateAllMatrix, updateAllChange } = LeafHelper;
6428
- const debug$6 = Debug.get('Layouter');
6442
+ const debug$5 = Debug.get('Layouter');
6429
6443
  class Layouter {
6430
6444
  constructor(target, userConfig) {
6431
6445
  this.totalTimes = 0;
@@ -6460,7 +6474,7 @@ var LeaferUI = (function (exports) {
6460
6474
  target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
6461
6475
  }
6462
6476
  catch (e) {
6463
- debug$6.error(e);
6477
+ debug$5.error(e);
6464
6478
  }
6465
6479
  this.layoutedBlocks = null;
6466
6480
  }
@@ -6474,9 +6488,9 @@ var LeaferUI = (function (exports) {
6474
6488
  }
6475
6489
  layoutOnce() {
6476
6490
  if (this.layouting)
6477
- return debug$6.warn('layouting');
6491
+ return debug$5.warn('layouting');
6478
6492
  if (this.times > 3)
6479
- return debug$6.warn('layout max times');
6493
+ return debug$5.warn('layout max times');
6480
6494
  this.times++;
6481
6495
  this.totalTimes++;
6482
6496
  this.layouting = true;
@@ -6580,7 +6594,7 @@ var LeaferUI = (function (exports) {
6580
6594
  }
6581
6595
  }
6582
6596
 
6583
- const debug$5 = Debug.get('Renderer');
6597
+ const debug$4 = Debug.get('Renderer');
6584
6598
  class Renderer {
6585
6599
  get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
6586
6600
  constructor(target, canvas, userConfig) {
@@ -6596,29 +6610,29 @@ var LeaferUI = (function (exports) {
6596
6610
  if (userConfig)
6597
6611
  this.config = DataHelper.default(userConfig, this.config);
6598
6612
  this.__listenEvents();
6599
- this.__requestRender();
6600
6613
  }
6601
6614
  start() {
6602
6615
  this.running = true;
6616
+ this.update(false);
6603
6617
  }
6604
6618
  stop() {
6605
6619
  this.running = false;
6606
6620
  }
6607
- update() {
6608
- this.changed = true;
6621
+ update(change = true) {
6622
+ if (!this.changed)
6623
+ this.changed = change;
6624
+ this.__requestRender();
6609
6625
  }
6610
6626
  requestLayout() {
6611
6627
  this.target.emit(LayoutEvent.REQUEST);
6612
6628
  }
6613
6629
  render(callback) {
6614
- if (!(this.running && this.canvas.view)) {
6615
- this.changed = true;
6616
- return;
6617
- }
6630
+ if (!(this.running && this.canvas.view))
6631
+ return this.update();
6618
6632
  const { target } = this;
6619
6633
  this.times = 0;
6620
6634
  this.totalBounds = new Bounds();
6621
- debug$5.log(target.innerName, '--->');
6635
+ debug$4.log(target.innerName, '--->');
6622
6636
  try {
6623
6637
  if (!target.isApp)
6624
6638
  target.app.emit(RenderEvent.CHILD_START, target);
@@ -6629,9 +6643,9 @@ var LeaferUI = (function (exports) {
6629
6643
  }
6630
6644
  catch (e) {
6631
6645
  this.rendering = false;
6632
- debug$5.error(e);
6646
+ debug$4.error(e);
6633
6647
  }
6634
- debug$5.log('-------------|');
6648
+ debug$4.log('-------------|');
6635
6649
  }
6636
6650
  renderAgain() {
6637
6651
  if (this.rendering) {
@@ -6643,9 +6657,9 @@ var LeaferUI = (function (exports) {
6643
6657
  }
6644
6658
  renderOnce(callback) {
6645
6659
  if (this.rendering)
6646
- return debug$5.warn('rendering');
6660
+ return debug$4.warn('rendering');
6647
6661
  if (this.times > 3)
6648
- return debug$5.warn('render max times');
6662
+ return debug$4.warn('render max times');
6649
6663
  this.times++;
6650
6664
  this.totalTimes++;
6651
6665
  this.rendering = true;
@@ -6682,7 +6696,7 @@ var LeaferUI = (function (exports) {
6682
6696
  partRender() {
6683
6697
  const { canvas, updateBlocks: list } = this;
6684
6698
  if (!list)
6685
- return debug$5.warn('PartRender: need update attr');
6699
+ return debug$4.warn('PartRender: need update attr');
6686
6700
  this.mergeBlocks();
6687
6701
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6688
6702
  this.clipRender(block); });
@@ -6748,16 +6762,17 @@ var LeaferUI = (function (exports) {
6748
6762
  }
6749
6763
  }
6750
6764
  __requestRender() {
6751
- const startTime = Date.now();
6765
+ if (this.requestTime)
6766
+ return;
6767
+ const requestTime = this.requestTime = Date.now();
6752
6768
  Platform.requestRender(() => {
6753
- this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
6769
+ this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
6770
+ this.requestTime = 0;
6754
6771
  if (this.running) {
6755
6772
  if (this.changed && this.canvas.view)
6756
6773
  this.render();
6757
6774
  this.target.emit(RenderEvent.NEXT);
6758
6775
  }
6759
- if (this.target)
6760
- this.__requestRender();
6761
6776
  });
6762
6777
  }
6763
6778
  __onResize(e) {
@@ -6773,7 +6788,7 @@ var LeaferUI = (function (exports) {
6773
6788
  }
6774
6789
  }
6775
6790
  this.addBlock(new Bounds(0, 0, 1, 1));
6776
- this.changed = true;
6791
+ this.update();
6777
6792
  }
6778
6793
  __onLayoutEnd(event) {
6779
6794
  if (event.data)
@@ -6784,7 +6799,7 @@ var LeaferUI = (function (exports) {
6784
6799
  empty = (!leaf.__world.width || !leaf.__world.height);
6785
6800
  if (empty) {
6786
6801
  if (!leaf.isLeafer)
6787
- debug$5.tip(leaf.innerName, ': empty');
6802
+ debug$4.tip(leaf.innerName, ': empty');
6788
6803
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
6789
6804
  }
6790
6805
  return empty;
@@ -7159,7 +7174,7 @@ var LeaferUI = (function (exports) {
7159
7174
 
7160
7175
  const { parse, objectToCanvasData } = PathConvert;
7161
7176
  const emptyPaint = {};
7162
- const debug$4 = Debug.get('UIData');
7177
+ const debug$3 = Debug.get('UIData');
7163
7178
  class UIData extends LeafData {
7164
7179
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
7165
7180
  get __strokeWidth() {
@@ -7181,7 +7196,7 @@ var LeaferUI = (function (exports) {
7181
7196
  return true;
7182
7197
  return t.fill && this.__hasStroke;
7183
7198
  }
7184
- get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
7199
+ get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7185
7200
  get __autoWidth() { return !this._width; }
7186
7201
  get __autoHeight() { return !this._height; }
7187
7202
  get __autoSide() { return !this._width || !this._height; }
@@ -7196,7 +7211,7 @@ var LeaferUI = (function (exports) {
7196
7211
  if (value < 0) {
7197
7212
  this._width = -value;
7198
7213
  this.__leaf.scaleX *= -1;
7199
- debug$4.warn('width < 0, instead -scaleX ', this);
7214
+ debug$3.warn('width < 0, instead -scaleX ', this);
7200
7215
  }
7201
7216
  else
7202
7217
  this._width = value;
@@ -7205,7 +7220,7 @@ var LeaferUI = (function (exports) {
7205
7220
  if (value < 0) {
7206
7221
  this._height = -value;
7207
7222
  this.__leaf.scaleY *= -1;
7208
- debug$4.warn('height < 0, instead -scaleY', this);
7223
+ debug$3.warn('height < 0, instead -scaleY', this);
7209
7224
  }
7210
7225
  else
7211
7226
  this._height = value;
@@ -7295,7 +7310,7 @@ var LeaferUI = (function (exports) {
7295
7310
 
7296
7311
  class BoxData extends GroupData {
7297
7312
  get __boxStroke() { return !this.__pathInputed; }
7298
- get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
7313
+ get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7299
7314
  get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7300
7315
  }
7301
7316
 
@@ -7581,11 +7596,15 @@ var LeaferUI = (function (exports) {
7581
7596
  super(data);
7582
7597
  }
7583
7598
  reset(_data) { }
7584
- set(data, isTemp) {
7585
- if (isTemp) {
7586
- this.lockNormalStyle = true;
7587
- Object.assign(this, data);
7588
- this.lockNormalStyle = false;
7599
+ set(data, transition) {
7600
+ if (transition) {
7601
+ if (transition === 'temp') {
7602
+ this.lockNormalStyle = true;
7603
+ Object.assign(this, data);
7604
+ this.lockNormalStyle = false;
7605
+ }
7606
+ else
7607
+ this.animate(data, transition);
7589
7608
  }
7590
7609
  else
7591
7610
  Object.assign(this, data);
@@ -7895,17 +7914,17 @@ var LeaferUI = (function (exports) {
7895
7914
  if (!this.children)
7896
7915
  this.children = [];
7897
7916
  }
7898
- set(data, isTemp) {
7917
+ set(data, transition) {
7899
7918
  if (data.children) {
7900
7919
  const { children } = data;
7901
7920
  delete data.children;
7902
7921
  this.children ? this.clear() : this.__setBranch();
7903
- super.set(data, isTemp);
7922
+ super.set(data, transition);
7904
7923
  children.forEach(child => this.add(child));
7905
7924
  data.children = children;
7906
7925
  }
7907
7926
  else
7908
- super.set(data, isTemp);
7927
+ super.set(data, transition);
7909
7928
  }
7910
7929
  toJSON(options) {
7911
7930
  const data = super.toJSON(options);
@@ -7937,7 +7956,7 @@ var LeaferUI = (function (exports) {
7937
7956
  ], exports.Group);
7938
7957
 
7939
7958
  var Leafer_1;
7940
- const debug$3 = Debug.get('Leafer');
7959
+ const debug$2 = Debug.get('Leafer');
7941
7960
  exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
7942
7961
  get __tag() { return 'Leafer'; }
7943
7962
  get isApp() { return false; }
@@ -7951,20 +7970,10 @@ var LeaferUI = (function (exports) {
7951
7970
  constructor(userConfig, data) {
7952
7971
  super(data);
7953
7972
  this.config = {
7954
- type: 'design',
7955
7973
  start: true,
7956
7974
  hittable: true,
7957
7975
  smooth: true,
7958
- lazySpeard: 100,
7959
- zoom: {
7960
- min: 0.01,
7961
- max: 256
7962
- },
7963
- move: {
7964
- holdSpaceKey: true,
7965
- holdMiddleKey: true,
7966
- autoDistance: 2
7967
- }
7976
+ lazySpeard: 100
7968
7977
  };
7969
7978
  this.leafs = 0;
7970
7979
  this.__eventIds = [];
@@ -7981,23 +7990,27 @@ var LeaferUI = (function (exports) {
7981
7990
  init(userConfig, parentApp) {
7982
7991
  if (this.canvas)
7983
7992
  return;
7984
- this.__setLeafer(this);
7985
- if (userConfig)
7986
- DataHelper.assign(this.config, userConfig);
7987
7993
  let start;
7988
7994
  const { config } = this;
7989
- this.initType(config.type);
7995
+ this.__setLeafer(this);
7996
+ if (parentApp) {
7997
+ this.parentApp = parentApp;
7998
+ this.__bindApp(parentApp);
7999
+ start = parentApp.running;
8000
+ }
8001
+ if (userConfig) {
8002
+ this.parent = parentApp;
8003
+ this.initType(userConfig.type);
8004
+ this.parent = undefined;
8005
+ DataHelper.assign(config, userConfig);
8006
+ }
7990
8007
  const canvas = this.canvas = Creator.canvas(config);
7991
8008
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7992
8009
  if (this.isApp)
7993
8010
  this.__setApp();
7994
8011
  this.__checkAutoLayout(config, parentApp);
7995
8012
  this.view = canvas.view;
7996
- if (parentApp) {
7997
- this.__bindApp(parentApp);
7998
- start = parentApp.running;
7999
- }
8000
- else {
8013
+ if (!parentApp) {
8001
8014
  this.selector = Creator.selector(this);
8002
8015
  this.interaction = Creator.interaction(this, canvas, this.selector, config);
8003
8016
  if (this.interaction) {
@@ -8018,8 +8031,8 @@ var LeaferUI = (function (exports) {
8018
8031
  }
8019
8032
  onInit() { }
8020
8033
  initType(_type) { }
8021
- set(data) {
8022
- this.waitInit(() => { super.set(data); });
8034
+ set(data, transition) {
8035
+ this.waitInit(() => { super.set(data, transition); });
8023
8036
  }
8024
8037
  start() {
8025
8038
  clearTimeout(this.__startTimer);
@@ -8054,7 +8067,11 @@ var LeaferUI = (function (exports) {
8054
8067
  forceRender(bounds) {
8055
8068
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
8056
8069
  if (this.viewReady)
8057
- this.renderer.update();
8070
+ this.renderer.render();
8071
+ }
8072
+ requestRender(change = false) {
8073
+ if (this.renderer)
8074
+ this.renderer.update(change);
8058
8075
  }
8059
8076
  updateCursor(cursor) {
8060
8077
  const i = this.interaction;
@@ -8101,7 +8118,7 @@ var LeaferUI = (function (exports) {
8101
8118
  if (this.canvas) {
8102
8119
  if (canvasSizeAttrs.includes(attrName)) {
8103
8120
  if (!newValue)
8104
- debug$3.warn(attrName + ' is 0');
8121
+ debug$2.warn(attrName + ' is 0');
8105
8122
  this.__changeCanvasSize(attrName, newValue);
8106
8123
  }
8107
8124
  else if (attrName === 'fill') {
@@ -8162,8 +8179,10 @@ var LeaferUI = (function (exports) {
8162
8179
  const { imageReady } = this;
8163
8180
  if (imageReady && !this.viewCompleted)
8164
8181
  this.__checkViewCompleted();
8165
- if (!imageReady)
8182
+ if (!imageReady) {
8166
8183
  this.viewCompleted = false;
8184
+ this.requestRender();
8185
+ }
8167
8186
  }
8168
8187
  }
8169
8188
  __checkViewCompleted(emit = true) {
@@ -8221,6 +8240,7 @@ var LeaferUI = (function (exports) {
8221
8240
  }
8222
8241
  else
8223
8242
  list.push(item);
8243
+ this.requestRender();
8224
8244
  }
8225
8245
  zoom(_zoomType, _padding, _fixedScale) {
8226
8246
  return needPlugin('view');
@@ -8274,14 +8294,14 @@ var LeaferUI = (function (exports) {
8274
8294
  this.canvasManager.destroy();
8275
8295
  }
8276
8296
  this.canvas.destroy();
8277
- this.config.view = this.view = null;
8297
+ this.config.view = this.view = this.parentApp = null;
8278
8298
  if (this.userConfig)
8279
8299
  this.userConfig.view = null;
8280
8300
  super.destroy();
8281
8301
  setTimeout(() => { ImageManager.clearRecycled(); }, 100);
8282
8302
  }
8283
8303
  catch (e) {
8284
- debug$3.error(e);
8304
+ debug$2.error(e);
8285
8305
  }
8286
8306
  }
8287
8307
  };
@@ -9001,9 +9021,9 @@ var LeaferUI = (function (exports) {
9001
9021
  if (ground)
9002
9022
  this.ground = this.addLeafer(ground);
9003
9023
  if (tree || editor)
9004
- this.tree = this.addLeafer(tree);
9024
+ this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
9005
9025
  if (sky || editor)
9006
- this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
9026
+ this.sky = this.addLeafer(sky);
9007
9027
  if (editor)
9008
9028
  this.sky.add(this.editor = Creator.editor(editor));
9009
9029
  }
@@ -9208,10 +9228,8 @@ var LeaferUI = (function (exports) {
9208
9228
  this.data = data;
9209
9229
  }
9210
9230
  static getValidMove(leaf, start, total) {
9211
- const { draggable, dragBounds, x, y } = leaf;
9212
- const move = leaf.getLocalPoint(total, null, true);
9213
- move.x += start.x - x;
9214
- move.y += start.y - y;
9231
+ const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
9232
+ PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9215
9233
  if (dragBounds)
9216
9234
  this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
9217
9235
  if (draggable === 'x')
@@ -9221,8 +9239,7 @@ var LeaferUI = (function (exports) {
9221
9239
  return move;
9222
9240
  }
9223
9241
  static getMoveInDragBounds(childBox, dragBounds, move, change) {
9224
- const x = childBox.x + move.x, y = childBox.y + move.y;
9225
- const right = x + childBox.width, bottom = y + childBox.height;
9242
+ const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
9226
9243
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9227
9244
  if (!change)
9228
9245
  move = Object.assign({}, move);
@@ -9274,9 +9291,7 @@ var LeaferUI = (function (exports) {
9274
9291
  return this.getLocalMove(relative, true);
9275
9292
  }
9276
9293
  getPageBounds() {
9277
- const total = this.getPageTotal();
9278
- const start = this.getPagePoint();
9279
- const bounds = {};
9294
+ const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
9280
9295
  BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
9281
9296
  BoundsHelper.unsign(bounds);
9282
9297
  return bounds;
@@ -9362,184 +9377,7 @@ var LeaferUI = (function (exports) {
9362
9377
  registerUIEvent()
9363
9378
  ], exports.KeyEvent);
9364
9379
 
9365
- function addInteractionWindow(leafer) {
9366
- if (leafer.isApp)
9367
- return;
9368
- leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => {
9369
- leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
9370
- }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
9371
- const { zoomLayer } = leafer;
9372
- const changeScale = leafer.getValidScale(e.scale);
9373
- if (changeScale !== 1) {
9374
- PointHelper.scaleOf(zoomLayer, e, changeScale);
9375
- zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
9376
- }
9377
- }));
9378
- }
9379
-
9380
- function document$1(leafer) {
9381
- addInteractionWindow(leafer);
9382
- const { move, zoom } = leafer.config;
9383
- move.scroll = 'limit';
9384
- zoom.min = 1;
9385
- }
9386
-
9387
- function block(leafer) {
9388
- const { config } = leafer;
9389
- (config.wheel || (config.wheel = {})).preventDefault = false;
9390
- (config.touch || (config.touch = {})).preventDefault = 'auto';
9391
- }
9392
-
9393
- const debug$2 = Debug.get('LeaferTypeCreator');
9394
- const LeaferTypeCreator = {
9395
- list: {},
9396
- register(name, fn) {
9397
- list[name] && debug$2.repeat(name);
9398
- list[name] = fn;
9399
- },
9400
- run(name, leafer) {
9401
- const fn = list[name];
9402
- fn && fn(leafer);
9403
- }
9404
- };
9405
- const { list, register } = LeaferTypeCreator;
9406
- register('design', addInteractionWindow);
9407
- register('document', document$1);
9408
- register('block', block);
9409
-
9410
- const leafer = exports.Leafer.prototype;
9411
- leafer.initType = function (type) {
9412
- LeaferTypeCreator.run(type, this);
9413
- };
9414
- leafer.getValidMove = function (moveX, moveY) {
9415
- const { scroll, disabled } = this.app.config.move;
9416
- if (scroll) {
9417
- Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
9418
- if (scroll === 'limit') {
9419
- const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
9420
- const right = x + width - this.width, bottom = y + height - this.height;
9421
- if (x >= 0 && right <= 0)
9422
- moveX = 0;
9423
- else if (moveX > 0) {
9424
- if (x + moveX > 0)
9425
- moveX = -x;
9426
- }
9427
- else if (moveX < 0 && right + moveX < 0)
9428
- moveX = -right;
9429
- if (y >= 0 && bottom <= 0)
9430
- moveY = 0;
9431
- else if (moveY > 0) {
9432
- if (y + moveY > 0)
9433
- moveY = -y;
9434
- }
9435
- else if (moveY < 0 && bottom + moveY < 0)
9436
- moveY = -bottom;
9437
- }
9438
- }
9439
- return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
9440
- };
9441
- leafer.getValidScale = function (changeScale) {
9442
- const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
9443
- if (absScale < min)
9444
- changeScale = min / scaleX;
9445
- else if (absScale > max)
9446
- changeScale = max / scaleX;
9447
- return disabled ? 1 : changeScale;
9448
- };
9449
-
9450
- class Transformer {
9451
- get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
9452
- constructor(interaction) {
9453
- this.interaction = interaction;
9454
- }
9455
- move(data) {
9456
- const { interaction } = this;
9457
- if (!data.moveType)
9458
- data.moveType = 'move';
9459
- if (!this.moveData) {
9460
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9461
- data.path = path;
9462
- this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
9463
- interaction.cancelHover();
9464
- interaction.emit(exports.MoveEvent.START, this.moveData);
9465
- }
9466
- data.path = this.moveData.path;
9467
- interaction.emit(exports.MoveEvent.BEFORE_MOVE, data);
9468
- interaction.emit(exports.MoveEvent.MOVE, data);
9469
- this.transformEndWait();
9470
- }
9471
- zoom(data) {
9472
- const { interaction } = this;
9473
- if (!this.zoomData) {
9474
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9475
- data.path = path;
9476
- this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
9477
- interaction.cancelHover();
9478
- interaction.emit(exports.ZoomEvent.START, this.zoomData);
9479
- }
9480
- data.path = this.zoomData.path;
9481
- interaction.emit(exports.ZoomEvent.BEFORE_ZOOM, data);
9482
- interaction.emit(exports.ZoomEvent.ZOOM, data);
9483
- this.transformEndWait();
9484
- }
9485
- rotate(data) {
9486
- const { interaction } = this;
9487
- if (!this.rotateData) {
9488
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9489
- data.path = path;
9490
- this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
9491
- interaction.cancelHover();
9492
- interaction.emit(exports.RotateEvent.START, this.rotateData);
9493
- }
9494
- data.path = this.rotateData.path;
9495
- interaction.emit(exports.RotateEvent.BEFORE_ROTATE, data);
9496
- interaction.emit(exports.RotateEvent.ROTATE, data);
9497
- this.transformEndWait();
9498
- }
9499
- transformEndWait() {
9500
- clearTimeout(this.transformTimer);
9501
- this.transformTimer = setTimeout(() => {
9502
- this.transformEnd();
9503
- }, this.interaction.config.pointer.transformTime);
9504
- }
9505
- transformEnd() {
9506
- this.moveEnd();
9507
- this.zoomEnd();
9508
- this.rotateEnd();
9509
- }
9510
- moveEnd() {
9511
- if (this.moveData) {
9512
- this.interaction.emit(exports.MoveEvent.END, this.moveData);
9513
- this.moveData = null;
9514
- }
9515
- }
9516
- zoomEnd() {
9517
- if (this.zoomData) {
9518
- this.interaction.emit(exports.ZoomEvent.END, this.zoomData);
9519
- this.zoomData = null;
9520
- }
9521
- }
9522
- rotateEnd() {
9523
- if (this.rotateData) {
9524
- this.interaction.emit(exports.RotateEvent.END, this.rotateData);
9525
- this.rotateData = null;
9526
- }
9527
- }
9528
- destroy() {
9529
- this.zoomData = this.moveData = this.rotateData = null;
9530
- }
9531
- }
9532
-
9533
9380
  const InteractionHelper = {
9534
- getMoveEventData(center, move, event) {
9535
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, moveX: move.x, moveY: move.y });
9536
- },
9537
- getRotateEventData(center, angle, event) {
9538
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, rotation: angle });
9539
- },
9540
- getZoomEventData(center, scale, event) {
9541
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, scale });
9542
- },
9543
9381
  getDragEventData(startPoint, lastPoint, event) {
9544
9382
  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 });
9545
9383
  },
@@ -9548,18 +9386,14 @@ var LeaferUI = (function (exports) {
9548
9386
  data });
9549
9387
  },
9550
9388
  getSwipeDirection(angle) {
9551
- if (angle < -45 && angle > -135) {
9389
+ if (angle < -45 && angle > -135)
9552
9390
  return exports.SwipeEvent.UP;
9553
- }
9554
- else if (angle > 45 && angle < 135) {
9391
+ else if (angle > 45 && angle < 135)
9555
9392
  return exports.SwipeEvent.DOWN;
9556
- }
9557
- else if (angle <= 45 && angle >= -45) {
9393
+ else if (angle <= 45 && angle >= -45)
9558
9394
  return exports.SwipeEvent.RIGHT;
9559
- }
9560
- else {
9395
+ else
9561
9396
  return exports.SwipeEvent.LEFT;
9562
- }
9563
9397
  },
9564
9398
  getSwipeEventData(startPoint, lastDragData, event) {
9565
9399
  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)) });
@@ -9632,9 +9466,8 @@ var LeaferUI = (function (exports) {
9632
9466
  interaction.emit(exports.MoveEvent.START, this.dragData);
9633
9467
  }
9634
9468
  }
9635
- if (!this.moving) {
9469
+ if (!this.moving)
9636
9470
  this.dragStart(data, canDrag);
9637
- }
9638
9471
  this.drag(data);
9639
9472
  }
9640
9473
  dragStart(data, canDrag) {
@@ -9712,16 +9545,9 @@ var LeaferUI = (function (exports) {
9712
9545
  dragEnd(data, speed) {
9713
9546
  if (!this.dragging && !this.moving)
9714
9547
  return;
9715
- const { moveX, moveY } = this.dragData;
9716
- if (this.interaction.config.move.dragAnimate && this.canAnimate && this.moving && (Math.abs(moveX) > 1 || Math.abs(moveY) > 1)) {
9717
- data = Object.assign({}, data);
9718
- speed = (speed || (data.pointerType === 'touch' ? 2 : 1)) * 0.9;
9719
- PointHelper.move(data, moveX * speed, moveY * speed);
9720
- this.drag(data);
9721
- this.animate(() => { this.dragEnd(data, 1); });
9722
- }
9723
- else
9724
- this.dragEndReal(data);
9548
+ if (this.checkDragEndAnimate(data, speed))
9549
+ return;
9550
+ this.dragEndReal(data);
9725
9551
  }
9726
9552
  dragEndReal(data) {
9727
9553
  const { interaction, downData, dragData } = this;
@@ -9748,12 +9574,6 @@ var LeaferUI = (function (exports) {
9748
9574
  this.dragReset();
9749
9575
  this.animate(null, 'off');
9750
9576
  }
9751
- animate(func, off) {
9752
- const animateWait = func || this.animateWait;
9753
- if (animateWait)
9754
- this.interaction.target.nextRender(animateWait, null, off);
9755
- this.animateWait = func;
9756
- }
9757
9577
  swipe(data, downData, dragData, endDragData) {
9758
9578
  const { interaction } = this;
9759
9579
  if (PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
@@ -9770,39 +9590,11 @@ var LeaferUI = (function (exports) {
9770
9590
  dragReset() {
9771
9591
  exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9772
9592
  }
9773
- checkDragOut(data) {
9774
- const { interaction } = this;
9775
- this.autoMoveCancel();
9776
- if (this.dragging && !interaction.shrinkCanvasBounds.hitPoint(data))
9777
- this.autoMoveOnDragOut(data);
9778
- }
9779
- autoMoveOnDragOut(data) {
9780
- const { interaction, downData, canDragOut } = this;
9781
- const { autoDistance, dragOut } = interaction.config.move;
9782
- if (!dragOut || !canDragOut || !autoDistance)
9783
- return;
9784
- const bounds = interaction.shrinkCanvasBounds;
9785
- const { x, y } = bounds;
9786
- const right = BoundsHelper.maxX(bounds);
9787
- const bottom = BoundsHelper.maxY(bounds);
9788
- const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
9789
- const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
9790
- let totalX = 0, totalY = 0;
9791
- this.autoMoveTimer = setInterval(() => {
9792
- totalX += moveX;
9793
- totalY += moveY;
9794
- PointHelper.move(downData, moveX, moveY);
9795
- PointHelper.move(this.dragData, moveX, moveY);
9796
- interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
9797
- interaction.pointerMoveReal(data);
9798
- }, 10);
9799
- }
9800
- autoMoveCancel() {
9801
- if (this.autoMoveTimer) {
9802
- clearInterval(this.autoMoveTimer);
9803
- this.autoMoveTimer = 0;
9804
- }
9805
- }
9593
+ checkDragEndAnimate(_data, _speed) { return false; }
9594
+ animate(_func, _off) { }
9595
+ checkDragOut(_data) { }
9596
+ autoMoveOnDragOut(_data) { }
9597
+ autoMoveCancel() { }
9806
9598
  destroy() {
9807
9599
  this.dragReset();
9808
9600
  }
@@ -9872,28 +9664,12 @@ var LeaferUI = (function (exports) {
9872
9664
  return excludePath && excludePath.has(leaf);
9873
9665
  }
9874
9666
 
9875
- const MultiTouchHelper = {
9876
- getData(list) {
9877
- const a = list[0];
9878
- const b = list[1];
9879
- const lastCenter = PointHelper.getCenter(a.from, b.from);
9880
- const center = PointHelper.getCenter(a.to, b.to);
9881
- const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
9882
- const lastDistance = PointHelper.getDistance(a.from, b.from);
9883
- const distance = PointHelper.getDistance(a.to, b.to);
9884
- const scale = distance / lastDistance;
9885
- const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
9886
- return { move, scale, angle, center };
9887
- }
9888
- };
9889
-
9890
9667
  const config = {
9891
9668
  wheel: {
9892
9669
  zoomSpeed: 0.5,
9893
9670
  moveSpeed: 0.5,
9894
9671
  rotateSpeed: 0.5,
9895
9672
  delta: { x: 80 / 4, y: 8.0 },
9896
- preventDefault: true
9897
9673
  },
9898
9674
  pointer: {
9899
9675
  hitRadius: 5,
@@ -9904,17 +9680,18 @@ var LeaferUI = (function (exports) {
9904
9680
  dragHover: true,
9905
9681
  dragDistance: 2,
9906
9682
  swipeDistance: 20,
9907
- preventDefaultMenu: true
9908
9683
  },
9909
9684
  touch: {
9910
- preventDefault: true
9685
+ preventDefault: 'auto'
9911
9686
  },
9912
9687
  multiTouch: {},
9688
+ move: { autoDistance: 2 },
9689
+ zoom: {},
9913
9690
  cursor: true,
9914
9691
  keyEvent: true
9915
9692
  };
9916
9693
 
9917
- const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1, pathCanDrag: pathCanDrag$1, pathHasOutside } = InteractionHelper;
9694
+ const { pathHasEventType, pathCanDrag: pathCanDrag$1, pathHasOutside } = InteractionHelper;
9918
9695
  class InteractionBase {
9919
9696
  get dragging() { return this.dragger.dragging; }
9920
9697
  get transforming() { return this.transformer.transforming; }
@@ -9936,7 +9713,7 @@ var LeaferUI = (function (exports) {
9936
9713
  this.canvas = canvas;
9937
9714
  this.selector = selector;
9938
9715
  this.defaultPath = new LeafList(target);
9939
- this.transformer = new Transformer(this);
9716
+ this.createTransformer();
9940
9717
  this.dragger = new Dragger(this);
9941
9718
  if (userConfig)
9942
9719
  this.config = DataHelper.default(userConfig, this.config);
@@ -10037,14 +9814,6 @@ var LeaferUI = (function (exports) {
10037
9814
  data.isCancel = true;
10038
9815
  this.pointerUp(data);
10039
9816
  }
10040
- multiTouch(data, list) {
10041
- if (this.config.multiTouch.disabled)
10042
- return;
10043
- const { move, angle, scale, center } = MultiTouchHelper.getData(list);
10044
- this.rotate(getRotateEventData$1(center, angle, data));
10045
- this.zoom(getZoomEventData$1(center, scale, data));
10046
- this.move(getMoveEventData$1(center, move, data));
10047
- }
10048
9817
  menu(data) {
10049
9818
  this.findPath(data);
10050
9819
  this.emit(exports.PointerEvent.MENU, data);
@@ -10058,18 +9827,13 @@ var LeaferUI = (function (exports) {
10058
9827
  this.waitRightTap = this.waitMenuTap = false;
10059
9828
  }
10060
9829
  }
10061
- move(data) {
10062
- this.transformer.move(data);
10063
- }
10064
- zoom(data) {
10065
- this.transformer.zoom(data);
10066
- }
10067
- rotate(data) {
10068
- this.transformer.rotate(data);
10069
- }
10070
- transformEnd() {
10071
- this.transformer.transformEnd();
10072
- }
9830
+ createTransformer() { }
9831
+ move(_data) { }
9832
+ zoom(_data) { }
9833
+ rotate(_data) { }
9834
+ transformEnd() { }
9835
+ wheel(_data) { }
9836
+ multiTouch(_data, _list) { }
10073
9837
  keyDown(data) {
10074
9838
  if (!this.config.keyEvent)
10075
9839
  return;
@@ -10307,8 +10071,9 @@ var LeaferUI = (function (exports) {
10307
10071
  this.longPressed = false;
10308
10072
  }
10309
10073
  __onResize() {
10074
+ const { dragOut } = this.m;
10310
10075
  this.shrinkCanvasBounds = new Bounds(this.canvas.bounds);
10311
- this.shrinkCanvasBounds.spread(-2);
10076
+ this.shrinkCanvasBounds.spread(-(typeof dragOut === 'number' ? dragOut : 2));
10312
10077
  }
10313
10078
  __listenEvents() {
10314
10079
  const { target } = this;
@@ -10328,7 +10093,8 @@ var LeaferUI = (function (exports) {
10328
10093
  this.stop();
10329
10094
  this.__removeListenEvents();
10330
10095
  this.dragger.destroy();
10331
- this.transformer.destroy();
10096
+ if (this.transformer)
10097
+ this.transformer.destroy();
10332
10098
  this.downData = this.overPath = this.enterPath = null;
10333
10099
  }
10334
10100
  }
@@ -10564,46 +10330,6 @@ var LeaferUI = (function (exports) {
10564
10330
  }
10565
10331
  };
10566
10332
 
10567
- const WheelEventHelper = {
10568
- getMove(e, config) {
10569
- let { moveSpeed } = config;
10570
- let { deltaX, deltaY } = e;
10571
- if (e.shiftKey && !deltaX) {
10572
- deltaX = deltaY;
10573
- deltaY = 0;
10574
- }
10575
- if (deltaX > 50)
10576
- deltaX = Math.max(50, deltaX / 3);
10577
- if (deltaY > 50)
10578
- deltaY = Math.max(50, deltaY / 3);
10579
- return { x: -deltaX * moveSpeed * 2, y: -deltaY * moveSpeed * 2 };
10580
- },
10581
- getScale(e, config) {
10582
- let zoom;
10583
- let scale = 1;
10584
- let { zoomMode, zoomSpeed } = config;
10585
- const delta = e.deltaY || e.deltaX;
10586
- if (zoomMode) {
10587
- zoom = (zoomMode === 'mouse') ? true : (!e.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta));
10588
- if (e.shiftKey || e.metaKey || e.ctrlKey)
10589
- zoom = true;
10590
- }
10591
- else {
10592
- zoom = !e.shiftKey && (e.metaKey || e.ctrlKey);
10593
- }
10594
- if (zoom) {
10595
- zoomSpeed = MathHelper.within(zoomSpeed, 0, 1);
10596
- const min = e.deltaY ? config.delta.y : config.delta.x;
10597
- scale = 1 - delta / (min * 4) * zoomSpeed;
10598
- if (scale < 0.5)
10599
- scale = 0.5;
10600
- if (scale >= 1.5)
10601
- scale = 1.5;
10602
- }
10603
- return scale;
10604
- }
10605
- };
10606
-
10607
10333
  const KeyEventHelper = {
10608
10334
  convert(e) {
10609
10335
  const base = InteractionHelper.getBase(e);
@@ -10612,7 +10338,7 @@ var LeaferUI = (function (exports) {
10612
10338
  }
10613
10339
  };
10614
10340
 
10615
- const { getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag } = InteractionHelper;
10341
+ const { pathCanDrag } = InteractionHelper;
10616
10342
  class Interaction extends InteractionBase {
10617
10343
  __listenEvents() {
10618
10344
  super.__listenEvents();
@@ -10822,13 +10548,7 @@ var LeaferUI = (function (exports) {
10822
10548
  }
10823
10549
  onWheel(e) {
10824
10550
  this.preventDefaultWheel(e);
10825
- const { wheel } = this.config;
10826
- if (wheel.disabled)
10827
- return;
10828
- const scale = wheel.getScale ? wheel.getScale(e, wheel) : WheelEventHelper.getScale(e, wheel);
10829
- const local = this.getLocal(e);
10830
- const eventBase = InteractionHelper.getBase(e);
10831
- scale !== 1 ? this.zoom(getZoomEventData(local, scale, eventBase)) : this.move(getMoveEventData(local, wheel.getMove ? wheel.getMove(e, wheel) : WheelEventHelper.getMove(e, wheel), eventBase));
10551
+ this.wheel(Object.assign(Object.assign(Object.assign({}, InteractionHelper.getBase(e)), this.getLocal(e)), { deltaX: e.deltaX, deltaY: e.deltaY }));
10832
10552
  }
10833
10553
  onGesturestart(e) {
10834
10554
  if (this.useMultiTouch)
@@ -10841,14 +10561,12 @@ var LeaferUI = (function (exports) {
10841
10561
  if (this.useMultiTouch)
10842
10562
  return;
10843
10563
  this.preventDefaultWheel(e);
10844
- const local = this.getLocal(e);
10845
10564
  const eventBase = InteractionHelper.getBase(e);
10846
- const changeScale = e.scale / this.lastGestureScale;
10847
- const changeAngle = e.rotation - this.lastGestureRotation;
10848
- let { rotateSpeed } = this.config.wheel;
10849
- rotateSpeed = MathHelper.within(rotateSpeed, 0, 1);
10850
- this.zoom(getZoomEventData(local, changeScale * changeScale, eventBase));
10851
- this.rotate(getRotateEventData(local, changeAngle / Math.PI * 180 * (rotateSpeed / 4 + 0.1), eventBase));
10565
+ Object.assign(eventBase, this.getLocal(e));
10566
+ const scale = (e.scale / this.lastGestureScale);
10567
+ const rotation = (e.rotation - this.lastGestureRotation) / Math.PI * 180 * (MathHelper.within(this.config.wheel.rotateSpeed, 0, 1) / 4 + 0.1);
10568
+ this.zoom(Object.assign(Object.assign({}, eventBase), { scale: scale * scale }));
10569
+ this.rotate(Object.assign(Object.assign({}, eventBase), { rotation }));
10852
10570
  this.lastGestureScale = e.scale;
10853
10571
  this.lastGestureRotation = e.rotation;
10854
10572
  }
@@ -11016,6 +10734,8 @@ var LeaferUI = (function (exports) {
11016
10734
  case 'center':
11017
10735
  canvas.setStroke(stroke, __strokeWidth, options);
11018
10736
  canvas.stroke();
10737
+ if (options.__useArrow)
10738
+ strokeArrow(ui, canvas);
11019
10739
  break;
11020
10740
  case 'inside':
11021
10741
  canvas.save();
@@ -11053,6 +10773,8 @@ var LeaferUI = (function (exports) {
11053
10773
  case 'center':
11054
10774
  canvas.setStroke(undefined, __strokeWidth, options);
11055
10775
  drawStrokesStyle(strokes, false, ui, canvas);
10776
+ if (options.__useArrow)
10777
+ strokeArrow(ui, canvas);
11056
10778
  break;
11057
10779
  case 'inside':
11058
10780
  canvas.save();
@@ -11078,6 +10800,14 @@ var LeaferUI = (function (exports) {
11078
10800
  }
11079
10801
  }
11080
10802
  }
10803
+ function strokeArrow(ui, canvas) {
10804
+ if (ui.__.dashPattern) {
10805
+ canvas.beginPath();
10806
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10807
+ canvas.dashPattern = null;
10808
+ canvas.stroke();
10809
+ }
10810
+ }
11081
10811
 
11082
10812
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
11083
10813
  function shape(ui, current, options) {
@@ -12573,6 +12303,7 @@ var LeaferUI = (function (exports) {
12573
12303
  exports.Cursor = Cursor;
12574
12304
  exports.DataHelper = DataHelper;
12575
12305
  exports.Debug = Debug;
12306
+ exports.Dragger = Dragger;
12576
12307
  exports.Effect = Effect;
12577
12308
  exports.EllipseData = EllipseData;
12578
12309
  exports.EllipseHelper = EllipseHelper;
@@ -12610,12 +12341,10 @@ var LeaferUI = (function (exports) {
12610
12341
  exports.LeaferData = LeaferData;
12611
12342
  exports.LeaferEvent = LeaferEvent;
12612
12343
  exports.LeaferImage = LeaferImage;
12613
- exports.LeaferTypeCreator = LeaferTypeCreator;
12614
12344
  exports.LineData = LineData;
12615
12345
  exports.MathHelper = MathHelper;
12616
12346
  exports.Matrix = Matrix;
12617
12347
  exports.MatrixHelper = MatrixHelper;
12618
- exports.MultiTouchHelper = MultiTouchHelper;
12619
12348
  exports.MyDragEvent = MyDragEvent;
12620
12349
  exports.MyImage = MyImage;
12621
12350
  exports.MyPointerEvent = MyPointerEvent;
@@ -12671,7 +12400,6 @@ var LeaferUI = (function (exports) {
12671
12400
  exports.WaitHelper = WaitHelper;
12672
12401
  exports.WatchEvent = WatchEvent;
12673
12402
  exports.Watcher = Watcher;
12674
- exports.addInteractionWindow = addInteractionWindow;
12675
12403
  exports.affectRenderBoundsType = affectRenderBoundsType;
12676
12404
  exports.affectStrokeBoundsType = affectStrokeBoundsType;
12677
12405
  exports.attr = attr;