leafer-game 2.2.6 → 2.2.7

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$3(leaf, checkAutoLayout, waitAutoLayout);
4516
+ updateMatrix$2(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++) {
@@ -4729,7 +4730,7 @@ var LeaferUI = function(exports) {
4729
4730
  }
4730
4731
  };
4731
4732
  const L$1 = LeafHelper;
4732
- const {updateAllMatrix: updateAllMatrix$4, updateMatrix: updateMatrix$3, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L$1;
4733
+ const {updateAllMatrix: updateAllMatrix$4, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange} = L$1;
4733
4734
  function getTempLocal(t, worldPoint) {
4734
4735
  t.updateLayout();
4735
4736
  return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
@@ -4770,7 +4771,7 @@ var LeaferUI = function(exports) {
4770
4771
  if (target.__.mask) findMask = 1;
4771
4772
  return findMask < 0 ? null : (findMask && (findMask = -1), true);
4772
4773
  }
4773
- const {updateBounds: updateBounds$4} = LeafHelper;
4774
+ const {updateBounds: updateBounds$3} = LeafHelper;
4774
4775
  const BranchHelper = {
4775
4776
  sort(a, b) {
4776
4777
  return a.__.zIndex === b.__.zIndex ? a.__tempNumber - b.__tempNumber : a.__.zIndex - b.__.zIndex;
@@ -4830,10 +4831,10 @@ var LeaferUI = function(exports) {
4830
4831
  branch = branchStack[i];
4831
4832
  children = branch.children;
4832
4833
  for (let j = 0, len = children.length; j < len; j++) {
4833
- updateBounds$4(children[j]);
4834
+ updateBounds$3(children[j]);
4834
4835
  }
4835
4836
  if (exclude && exclude === branch) continue;
4836
- updateBounds$4(branch);
4837
+ updateBounds$3(branch);
4837
4838
  }
4838
4839
  },
4839
4840
  move(branch, x, y) {
@@ -4892,7 +4893,7 @@ var LeaferUI = function(exports) {
4892
4893
  }
4893
4894
  }
4894
4895
  };
4895
- const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$3} = LeafHelper;
4896
+ const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2} = LeafHelper;
4896
4897
  const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$4} = BoundsHelper;
4897
4898
  const localContent = "_localContentBounds";
4898
4899
  const worldContent = "_worldContentBounds", worldBox = "_worldBoxBounds", worldStroke = "_worldStrokeBounds";
@@ -4996,7 +4997,7 @@ var LeaferUI = function(exports) {
4996
4997
  }
4997
4998
  update() {
4998
4999
  const {leaf: leaf} = this, {leafer: leafer} = leaf;
4999
- if (leaf.isApp) return updateBounds$3(leaf);
5000
+ if (leaf.isApp) return updateBounds$2(leaf);
5000
5001
  if (leafer) {
5001
5002
  if (leafer.ready) leafer.watcher.changed && leafer.layouter.layout(); else leafer.start();
5002
5003
  } else {
@@ -5658,9 +5659,12 @@ var LeaferUI = function(exports) {
5658
5659
  }
5659
5660
  },
5660
5661
  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);
5662
+ const {leafer: leafer} = this;
5663
+ if (leafer.config.trackChanges || leafer.zoomLayer === this) {
5664
+ const event = new PropertyEvent(type, this, name, oldValue, newValue);
5665
+ this.isLeafer || this.hasEvent(type) && this.emitEvent(event);
5666
+ leafer.emitEvent(event);
5667
+ } else leafer.watcher.add(this);
5664
5668
  },
5665
5669
  __realSetAttr(name, newValue) {
5666
5670
  const data = this.__;
@@ -5701,8 +5705,8 @@ var LeaferUI = function(exports) {
5701
5705
  this.__layout.matrixChanged = undefined;
5702
5706
  }
5703
5707
  };
5704
- const {updateMatrix: updateMatrix$2, updateAllMatrix: updateAllMatrix$3} = LeafHelper;
5705
- const {updateBounds: updateBounds$2} = BranchHelper;
5708
+ const {updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$3} = LeafHelper;
5709
+ const {updateBounds: updateBounds$1} = BranchHelper;
5706
5710
  const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$2, copy: copy$3} = BoundsHelper;
5707
5711
  const {toBounds: toBounds} = PathBounds;
