leafer-ui 2.2.6 → 2.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.js CHANGED
@@ -4513,7 +4513,7 @@ var LeaferUI = function(exports) {
4513
4513
  const LeafHelper = {
4514
4514
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4515
4515
  if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged) waitAutoLayout = true;
4516
- updateMatrix$2(leaf, checkAutoLayout, waitAutoLayout);
4516
+ updateMatrix$1(leaf, checkAutoLayout, waitAutoLayout);
4517
4517
  if (leaf.isBranch) {
4518
4518
  const {children: children} = leaf;
4519
4519
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4534,9 +4534,10 @@ var LeaferUI = function(exports) {
4534
4534
  if (layout.matrixChanged) leaf.__updateLocalMatrix();
4535
4535
  if (!layout.waitAutoLayout) leaf.__updateWorldMatrix();
4536
4536
  },
4537
- updateBounds(leaf) {
4537
+ updateBounds(leaf, noUpdateSize) {
4538
4538
  const layout = leaf.__layout;
4539
4539
  if (layout.boundsChanged) leaf.__updateLocalBounds();
4540
+ if (noUpdateSize) layout.resized = undefined;
4540
4541
  if (!layout.waitAutoLayout) leaf.__updateWorldBounds();
4541
4542
  },
4542
4543
  updateAllWorldOpacity(leaf) {
@@ -4559,7 +4560,7 @@ var LeaferUI = function(exports) {
4559
4560
  }
4560
4561
  },
4561
4562
  updateAllChange(leaf) {
4562
- updateChange$1(leaf);
4563
+ updateChange(leaf);
4563
4564
  if (leaf.isBranch) {
4564
4565
  const {children: children} = leaf;
4565
4566
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4581,6 +4582,13 @@ var LeaferUI = function(exports) {
4581
4582
  if (!fromWorld) fromWorld = leaf.__nowWorld;
4582
4583
  if (leaf.__worldFlipped || Platform.fullImageShadow) currentCanvas.copyWorldByReset(fromCanvas, fromWorld, leaf.__nowWorld, blendMode, onlyResetTransform); else currentCanvas.copyWorldToInner(fromCanvas, fromWorld, leaf.__layout.renderBounds, blendMode);
4583
4584
  },
4585
+ clip(leaf, canvas, options) {
4586
+ if (leaf.__worldOpacity) {
4587
+ canvas.setWorld(leaf.__nowWorld = leaf.__getNowWorld(options));
4588
+ leaf.__drawRenderPath(canvas);
4589
+ canvas.clipUI(leaf);
4590
+ }
4591
+ },
4584
4592
  renderComplex(_leaf, _canvas, _options) {},
4585
4593
  updateComplex(_leaf) {},
4586
4594
  checkComplex(_leaf) {},
@@ -4729,7 +4737,7 @@ var LeaferUI = function(exports) {
4729
4737
  }
4730
4738
  };
4731
4739
  const L = LeafHelper;
4732
- const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L;
4740
+ const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$1, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange} = L;
4733
4741
  function getTempLocal(t, worldPoint) {
4734
4742
  t.updateLayout();
4735
4743
  return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
@@ -4770,7 +4778,7 @@ var LeaferUI = function(exports) {
4770
4778
  if (target.__.mask) findMask = 1;
4771
4779
  return findMask < 0 ? null : (findMask && (findMask = -1), true);
4772
4780
  }
4773
- const {updateBounds: updateBounds$3} = LeafHelper;
4781
+ const {updateBounds: updateBounds$2} = LeafHelper;
4774
4782
  const BranchHelper = {
4775
4783
  sort(a, b) {
4776
4784
  return a.__.zIndex === b.__.zIndex ? a.__tempNumber - b.__tempNumber : a.__.zIndex - b.__.zIndex;
@@ -4830,10 +4838,10 @@ var LeaferUI = function(exports) {
4830
4838
  branch = branchStack[i];
4831
4839
  children = branch.children;
4832
4840
  for (let j = 0, len = children.length; j < len; j++) {
4833
- updateBounds$3(children[j]);
4841
+ updateBounds$2(children[j]);
4834
4842
  }
4835
4843
  if (exclude && exclude === branch) continue;
4836
- updateBounds$3(branch);
4844
+ updateBounds$2(branch);
4837
4845
  }
4838
4846
  },
4839
4847
  move(branch, x, y) {
@@ -4892,7 +4900,7 @@ var LeaferUI = function(exports) {
4892
4900
  }
4893
4901
  }
4894
4902
  };
4895
- const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2} = LeafHelper;
4903
+ const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$1} = LeafHelper;
4896
4904
  const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$4} = BoundsHelper;
4897
4905
  const localContent = "_localContentBounds";
4898
4906
  const worldContent = "_worldContentBounds", worldBox = "_worldBoxBounds", worldStroke = "_worldStrokeBounds";
@@ -4996,7 +5004,7 @@ var LeaferUI = function(exports) {
4996
5004
  }
4997
5005
  update() {
4998
5006
  const {leaf: leaf} = this, {leafer: leafer} = leaf;
4999
- if (leaf.isApp) return updateBounds$2(leaf);
5007
+ if (leaf.isApp) return updateBounds$1(leaf);
5000
5008
  if (leafer) {
5001
5009
  if (leafer.ready) leafer.watcher.changed && leafer.layouter.layout(); else leafer.start();
5002
5010
  } else {
@@ -5658,9 +5666,12 @@ var LeaferUI = function(exports) {
5658
5666
  }
5659
5667
  },
5660
5668
  emitPropertyEvent(type, name, oldValue, newValue) {
5661
- const event = new PropertyEvent(type, this, name, oldValue, newValue);
5662
- this.isLeafer || this.hasEvent(type) && this.emitEvent(event);
5663
- this.leafer.emitEvent(event);
5669
+ const {leafer: leafer} = this;
5670
+ if (leafer.config.trackChanges || leafer.zoomLayer === this) {
5671
+ const event = new PropertyEvent(type, this, name, oldValue, newValue);
5672
+ this.isLeafer || this.hasEvent(type) && this.emitEvent(event);
5673
+ leafer.emitEvent(event);
5674
+ } else leafer.watcher.add(this);
5664
5675
  },
5665
5676
  __realSetAttr(name, newValue) {
5666
5677
  const data = this.__;
@@ -5701,8 +5712,8 @@ var LeaferUI = function(exports) {
5701
5712
  this.__layout.matrixChanged = undefined;
5702
5713
  }
5703
5714
  };
5704
- const {updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2} = LeafHelper;
5705
- const {updateBounds: updateBounds$1} = BranchHelper;
5715
+ const {updateMatrix: updateMatrix, updateAllMatrix: updateAllMatrix$2} = LeafHelper;
5716
+ const {updateBounds: updateBounds} = BranchHelper;
5706
5717
  const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$2, copy: copy$3} = BoundsHelper;
5707
5718
  const {toBounds: toBounds} = PathBounds;
5708
5719
  const LeafBounds = {
@@ -5802,14 +5813,14 @@ var LeaferUI = function(exports) {
5802
5813
  if (this.__layout.childrenSortChanged) this.__updateSortChildren();
5803
5814
  if (this.__layout.boxChanged) this.__updateFlowLayout();
5804
5815
  updateAllMatrix$2(this);
5805
- updateBounds$1(this, this);
5816
+ updateBounds(this, this);
5806
5817
  if (this.__.__autoSide) this.__updateBoxBounds(true);
5807
5818
  } else {
5808
5819
  updateAllMatrix$2(this);
5809
- updateBounds$1(this, this);
5820
+ updateBounds(this, this);
5810
5821
  }
5811
5822
  } else {
5812
- updateMatrix$1(this);
5823
+ updateMatrix(this);
5813
5824
  }
5814
5825
  },
