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.
package/README.md CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  官网: [leaferjs.com](https://www.leaferjs.com)
10
10
 
11
+ 森林: [leafer.pro](https://www.leafer.pro)
12
+
11
13
  **👉 在浏览器里 “跑得动 100 万个图形” 的 Canvas 引擎**
12
14
  **👉 可以做 “Figma 级编辑器” 的 Canvas 内核**
13
15
 
package/dist/web.js CHANGED
@@ -4327,37 +4327,39 @@ var LeaferUI = function(exports) {
4327
4327
  if (oldValue === 0 || value === 0) doBoundsType(leaf);
4328
4328
  }
4329
4329
  }
4330
+ function sortParentChange(parent) {
4331
+ parent.__layout.childrenSortChange();
4332
+ if (parent.__.flow) parent.__layout.boxChange();
4333
+ }
4330
4334
  function sortType(defaultValue) {
4331
4335
  return decorateLeafAttr(defaultValue, key => attr({
4332
4336
  set(value) {
4333
4337
  if (this.__setAttr(key, value)) {
4334
- this.waitParent(() => {
4335
- const {parent: parent} = this;
4336
- parent.__layout.childrenSortChange();
4337
- if (parent.__.flow) parent.__layout.boxChange();
4338
- });
4338
+ this.waitParentChange(sortParentChange);
4339
4339
  }
4340
4340
  }
4341
4341
  }));
4342
4342
  }
4343
+ function maskParentChange(parent) {
4344
+ parent.__updateMask();
4345
+ }
4343
4346
  function maskType(defaultValue, updateSelf) {
4344
4347
  return decorateLeafAttr(defaultValue, key => attr({
4345
4348
  set(value) {
4346
4349
  if (this.__setAttr(key, value)) {
4347
4350
  this.__layout.boxChanged || this.__layout.boxChange();
4348
- updateSelf ? this.__updateMask() : this.waitParent(() => {
4349
- this.parent.__updateMask(value);
4350
- });
4351
+ updateSelf ? this.__updateMask() : this.waitParentChange(maskParentChange);
4351
4352
  }
4352
4353
  }
4353
4354
  }));
4354
4355
  }
4356
+ function eraserParentChange(parent) {
4357
+ parent.__updateEraser();
4358
+ }
4355
4359
  function eraserType(defaultValue) {
4356
4360
  return decorateLeafAttr(defaultValue, key => attr({
4357
4361
  set(value) {
4358
- this.__setAttr(key, value) && this.waitParent(() => {
4359
- this.parent.__updateEraser(value);
4360
- });
4362
+ this.__setAttr(key, value) && this.waitParentChange(eraserParentChange);
4361
4363
  }
4362
4364
  }));
4363
4365
  }
@@ -6063,6 +6065,11 @@ var LeaferUI = function(exports) {
6063
6065
  this.__hasMask = this.__hasEraser = null;
6064
6066
  this.forceUpdate();
6065
6067
  }
6068
+ waitParentChange(item) {
6069
+ this.__parentChange || (this.__parentChange = []);
6070
+ if (!this.__parentChange.includes(item)) this.__parentChange.push(item);
6071
+ if (this.parent) item(this.parent, this);
6072
+ }
6066
6073
  waitParent(item, bind) {
6067
6074
  if (bind) item = item.bind(bind);
6068
6075
  this.parent ? item() : this.on(ChildEvent.ADD, item, "once");
@@ -6150,8 +6157,8 @@ var LeaferUI = function(exports) {
6150
6157
  __extraUpdate() {
6151
6158
  if (this.leaferIsReady) this.leafer.layouter.addExtra(this);
6152
6159
  }
6153
- __updateEraser(value) {
6154
- this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
6160
+ __updateEraser() {
6161
+ this.__hasEraser = this.children.some(item => item.__.eraser);
6155
6162
  }
6156
6163
  __renderEraser(canvas, options) {
6157
6164
  canvas.save();
@@ -6160,7 +6167,7 @@ var LeaferUI = function(exports) {
6160
6167
  canvas.clearRect(r.x, r.y, r.width, r.height);
6161
6168
  canvas.restore();
6162
6169
  }
6163
- __updateMask(_value) {
6170
+ __updateMask() {
6164
6171
  const hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6165
6172
  this.__hasMask = this.__.maskskip ? hasMask && 0 : hasMask;
6166
6173
  }
@@ -6408,6 +6415,7 @@ var LeaferUI = function(exports) {
6408
6415
  const childLayout = child.__layout;
6409
6416
  childLayout.boxChanged || childLayout.boxChange();
6410
6417
  childLayout.matrixChanged || childLayout.matrixChange();
6418
+ if (child.__parentChange) child.__parentChange.forEach(item => item(this, child));
6411
6419
  if (child.__bubbleMap) child.__emitLifeEvent(ChildEvent.ADD);
6412
6420
  if (this.isFrame) child.__bindFrame(this);
6413
6421
  if (this.leafer) {
@@ -6626,7 +6634,7 @@ var LeaferUI = function(exports) {
6626
6634
  this.levelMap = null;
6627
6635
  }
6628
6636
  }
6629
- const version = "2.2.10";
6637
+ const version = "2.2.11";
6630
6638
  const debug$5 = Debug.get("LeaferCanvas");
6631
6639
  class LeaferCanvas extends LeaferCanvasBase {
6632
6640
  set zIndex(zIndex) {