5708
5712
  const LeafBounds = {
@@ -5802,14 +5806,14 @@ var LeaferUI = function(exports) {
5802
5806
  if (this.__layout.childrenSortChanged) this.__updateSortChildren();
5803
5807
  if (this.__layout.boxChanged) this.__updateFlowLayout();
5804
5808
  updateAllMatrix$3(this);
5805
- updateBounds$2(this, this);
5809
+ updateBounds$1(this, this);
5806
5810
  if (this.__.__autoSide) this.__updateBoxBounds(true);
5807
5811
  } else {
5808
5812
  updateAllMatrix$3(this);
5809
- updateBounds$2(this, this);
5813
+ updateBounds$1(this, this);
5810
5814
  }
5811
5815
  } else {
5812
- updateMatrix$2(this);
5816
+ updateMatrix$1(this);
5813
5817
  }
5814
5818
  },
5815
5819
  __updateNaturalSize() {
@@ -6465,9 +6469,12 @@ var LeaferUI = function(exports) {
6465
6469
  if (this.isFrame) child.__bindFrame(null);
6466
6470
  }
6467
6471
  __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);
6472
+ const {leafer: leafer} = this;
6473
+ if (leafer.config.trackChanges || leafer.zoomLayer === this) {
6474
+ const event = new ChildEvent(type, child, this);
6475
+ if (this.hasEvent(type) && !this.isLeafer) this.emitEvent(event);
6476
+ leafer.emitEvent(event);
6477
+ } else leafer.watcher.addChild(child, this, type);
6471
6478
  }
6472
6479
  };
6473
6480
  exports.Branch = __decorate([ useModule(BranchRender) ], exports.Branch);
@@ -6616,7 +6623,7 @@ var LeaferUI = function(exports) {
6616
6623
  this.levelMap = null;
6617
6624
  }
6618
6625
  }
6619
- const version = "2.2.6";
6626
+ const version = "2.2.7";
6620
6627
  const debug$5 = Debug.get("LeaferCanvas");