5815
5826
  __updateNaturalSize() {
@@ -5854,11 +5865,7 @@ var LeaferUI = function(exports) {
5854
5865
  }
5855
5866
  },
5856
5867
  __clip(canvas, options) {
5857
- if (this.__worldOpacity) {
5858
- canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5859
- this.__drawRenderPath(canvas);
5860
- canvas.clipUI(this);
5861
- }
5868
+ LeafHelper.clip(this, canvas, options);
5862
5869
  },
5863
5870
  __updateWorldOpacity() {
5864
5871
  this.__worldOpacity = this.__.visible ? this.parent ? this.parent.__worldOpacity * this.__.opacity : this.__.opacity : 0;
@@ -6465,9 +6472,12 @@ var LeaferUI = function(exports) {
6465
6472
  if (this.isFrame) child.__bindFrame(null);
6466
6473
  }
6467
6474
  __emitChildEvent(type, child) {
6468
- const event = new ChildEvent(type, child, this);
6469
- if (this.hasEvent(type) && !this.isLeafer) this.emitEvent(event);
6470
- this.leafer.emitEvent(event);
6475
+ const {leafer: leafer} = this;
6476
+ if (leafer.config.trackChanges || leafer.zoomLayer === this) {
6477
+ const event = new ChildEvent(type, child, this);
6478
+ if (this.hasEvent(type) && !this.isLeafer) this.emitEvent(event);
6479
+ leafer.emitEvent(event);
6480
+ } else leafer.watcher.addChild(child, this, type);
6471
6481
  }
6472
6482
  };
