@leafer-ui/worker 1.2.0 → 1.2.2

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.
@@ -2047,11 +2047,11 @@ class LeaferCanvasBase extends Canvas$1 {
2047
2047
  toBlob(_type, _quality) { return undefined; }
2048
2048
  toDataURL(_type, _quality) { return undefined; }
2049
2049
  saveAs(_filename, _quality) { return undefined; }
2050
- resize(size) {
2050
+ resize(size, safeResize = true) {
2051
2051
  if (this.isSameSize(size))
2052
2052
  return;
2053
2053
  let takeCanvas;
2054
- if (this.context && !this.unreal && this.width) {
2054
+ if (this.context && !this.unreal && safeResize && this.width) {
2055
2055
  takeCanvas = this.getSameCanvas();
2056
2056
  takeCanvas.copyWorld(this);
2057
2057
  }
@@ -4253,18 +4253,21 @@ const LeafHelper = {
4253
4253
  L.setTransform(t, matrix$1, resize);
4254
4254
  },
4255
4255
  setTransform(t, transform, resize) {
4256
- const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around));
4256
+ const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
4257
+ const layout = getLayout(transform, originPoint, data.around && L.getInnerOrigin(t, data.around));
4257
4258
  if (resize) {
4258
- const scaleX = layout.scaleX / t.scaleX;
4259
- const scaleY = layout.scaleY / t.scaleY;
4260
- delete layout.scaleX;
4261
- delete layout.scaleY;
4259
+ const scaleX = layout.scaleX / t.scaleX, scaleY = layout.scaleY / t.scaleY;
4260
+ delete layout.scaleX, delete layout.scaleY;
4261
+ if (originPoint) {
4262
+ BoundsHelper.scale(t.boxBounds, Math.abs(scaleX), Math.abs(scaleY));
4263
+ const changedPoint = L.getInnerOrigin(t, data.origin);
4264
+ PointHelper.move(layout, originPoint.x - changedPoint.x, originPoint.y - changedPoint.y);
4265
+ }
4262
4266
  t.set(layout);
4263
- t.scaleResize(scaleX, scaleY, resize !== true);
4267
+ t.scaleResize(scaleX, scaleY, false);
4264
4268
  }
4265
- else {
4269
+ else
4266
4270
  t.set(layout);
4267
- }
4268
4271
  },
4269
4272
  getFlipTransform(t, axis) {
4270
4273
  const m = getMatrixData();
@@ -4947,14 +4950,15 @@ class Eventer {
4947
4950
  if (list) {
4948
4951
  let item;
4949
4952
  for (let i = 0, len = list.length; i < len; i++) {
4950
- item = list[i];
4951
- item.listener(event);
4952
- if (item.once) {
4953
- this.off(type, item.listener, capture);
4954
- i--, len--;
4953
+ if (item = list[i]) {
4954
+ item.listener(event);
4955
+ if (item.once) {
4956
+ this.off(type, item.listener, capture);
4957
+ i--, len--;
4958
+ }
4959
+ if (event && event.isStopNow)
4960
+ break;
4955
4961
  }
4956
- if (event && event.isStopNow)
4957
- break;
4958
4962
  }
4959
4963
  }
4960
4964
  this.syncEventer && this.syncEventer.emitEvent(event, capture);
@@ -5431,7 +5435,7 @@ let Leaf = class Leaf {
5431
5435
  this.__[attrName] = value === undefined ? null : undefined;
5432
5436
  this[attrName] = value;
5433
5437
  }
5434
- forceRender(_bounds) {
5438
+ forceRender(_bounds, _sync) {
5435
5439
  this.forceUpdate('surface');
5436
5440
  }
5437
5441
  __updateWorldMatrix() { }
@@ -6001,7 +6005,7 @@ class LeafLevelList {
6001
6005
  }
6002
6006
  }
6003
6007
 
6004
- const version = "1.2.0";
6008
+ const version = "1.2.2";
6005
6009
 
6006
6010
  class LeaferCanvas extends LeaferCanvasBase {
6007
6011
  get allowBackgroundColor() { return true; }
@@ -7900,10 +7904,13 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7900
7904
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
7901
7905
  Object.keys(data).forEach(key => this[key] = data[key]);
7902
7906
  }
7903
- forceRender(bounds) {
7904
- this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7905
- if (this.viewReady)
7906
- this.renderer.render();
7907
+ forceRender(bounds, sync) {
7908
+ const { renderer } = this;
7909
+ if (renderer) {
7910
+ renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7911
+ if (this.viewReady)
7912
+ sync ? renderer.render() : renderer.update();
7913
+ }
7907
7914
  }
7908
7915
  requestRender(change = false) {
7909
7916
  if (this.renderer)
@@ -8020,6 +8027,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8020
8027
  this.requestRender();
8021
8028
  }
8022
8029
  }
8030
+ else
8031
+ this.requestRender();
8023
8032
  }
8024
8033
  __checkViewCompleted(emit = true) {
8025
8034
  this.nextRender(() => {
@@ -8585,10 +8594,10 @@ let Canvas = class Canvas extends Rect {
8585
8594
  __updateSize() {
8586
8595
  const { canvas } = this;
8587
8596
  if (canvas) {
8588
- const { smooth } = this.__;
8597
+ const { smooth, safeResize } = this.__;
8598
+ canvas.resize(this.__, safeResize);
8589
8599
  if (canvas.smooth !== smooth)
8590
8600
  canvas.smooth = smooth;
8591
- canvas.resize(this.__);
8592
8601
  }
8593
8602
  }
8594
8603
  destroy() {
@@ -8614,6 +8623,9 @@ __decorate([
8614
8623
  __decorate([
8615
8624
  resizeType(true)
8616
8625
  ], Canvas.prototype, "smooth", void 0);
8626
+ __decorate([
8627
+ dataType(false)
8628
+ ], Canvas.prototype, "safeResize", void 0);
8617
8629
  __decorate([
8618
8630
  resizeType()
8619
8631
  ], Canvas.prototype, "contextSettings", void 0);
@@ -8892,8 +8904,8 @@ let App = class App extends Leafer {
8892
8904
  super.lockLayout();
8893
8905
  this.children.forEach(leafer => leafer.lockLayout());
8894
8906
  }
8895
- forceRender(bounds) {
8896
- this.children.forEach(leafer => leafer.forceRender(bounds));
8907
+ forceRender(bounds, sync) {
8908
+ this.children.forEach(leafer => leafer.forceRender(bounds, sync));
8897
8909
  }
8898
8910
  addLeafer(merge) {
8899
8911
  const leafer = new Leafer(merge);