6621
6628
  class LeaferCanvas extends LeaferCanvasBase {
6622
6629
  set zIndex(zIndex) {
@@ -6930,6 +6937,7 @@ var LeaferUI = function(exports) {
6930
6937
  }
6931
6938
  constructor(target, userConfig) {
6932
6939
  this.totalTimes = 0;
6940
+ this.changed = 0;
6933
6941
  this.config = {};
6934
6942
  this.__updatedList = new LeafList;
6935
6943
  this.target = target;
@@ -6949,8 +6957,10 @@ var LeaferUI = function(exports) {
6949
6957
  this.disabled = true;
6950
6958
  }
6951
6959
  update() {
6952
- this.changed = true;
6953
- if (this.running) this.target.emit(RenderEvent.REQUEST);
6960
+ if (this.changed < 100) {
6961
+ this.changed++;
6962
+ if (this.running) this.target.emit(RenderEvent.REQUEST);
6963
+ }
6954
6964
  }
6955
6965
  __onAttrChange(event) {
6956
6966
  this.add(event.target);
@@ -6959,18 +6969,21 @@ var LeaferUI = function(exports) {
6959
6969
  if (this.config.usePartLayout) this.__updatedList.add(leaf);
6960
6970
  this.update();
6961
6971
  }
6962
- __onChildEvent(event) {
6972
+ addChild(child, parent, eventType) {
6963
6973
  if (this.config.usePartLayout) {
6964
- if (event.type === ChildEvent.ADD) {
6974
+ if (eventType === ChildEvent.ADD) {
6965
6975
  this.hasAdd = true;
6966
- this.__pushChild(event.child);
6976
+ this.__pushChild(child);
6967
6977
  } else {
6968
6978
  this.hasRemove = true;
6969
- this.__updatedList.add(event.parent);
6979
+ this.__updatedList.add(parent);
6970
6980
  }
6971
6981
  }
6972
6982
  this.update();
6973
6983
  }
6984
+ __onChildEvent(event) {
6985
+ this.addChild(event.child, event.parent, event.type);
6986
+ }
6974
6987
  __pushChild(child) {
6975
6988
  this.__updatedList.add(child);
6976
6989
  if (child.isBranch) this.__loopChildren(child);
@@ -6985,7 +6998,8 @@ var LeaferUI = function(exports) {
6985
6998
  }));
6986
6999
  this.__updatedList = new LeafList;
6987
7000
  this.totalTimes++;
6988
- this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
7001
+ this.hasVisible = this.hasRemove = this.hasAdd = false;
7002
+ this.changed = 0;
6989
7003
  }
6990
7004
  __listenEvents() {
6991
7005
  this.__eventIds = [ this.target.on_([ [ PropertyEvent.CHANGE, this.__onAttrChange, this ], [ [ ChildEvent.ADD, ChildEvent.REMOVE ], this.__onChildEvent, this ], [ WatchEvent.REQUEST, this.__onRquestData, this ] ]) ];
@@ -7003,45 +7017,56 @@ var LeaferUI = function(exports) {
7003
7017
  }
7004
7018
  const {updateAllMatrix: updateAllMatrix$2, updateBounds: updateOneBounds, updateChange: updateOneChange} = LeafHelper;
7005
7019
  const {pushAllChildBranch: pushAllChildBranch, pushAllParent: pushAllParent} = BranchHelper;
7006
- function updateMatrix$1(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$2(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);
7020
+ const LayouterHelper = {
7021
+ updateMatrix(updateList, levelList) {
7022
+ let index = 0, leaf, layout;
7023
+ const {list: list} = updateList;
7024
+ while (index < list.length) {
7025
+ leaf = list[index];
7026
+ layout = leaf.__layout;
7027
+ if (levelList.without(leaf) && !layout.proxyZoom) {
7028
+ if (layout.matrixChanged) {
7029
+ updateAllMatrix$2(leaf, true);
7030
+ if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
7031
+ push(leaf, levelList);
7032
+ } else if (layout.boundsChanged) {
7033
+ if (leaf.isBranch) leaf.__tempNumber = 0;
7034
+ push(leaf, levelList);
7035
+ }
7020
7036
  }
7037
+ index++;
7021
7038
  }
7022
- });
7023
- }
7024
- function updateBounds$1(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]);
7039
+ },
7040
+ updateBounds(boundsList) {
7041
+ let index = 0, level, list, branch, children;
7042
+ const {levels: levels, levelMap: levelMap} = boundsList;
7043
+ boundsList.sort(true);
7044
+ while (index < levels.length) {
7045
+ level = levels[index];
7046
+ list = levelMap[level];
7047
+ for (let i = 0, len = list.length; i < len; i++) {
7048
+ branch = list[i];
7049
+ if (branch.isBranch && branch.__tempNumber) {
7050
+ children = branch.children;
7051
+ for (let j = 0, jLen = children.length; j < jLen; j++) {
7052
+ if (!children[j].isBranch) {
7053
+ updateOneBounds(children[j]);
7054
+ }
7036
7055
  }
7037
7056
  }
7057
+ updateOneBounds(branch);
7038
7058
  }
7039
- updateOneBounds(branch);
7059
+ index++;
7040
7060
  }
7041
- });
7042
- }
7043
- function updateChange(updateList) {
7044
- updateList.list.forEach(updateOneChange);
7061
+ },
7062
+ updateChange(updateList) {
7063
+ updateList.list.forEach(updateOneChange);
7064
+ },
7065
+ push: push
7066
+ };
7067
+ function push(leaf, levelList) {
7068
+ levelList.add(leaf);
7069
+ pushAllParent(leaf, levelList);
7045
7070
  }
7046
7071
  const {worldBounds: worldBounds} = LeafBoundsHelper;
