leafer-ui 2.1.7 → 2.1.9

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.
@@ -952,12 +952,12 @@ class Point {
952
952
  PointHelper.scaleOf(this, origin, scaleX, scaleY);
953
953
  return this;
954
954
  }
955
- rotate(rotation, origin) {
956
- PointHelper.rotate(this, rotation, origin);
955
+ rotate(rotation, origin, radiusX, radiusY) {
956
+ PointHelper.rotate(this, rotation, origin, radiusX, radiusY);
957
957
  return this;
958
958
  }
959
- rotateOf(origin, rotation) {
960
- PointHelper.rotate(this, rotation, origin);
959
+ rotateOf(origin, rotation, radiusX, radiusY) {
960
+ PointHelper.rotate(this, rotation, origin, radiusX, radiusY);
961
961
  return this;
962
962
  }
963
963
  getRotation(origin, to, toOrigin) {
@@ -980,11 +980,11 @@ class Point {
980
980
  getDistancePoint(to, distance, changeTo, fromTo) {
981
981
  return new Point(PointHelper.getDistancePoint(this, to, distance, changeTo, fromTo));
982
982
  }
983
- getAngle(to) {
984
- return PointHelper.getAngle(this, to);
983
+ getAngle(to, radiusX, radiusY) {
984
+ return PointHelper.getAngle(this, to, radiusX, radiusY);
985
985
  }
986
- getAtan2(to) {
987
- return PointHelper.getAtan2(this, to);
986
+ getAtan2(to, radiusX, radiusY) {
987
+ return PointHelper.getAtan2(this, to, radiusX, radiusY);
988
988
  }
989
989
  isSame(point, quick) {
990
990
  return PointHelper.isSame(this, point, quick);
@@ -4586,7 +4586,9 @@ function sortType(defaultValue) {
4586
4586
  set(value) {
4587
4587
  if (this.__setAttr(key, value)) {
4588
4588
  this.waitParent(() => {
4589
- this.parent.__layout.childrenSortChange();
4589
+ const {parent: parent} = this;
4590
+ parent.__layout.childrenSortChange();
4591
+ if (parent.__.flow) parent.__layout.boxChange();
4590
4592
  });
4591
4593
  }
4592
4594
  }
@@ -4988,7 +4990,7 @@ const LeafHelper = {
4988
4990
  p = p.parent;
4989
4991
  }
4990
4992
  },
4991
- animateMove(t, move, speed = .3) {
4993
+ animateMove(t, move, speed = .3, onAnimate) {
4992
4994
  if (!move.x && !move.y) return;
4993
4995
  if (Math.abs(move.x) < 1 && Math.abs(move.y) < 1) {
4994
4996
  t.move(move);
@@ -4996,8 +4998,9 @@ const LeafHelper = {
4996
4998
  const x = move.x * speed, y = move.y * speed;
4997
4999
  move.x -= x, move.y -= y;
4998
5000
  t.move(x, y);
4999
- Platform.requestRender(() => L.animateMove(t, move, speed));
5001
+ Platform.requestRender(() => L.animateMove(t, move, speed, onAnimate));
5000
5002
  }
5003
+ onAnimate && onAnimate();
5001
5004
  }
5002
5005
  };
5003
5006
 
@@ -6169,6 +6172,7 @@ const LeafBounds = {
6169
6172
  if (this.isBranch) {
6170
6173
  this.__extraUpdate();
6171
6174
  if (this.__.flow) {
6175
+ if (this.__layout.childrenSortChanged) this.__updateSortChildren();
6172
6176
  if (this.__layout.boxChanged) this.__updateFlowLayout();
6173
6177
  updateAllMatrix$2(this);
6174
6178
  updateBounds$1(this, this);
@@ -6240,11 +6244,7 @@ const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper, {hasSize:
6240
6244
 
6241
6245
  const BranchRender = {
6242
6246
  __updateChange() {
6243
- const {__layout: layout} = this;
6244
- if (layout.childrenSortChanged) {
6245
- this.__updateSortChildren();
6246
- layout.childrenSortChanged = false;
6247
- }
6247
+ if (this.__layout.childrenSortChanged) this.__updateSortChildren();
6248
6248
  this.__.__checkSingle();
6249
6249
  },
6250
6250
  __render(canvas, options) {
@@ -6748,6 +6748,7 @@ let Branch = class Branch extends Leaf {
6748
6748
  children.sort(sort);
6749
6749
  this.__layout.affectChildrenSort = affectSort;
6750
6750
  }
6751
+ this.__layout.childrenSortChanged = false;
6751
6752
  }
6752
6753
  add(child, index) {
6753
6754
  if (child === this || child.destroyed) return debug$6.warn("add self or destroyed");
@@ -6983,7 +6984,7 @@ class LeafLevelList {
6983
6984
  }
6984
6985
  }
6985
6986
 
6986
- const version = "2.1.7";
6987
+ const version = "2.1.9";
6987
6988
 
6988
6989
  const debug$5 = Debug.get("LeaferCanvas");
6989
6990
 
@@ -7334,7 +7335,10 @@ class Watcher {
7334
7335
  if (this.running) this.target.emit(RenderEvent.REQUEST);
7335
7336
  }
7336
7337
  __onAttrChange(event) {
7337
- if (this.config.usePartLayout) this.__updatedList.add(event.target);
7338
+ this.add(event.target);
7339
+ }
7340
+ add(leaf) {
7341
+ if (this.config.usePartLayout) this.__updatedList.add(leaf);
7338
7342
  this.update();
7339
7343
  }
7340
7344
  __onChildEvent(event) {
@@ -8373,11 +8377,7 @@ class PolygonData extends UIData {
8373
8377
  }
8374
8378
  }
8375
8379
 
8376
- class StarData extends UIData {
8377
- get __boxStroke() {
8378
- return !this.__pathInputed;
8379
- }
8380
- }
8380
+ class StarData extends UIData {}
8381
8381
 
8382
8382
  class PathData extends UIData {
8383
8383
  get __pathInputed() {
@@ -9548,7 +9548,10 @@ let Ellipse = class Ellipse extends UI {
9548
9548
  ellipse(path, rx, ry, rx, ry, 0, outerStartAngle, outerEndAngle, outerAnticlockwise);
9549
9549
  } else {
9550
9550
  if (hasAngle) {
9551
- if (!closedAngle) moveTo$3(path, rx, ry);
9551
+ if (!closedAngle) {
9552
+ if (!closed) open = true;
9553
+ if (!open) moveTo$3(path, rx, ry);
9554
+ }
9552
9555
  ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle);
9553
9556
  } else {
9554
9557
  ellipse(path, rx, ry, rx, ry);
@@ -10226,8 +10229,8 @@ const DragBoundsHelper = {
10226
10229
  if (!change) scale = Object.assign({}, scale);
10227
10230
  tempDragBounds.set(dragBounds);
10228
10231
  tempContent.set(content).scaleOf(origin, scale.x, scale.y);
10229
- const originLeftScale = (origin.x - content.x) / content.width, originRightScale = 1 - originLeftScale;
10230
- const originTopScale = (origin.y - content.y) / content.height, originBottomScale = 1 - originTopScale;
10232
+ const originLeftScale = float((origin.x - content.x) / content.width), originRightScale = float(1 - originLeftScale);
10233
+ const originTopScale = float((origin.y - content.y) / content.height), originBottomScale = float(1 - originTopScale);
10231
10234
  let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
10232
10235
  if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
10233
10236
  if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
@@ -10238,7 +10241,13 @@ const DragBoundsHelper = {
10238
10241
  correctScaleX *= max$1(aScale, bScale);
10239
10242
  } else {
10240
10243
  if (scale.x < 0) {
10241
- if (float(minX(content) - minX(dragBounds)) <= 0 || float(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10244
+ if (float(minX(content) - minX(dragBounds), 2) <= 0 || float(maxX(dragBounds) - maxX(content), 2) <= 0) {
10245
+ tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10246
+ if (tempContent.width > 1) {
10247
+ correctScaleX *= 1 / tempContent.width;
10248
+ tempContent.width = 1;
10249
+ }
10250
+ }
10242
10251
  tempContent.unsign();
10243
10252
  }
10244
10253
  aSize = float(tempDragBounds.minX - tempContent.minX);
@@ -10261,7 +10270,13 @@ const DragBoundsHelper = {
10261
10270
  }
10262
10271
  } else {
10263
10272
  if (scale.y < 0) {
10264
- if (float(minY(content) - minY(dragBounds)) <= 0 || float(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10273
+ if (float(minY(content) - minY(dragBounds), 2) <= 0 || float(maxY(dragBounds) - maxY(content), 2) <= 0) {
10274
+ tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10275
+ if (tempContent.height > 1) {
10276
+ correctScaleY *= 1 / tempContent.height;
10277
+ tempContent.height = 1;
10278
+ }
10279
+ }
10265
10280
  tempContent.unsign();
10266
10281
  }
10267
10282
  aSize = float(tempDragBounds.minY - tempContent.minY);
@@ -10392,6 +10407,8 @@ DragEvent$1.ENTER = "drag.enter";
10392
10407
 
10393
10408
  DragEvent$1.LEAVE = "drag.leave";
10394
10409
 
10410
+ DragEvent$1.ANIMATE = "drag.animate";
10411
+
10395
10412
  DragEvent$1 = __decorate([ registerUIEvent() ], DragEvent$1);
10396
10413
 
10397
10414
  const MyDragEvent = DragEvent$1;
@@ -10646,7 +10663,7 @@ class Dragger {
10646
10663
  x: totalX,
10647
10664
  y: totalY
10648
10665
  }, checkLimitMove || axisDrag);
10649
- if (dragLimitAnimate && !axisDrag && isDragEnd) LeafHelper.animateMove(leaf, move, isNumber(dragLimitAnimate) ? dragLimitAnimate : .3); else leaf.move(move);
10666
+ if (dragLimitAnimate && !axisDrag && isDragEnd) LeafHelper.animateMove(leaf, move, isNumber(dragLimitAnimate) ? dragLimitAnimate : .3, () => leaf.emit(DragEvent$1.ANIMATE)); else leaf.move(move);
10650
10667
  }
10651
10668
  });
10652
10669
  }
@@ -12516,13 +12533,9 @@ function createPattern(paint, ui, canvas, renderOptions) {
12516
12533
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
12517
12534
  width *= scaleX;
12518
12535
  height *= scaleY;
12519
- if (gap) {
12536
+ if (gap && !brush) {
12520
12537
  xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
12521
12538
  yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
12522
- if (brush) {
12523
- const brushScale = PaintImage.getBrushScale(paint, ui);
12524
- xGap /= brushScale, yGap /= brushScale;
12525
- }
12526
12539
  }
12527
12540
  if (transform || scaleX !== 1 || scaleY !== 1) {
12528
12541
  scaleX *= getFloorScale(width + (xGap || 0));