leafer-ui 2.2.10 → 2.2.11

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.
@@ -4607,39 +4607,44 @@ function doVisible(leaf, key, value, oldValue) {
4607
4607
  }
4608
4608
  }
4609
4609
 
4610
+ function sortParentChange(parent) {
4611
+ parent.__layout.childrenSortChange();
4612
+ if (parent.__.flow) parent.__layout.boxChange();
4613
+ }
4614
+
4610
4615
  function sortType(defaultValue) {
4611
4616
  return decorateLeafAttr(defaultValue, key => attr({
4612
4617
  set(value) {
4613
4618
  if (this.__setAttr(key, value)) {
4614
- this.waitParent(() => {
4615
- const {parent: parent} = this;
4616
- parent.__layout.childrenSortChange();
4617
- if (parent.__.flow) parent.__layout.boxChange();
4618
- });
4619
+ this.waitParentChange(sortParentChange);
4619
4620
  }
4620
4621
  }
4621
4622
  }));
4622
4623
  }
4623
4624
 
4625
+ function maskParentChange(parent) {
4626
+ parent.__updateMask();
4627
+ }
4628
+
4624
4629
  function maskType(defaultValue, updateSelf) {
4625
4630
  return decorateLeafAttr(defaultValue, key => attr({
4626
4631
  set(value) {
4627
4632
  if (this.__setAttr(key, value)) {
4628
4633
  this.__layout.boxChanged || this.__layout.boxChange();
4629
- updateSelf ? this.__updateMask() : this.waitParent(() => {
4630
- this.parent.__updateMask(value);
4631
- });
4634
+ updateSelf ? this.__updateMask() : this.waitParentChange(maskParentChange);
4632
4635
  }
4633
4636
  }
4634
4637
  }));
4635
4638
  }
4636
4639
 
4640
+ function eraserParentChange(parent) {
4641
+ parent.__updateEraser();
4642
+ }
4643
+
4637
4644
  function eraserType(defaultValue) {
4638
4645
  return decorateLeafAttr(defaultValue, key => attr({
4639
4646
  set(value) {
4640
- this.__setAttr(key, value) && this.waitParent(() => {
4641
- this.parent.__updateEraser(value);
4642
- });
4647
+ this.__setAttr(key, value) && this.waitParentChange(eraserParentChange);
4643
4648
  }
4644
4649
  }));
4645
4650
  }
@@ -6473,6 +6478,11 @@ let Leaf = class Leaf {
6473
6478
  this.__hasMask = this.__hasEraser = null;
6474
6479
  this.forceUpdate();
6475
6480
  }
6481
+ waitParentChange(item) {
6482
+ this.__parentChange || (this.__parentChange = []);
6483
+ if (!this.__parentChange.includes(item)) this.__parentChange.push(item);
6484
+ if (this.parent) item(this.parent, this);
6485
+ }
6476
6486
  waitParent(item, bind) {
6477
6487
  if (bind) item = item.bind(bind);
6478
6488
  this.parent ? item() : this.on(ChildEvent.ADD, item, "once");
@@ -6560,8 +6570,8 @@ let Leaf = class Leaf {
6560
6570
  __extraUpdate() {
6561
6571
  if (this.leaferIsReady) this.leafer.layouter.addExtra(this);
6562
6572
  }
6563
- __updateEraser(value) {
6564
- this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
6573
+ __updateEraser() {
6574
+ this.__hasEraser = this.children.some(item => item.__.eraser);
6565
6575
  }
6566
6576
  __renderEraser(canvas, options) {
6567
6577
  canvas.save();
@@ -6570,7 +6580,7 @@ let Leaf = class Leaf {
6570
6580
  canvas.clearRect(r.x, r.y, r.width, r.height);
6571
6581
  canvas.restore();
6572
6582
  }
6573
- __updateMask(_value) {
6583
+ __updateMask() {
6574
6584
  const hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6575
6585
  this.__hasMask = this.__.maskskip ? hasMask && 0 : hasMask;
6576
6586
  }
@@ -6824,6 +6834,7 @@ let Branch = class Branch extends Leaf {
6824
6834
  const childLayout = child.__layout;
6825
6835
  childLayout.boxChanged || childLayout.boxChange();
6826
6836
  childLayout.matrixChanged || childLayout.matrixChange();
6837
+ if (child.__parentChange) child.__parentChange.forEach(item => item(this, child));
6827
6838
  if (child.__bubbleMap) child.__emitLifeEvent(ChildEvent.ADD);
6828
6839
  if (this.isFrame) child.__bindFrame(this);
6829
6840
  if (this.leafer) {
@@ -7046,7 +7057,7 @@ class LeafLevelList {
7046
7057
  }
7047
7058
  }
7048
7059
 
7049
- const version = "2.2.10";
7060
+ const version = "2.2.11";
7050
7061
 
7051
7062
  const debug$5 = Debug.get("LeaferCanvas");
7052
7063