leafer-ui 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
  const debug$6 = Debug.get('LeaferCanvas');
6007
6011
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6093,7 +6097,8 @@ class LeaferCanvas extends LeaferCanvasBase {
6093
6097
  this.view.height = Math.ceil(height * pixelRatio);
6094
6098
  }
6095
6099
  updateClientBounds() {
6096
- this.clientBounds = this.view.getBoundingClientRect();
6100
+ if (this.view.parentElement)
6101
+ this.clientBounds = this.view.getBoundingClientRect();
6097
6102
  }
6098
6103
  startAutoLayout(autoBounds, listener) {
6099
6104
  this.resizeListener = listener;
@@ -8073,10 +8078,13 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8073
8078
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
8074
8079
  Object.keys(data).forEach(key => this[key] = data[key]);
8075
8080
  }
8076
- forceRender(bounds) {
8077
- this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
8078
- if (this.viewReady)
8079
- this.renderer.render();
8081
+ forceRender(bounds, sync) {
8082
+ const { renderer } = this;
8083
+ if (renderer) {
8084
+ renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
8085
+ if (this.viewReady)
8086
+ sync ? renderer.render() : renderer.update();
8087
+ }
8080
8088
  }
8081
8089
  requestRender(change = false) {
8082
8090
  if (this.renderer)
@@ -8193,6 +8201,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8193
8201
  this.requestRender();
8194
8202
  }
8195
8203
  }
8204
+ else
8205
+ this.requestRender();
8196
8206
  }
8197
8207
  __checkViewCompleted(emit = true) {
8198
8208
  this.nextRender(() => {
@@ -8758,10 +8768,10 @@ let Canvas = class Canvas extends Rect {
8758
8768
  __updateSize() {
8759
8769
  const { canvas } = this;
8760
8770
  if (canvas) {
8761
- const { smooth } = this.__;
8771
+ const { smooth, safeResize } = this.__;
8772
+ canvas.resize(this.__, safeResize);
8762
8773
  if (canvas.smooth !== smooth)
8763
8774
  canvas.smooth = smooth;
8764
- canvas.resize(this.__);
8765
8775
  }
8766
8776
  }
8767
8777
  destroy() {
@@ -8787,6 +8797,9 @@ __decorate([
8787
8797
  __decorate([
8788
8798
  resizeType(true)
8789
8799
  ], Canvas.prototype, "smooth", void 0);
8800
+ __decorate([
8801
+ dataType(false)
8802
+ ], Canvas.prototype, "safeResize", void 0);
8790
8803
  __decorate([
8791
8804
  resizeType()
8792
8805
  ], Canvas.prototype, "contextSettings", void 0);
@@ -9065,8 +9078,8 @@ let App = class App extends Leafer {
9065
9078
  super.lockLayout();
9066
9079
  this.children.forEach(leafer => leafer.lockLayout());
9067
9080
  }
9068
- forceRender(bounds) {
9069
- this.children.forEach(leafer => leafer.forceRender(bounds));
9081
+ forceRender(bounds, sync) {
9082
+ this.children.forEach(leafer => leafer.forceRender(bounds, sync));
9070
9083
  }
9071
9084
  addLeafer(merge) {
9072
9085
  const leafer = new Leafer(merge);