7047
7072
  class LayoutBlockData {
@@ -7143,9 +7168,9 @@ var LeaferUI = function(exports) {
7143
7168
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
7144
7169
  this.extraBlock = null;
7145
7170
  updateList.sort();
7146
- updateMatrix$1(updateList, this.__levelList);
7147
- updateBounds$1(this.__levelList);
7148
- updateChange(updateList);
7171
+ LayouterHelper.updateMatrix(updateList, this.__levelList);
7172
+ LayouterHelper.updateBounds(this.__levelList);
7173
+ LayouterHelper.updateChange(updateList);
7149
7174
  if (this.extraBlock) blocks.push(this.extraBlock);
7150
7175
  blocks.forEach(item => item.setAfter());
7151
7176
  target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
@@ -7175,11 +7200,16 @@ var LeaferUI = function(exports) {
7175
7200
  if (target.isBranch) BranchHelper.updateBounds(target); else LeafHelper.updateBounds(target);
7176
7201
  updateAllChange(target);
7177
7202
  }
7178
- addExtra(leaf) {
7203
+ addExtra(leaf, updateBounds) {
7179
7204
  if (!this.__updatedList.has(leaf)) {
7180
7205
  const {updatedList: updatedList, beforeBounds: beforeBounds} = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
7181
7206
  updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
7182
7207
  updatedList.add(leaf);
7208
+ if (updateBounds) {
7209
+ const list = this.__levelList;
7210
+ LayouterHelper.push(leaf, list);
7211
+ list.sort(true);
7212
+ }
7183
7213
  }
7184
7214
  }
7185
7215
  createBlock(data) {
@@ -7497,7 +7527,7 @@ var LeaferUI = function(exports) {
7497
7527
  for (let i = 0, len = list.length; i < len; i++) {
7498
7528
  find = list[i];
7499
7529
  if (ignoreHittable || LeafHelper.worldHittable(find)) {
7500
- this.hitChild(find, find.hitThrough ? this.point : point);
7530
+ this.hitChild(find, find.hitThrough ? this.point : point, find.mask && find.parent && find.parent.__onlyHitMask);
7501
7531
  if (findList.length) {
7502
7532
  if (find.isBranchLeaf && list.some(item => item !== find && LeafHelper.hasParent(item, find))) {
7503
7533
  findList.reset();
@@ -7596,7 +7626,7 @@ var LeaferUI = function(exports) {
7596
7626
  }
7597
7627
  const leaf = proxy || child, {hitThrough: hitThrough} = child, {findList: findList} = this;
7598
7628
  if (hitThrough) {
7599
- const index = findList.list.findIndex(item => item[hitThrough] === child[hitThrough]);
7629
+ const index = findList.list.findIndex(item => hitThrough === "parent" ? LeafHelper.hasParent(item.parent, child.parent) : item[hitThrough] === child[hitThrough]);
7600
7630
  if (index > 0) return findList.addAt(leaf, index);
7601
7631
  }
7602
7632
  findList.add(leaf);
@@ -8492,6 +8522,7 @@ var LeaferUI = function(exports) {
8492
8522
  start: true,
8493
8523
  hittable: true,
8494
8524
  smooth: true,
8525
+ trackChanges: true,
8495
8526
  lazySpeard: 100
8496
8527
  };
8497
8528
  this.leafs = 0;
@@ -11485,7 +11516,7 @@ var LeaferUI = function(exports) {
11485
11516
  data.__naturalHeight = image.height / data.pixelRatio;
11486
11517
  if (data.__autoSide) {
11487
11518
  ui.forceUpdate();
11488
- LeafHelper.updateBounds(ui);
11519
+ LeafHelper.updateBounds(ui, true);
11489
11520
  ui.__layout.boundsChanged = true;
11490
11521
  if (ui.__proxyData) {
11491
11522
  ui.setProxyAttr("width", data.width);
@@ -14420,12 +14451,12 @@ var LeaferUI = function(exports) {
14420
14451
  ui$1.getMotionContentHeight = function() {
14421
14452
  return this.__layout.boxBounds.height;
14422
14453
  };
14423
- ui$1.getMotionPoint = function(motionDistance, motionVertical, pathElement, offsetX = 0, offsetY = 0) {
14454
+ ui$1.getMotionPoint = function(motionDistance, motionAround, motionVertical, offsetX = 0, offsetY = 0, pathElement) {
14424
14455
  if (!pathElement) pathElement = getMotionPath(this);
14425
14456
  const data = getMotionPathData(pathElement);
14426
14457
  if (!data.total) return {};
14427
14458
  const point = HighCurveHelper.getDistancePoint(data, motionDistance, pathElement.motionPrecision, offsetX);
14428
- const {motionRotation: motionRotation, motionAround: motionAround} = this;
14459
+ const {motionRotation: motionRotation} = this;
14429
14460
  if (isNumber(motionRotation)) point.rotation += motionRotation;
14430
14461
  if (motionAround && motionAround !== "top-left") {
14431
14462
  AroundHelper.toPoint(motionAround, this.__layout.boxBounds, tempPoint);
@@ -14482,7 +14513,7 @@ var LeaferUI = function(exports) {
14482
14513
  if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
14483
14514
  } else {
14484
14515
  if (leaf.motionText) leaf.__updateMotionText(); else {
14485
- const point = leaf.getMotionPoint(motion);
14516
+ const point = leaf.getMotionPoint(motion, leaf.motionAround);
14486
14517
  if (leaf.motionRotation === false) delete point.rotation;
14487
14518
  leaf.set(point);
14488
14519
  }
@@ -14704,6 +14735,7 @@ var LeaferUI = function(exports) {
14704
14735
  exports.Keyboard = Keyboard;
14705
14736
  exports.LayoutEvent = LayoutEvent;
14706
14737
  exports.Layouter = Layouter;
14738
+ exports.LayouterHelper = LayouterHelper;
14707
14739
  exports.LeafBounds = LeafBounds;
14708
14740
  exports.LeafBoundsHelper = LeafBoundsHelper;
14709
14741
  exports.LeafData = LeafData;