6473
6483
  exports.Branch = __decorate([ useModule(BranchRender) ], exports.Branch);
@@ -6616,7 +6626,7 @@ var LeaferUI = function(exports) {
6616
6626
  this.levelMap = null;
6617
6627
  }
6618
6628
  }
6619
- const version = "2.2.6";
6629
+ const version = "2.2.8";
6620
6630
  const debug$5 = Debug.get("LeaferCanvas");
6621
6631
  class LeaferCanvas extends LeaferCanvasBase {
6622
6632
  set zIndex(zIndex) {
@@ -6930,6 +6940,7 @@ var LeaferUI = function(exports) {
6930
6940
  }
6931
6941
  constructor(target, userConfig) {
6932
6942
  this.totalTimes = 0;
6943
+ this.changed = 0;
6933
6944
  this.config = {};
6934
6945
  this.__updatedList = new LeafList;
6935
6946
  this.target = target;
@@ -6949,8 +6960,10 @@ var LeaferUI = function(exports) {
6949
6960
  this.disabled = true;
6950
6961
  }
6951
6962
  update() {
6952
- this.changed = true;
6953
- if (this.running) this.target.emit(RenderEvent.REQUEST);
6963
+ if (this.changed < 100) {
6964
+ this.changed++;
6965
+ if (this.running) this.target.emit(RenderEvent.REQUEST);
6966
+ }
6954
6967
  }
6955
6968
  __onAttrChange(event) {
6956
6969
  this.add(event.target);
@@ -6959,18 +6972,21 @@ var LeaferUI = function(exports) {
6959
6972
  if (this.config.usePartLayout) this.__updatedList.add(leaf);
6960
6973
  this.update();
6961
6974
  }
6962
- __onChildEvent(event) {
6975
+ addChild(child, parent, eventType) {
6963
6976
  if (this.config.usePartLayout) {
6964
- if (event.type === ChildEvent.ADD) {
6977
+ if (eventType === ChildEvent.ADD) {
6965
6978
  this.hasAdd = true;
6966
- this.__pushChild(event.child);
6979
+ this.__pushChild(child);
6967
6980
  } else {
6968
6981
  this.hasRemove = true;
6969
- this.__updatedList.add(event.parent);
6982
+ this.__updatedList.add(parent);
6970
6983
  }
6971
6984
  }
6972
6985
  this.update();
6973
6986
  }
6987
+ __onChildEvent(event) {
6988
+ this.addChild(event.child, event.parent, event.type);
6989
+ }
6974
6990
  __pushChild(child) {
6975
6991
  this.__updatedList.add(child);
6976
6992
  if (child.isBranch) this.__loopChildren(child);
@@ -6985,7 +7001,8 @@ var LeaferUI = function(exports) {
6985
7001
  }));
6986
7002
  this.__updatedList = new LeafList;
6987
7003
  this.totalTimes++;
6988
- this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
7004
+ this.hasVisible = this.hasRemove = this.hasAdd = false;
7005
+ this.changed = 0;
6989
7006
  }
6990
7007
  __listenEvents() {
6991
7008
  this.__eventIds = [ this.target.on_([ [ PropertyEvent.CHANGE, this.__onAttrChange, this ], [ [ ChildEvent.ADD, ChildEvent.REMOVE ], this.__onChildEvent, this ], [ WatchEvent.REQUEST, this.__onRquestData, this ] ]) ];
@@ -7003,45 +7020,56 @@ var LeaferUI = function(exports) {
7003
7020
  }
7004
7021
  const {updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange} = LeafHelper;
7005
7022
  const {pushAllChildBranch: pushAllChildBranch, pushAllParent: pushAllParent} = BranchHelper;
7006
- function updateMatrix(updateList, levelList) {
7007
- let layout;
7008
- updateList.list.forEach(leaf => {
7009
- layout = leaf.__layout;
7010
- if (levelList.without(leaf) && !layout.proxyZoom) {
7011
- if (layout.matrixChanged) {
7012
- updateAllMatrix$1(leaf, true);
7013
- levelList.add(leaf);
7014
- if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
7015
- pushAllParent(leaf, levelList);
7016
- } else if (layout.boundsChanged) {
7017
- levelList.add(leaf);
7018
- if (leaf.isBranch) leaf.__tempNumber = 0;
7019
- pushAllParent(leaf, levelList);
7023
+ const LayouterHelper = {
7024
+ updateMatrix(updateList, levelList) {
7025
+ let index = 0, leaf, layout;
7026
+ const {list: list} = updateList;
7027
+ while (index < list.length) {
7028
+ leaf = list[index];
7029
+ layout = leaf.__layout;
7030
+ if (levelList.without(leaf) && !layout.proxyZoom) {
7031
+ if (layout.matrixChanged) {
7032
+ updateAllMatrix$1(leaf, true);
7033
+ if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
7034
+ push(leaf, levelList);
7035
+ } else if (layout.boundsChanged) {
7036
+ if (leaf.isBranch) leaf.__tempNumber = 0;
7037
+ push(leaf, levelList);
7038
+ }
7020
7039
  }
7040
+ index++;
7021
7041
  }
7022
- });
7023
- }
7024
- function updateBounds(boundsList) {
7025
- let list, branch, children;
7026
- boundsList.sort(true);
7027
- boundsList.levels.forEach(level => {
7028
- list = boundsList.levelMap[level];
7029
- for (let i = 0, len = list.length; i < len; i++) {
7030
- branch = list[i];
7031
- if (branch.isBranch && branch.__tempNumber) {
7032
- children = branch.children;
7033
- for (let j = 0, jLen = children.length; j < jLen; j++) {
7034
- if (!children[j].isBranch) {
7035
- updateOneBounds(children[j]);
7042
+ },
7043
+ updateBounds(boundsList) {
7044
+ let index = 0, level, list, branch, children;
7045
+ const {levels: levels, levelMap: levelMap} = boundsList;
7046
+ boundsList.sort(true);
7047
+ while (index < levels.length) {
7048
+ level = levels[index];
7049
+ list = levelMap[level];
7050
+ for (let i = 0, len = list.length; i < len; i++) {
7051
+ branch = list[i];
7052
+ if (branch.isBranch && branch.__tempNumber) {
7053
+ children = branch.children;
7054
+ for (let j = 0, jLen = children.length; j < jLen; j++) {
7055
+ if (!children[j].isBranch) {
7056
+ updateOneBounds(children[j]);
7057
+ }
7036
7058
  }
7037
7059
  }
7060
+ updateOneBounds(branch);
7038
7061
  }
7039
- updateOneBounds(branch);
7062
+ index++;
7040
7063
  }
7041
- });
7042
- }
7043
- function updateChange(updateList) {
7044
- updateList.list.forEach(updateOneChange);
7064
+ },
7065
+ updateChange(updateList) {
7066
+ updateList.list.forEach(updateOneChange);
7067
+ },
7068
+ push: push
7069
+ };
7070
+ function push(leaf, levelList) {
7071
+ levelList.add(leaf);
7072
+ pushAllParent(leaf, levelList);
7045
7073
  }
7046
7074
  const {worldBounds: worldBounds} = LeafBoundsHelper;
7047
7075
  class LayoutBlockData {
@@ -7143,9 +7171,9 @@ var LeaferUI = function(exports) {
7143
7171
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
7144
7172
  this.extraBlock = null;
7145
7173
  updateList.sort();
7146
- updateMatrix(updateList, this.__levelList);
7147
- updateBounds(this.__levelList);
7148
- updateChange(updateList);
7174
+ LayouterHelper.updateMatrix(updateList, this.__levelList);
7175
+ LayouterHelper.updateBounds(this.__levelList);
7176
+ LayouterHelper.updateChange(updateList);
7149
7177
  if (this.extraBlock) blocks.push(this.extraBlock);
7150
7178
  blocks.forEach(item => item.setAfter());
7151
7179
  target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
@@ -7175,11 +7203,16 @@ var LeaferUI = function(exports) {
7175
7203
  if (target.isBranch) BranchHelper.updateBounds(target); else LeafHelper.updateBounds(target);
7176
7204
  updateAllChange(target);
7177
7205
  }
7178
- addExtra(leaf) {
7206
+ addExtra(leaf, updateBounds) {
7179
7207
  if (!this.__updatedList.has(leaf)) {
7180
7208
  const {updatedList: updatedList, beforeBounds: beforeBounds} = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
7181
7209
  updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
7182
7210
  updatedList.add(leaf);
7211
+ if (updateBounds) {
7212
+ const list = this.__levelList;
7213
+ LayouterHelper.push(leaf, list);
7214
+ list.sort(true);
7215
+ }
7183
7216
  }
7184
7217
  }
7185
7218
  createBlock(data) {
@@ -7497,7 +7530,7 @@ var LeaferUI = function(exports) {
7497
7530
  for (let i = 0, len = list.length; i < len; i++) {
7498
7531
  find = list[i];
7499
7532
  if (ignoreHittable || LeafHelper.worldHittable(find)) {
7500
- this.hitChild(find, find.hitThrough ? this.point : point);
7533
+ this.hitChild(find, find.hitThrough ? this.point : point, find.mask && find.parent && find.parent.__onlyHitMask);
7501
7534
  if (findList.length) {
7502
7535
  if (find.isBranchLeaf && list.some(item => item !== find && LeafHelper.hasParent(item, find))) {
7503
7536
  findList.reset();
@@ -7596,7 +7629,7 @@ var LeaferUI = function(exports) {
7596
7629
  }
7597
7630
  const leaf = proxy || child, {hitThrough: hitThrough} = child, {findList: findList} = this;
7598
7631
  if (hitThrough) {
7599
- const index = findList.list.findIndex(item => item[hitThrough] === child[hitThrough]);
7632
+ const index = findList.list.findIndex(item => hitThrough === "parent" ? LeafHelper.hasParent(item.parent, child.parent) : item[hitThrough] === child[hitThrough]);
7600
7633
  if (index > 0) return findList.addAt(leaf, index);
7601
7634
  }
7602
7635
  findList.add(leaf);
@@ -7656,7 +7689,17 @@ var LeaferUI = function(exports) {
7656
7689
  });
7657
7690
  options.topList = new LeafList;
7658
7691
  target.__render(canvas, options);
7659
- if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
7692
+ if (options.topList.length) options.topList.forEach(item => {
7693
+ const {parent: parent} = item;
7694
+ if (parent && parent.isBranchLeaf && parent.overflow !== "show") {
7695
+ canvas.save();
7696
+ LeafHelper.clip(parent, canvas, topOptions);
7697
+ item.__render(canvas, topOptions);
7698
+ canvas.restore();
7699
+ } else {
7700
+ item.__render(canvas, topOptions);
7701
+ }
7702
+ });
7660
7703
  };
7661
7704
  function effectType(defaultValue) {
7662
7705
  return decorateLeafAttr(defaultValue, key => attr({
@@ -8492,6 +8535,7 @@ var LeaferUI = function(exports) {
8492
8535
  start: true,
8493
8536
  hittable: true,
8494
8537
  smooth: true,
8538
+ trackChanges: true,
8495
8539
  lazySpeard: 100
8496
8540
  };
8497
8541
  this.leafs = 0;
@@ -11485,7 +11529,7 @@ var LeaferUI = function(exports) {
11485
11529
  data.__naturalHeight = image.height / data.pixelRatio;
11486
11530
  if (data.__autoSide) {
11487
11531
  ui.forceUpdate();
11488
- LeafHelper.updateBounds(ui);
11532
+ LeafHelper.updateBounds(ui, true);
11489
11533
  ui.__layout.boundsChanged = true;
11490
11534
  if (ui.__proxyData) {
11491
11535
  ui.setProxyAttr("width", data.width);
@@ -12677,6 +12721,7 @@ var LeaferUI = function(exports) {
12677
12721
  exports.Keyboard = Keyboard;
12678
12722
  exports.LayoutEvent = LayoutEvent;
12679
12723
  exports.Layouter = Layouter;
12724
+ exports.LayouterHelper = LayouterHelper;
12680
12725
  exports.LeafBounds = LeafBounds;
12681
12726
  exports.LeafBoundsHelper = LeafBoundsHelper;
12682
12727
  exports.LeafData = LeafData;