leafer-game 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.
package/dist/web.js CHANGED
@@ -904,12 +904,12 @@ var LeaferUI = function(exports) {
904
904
  PointHelper.scaleOf(this, origin, scaleX, scaleY);
905
905
  return this;
906
906
  }
907
- rotate(rotation, origin) {
908
- PointHelper.rotate(this, rotation, origin);
907
+ rotate(rotation, origin, radiusX, radiusY) {
908
+ PointHelper.rotate(this, rotation, origin, radiusX, radiusY);
909
909
  return this;
910
910
  }
911
- rotateOf(origin, rotation) {
912
- PointHelper.rotate(this, rotation, origin);
911
+ rotateOf(origin, rotation, radiusX, radiusY) {
912
+ PointHelper.rotate(this, rotation, origin, radiusX, radiusY);
913
913
  return this;
914
914
  }
915
915
  getRotation(origin, to, toOrigin) {
@@ -932,11 +932,11 @@ var LeaferUI = function(exports) {
932
932
  getDistancePoint(to, distance, changeTo, fromTo) {
933
933
  return new Point(PointHelper.getDistancePoint(this, to, distance, changeTo, fromTo));
934
934
  }
935
- getAngle(to) {
936
- return PointHelper.getAngle(this, to);
935
+ getAngle(to, radiusX, radiusY) {
936
+ return PointHelper.getAngle(this, to, radiusX, radiusY);
937
937
  }
938
- getAtan2(to) {
939
- return PointHelper.getAtan2(this, to);
938
+ getAtan2(to, radiusX, radiusY) {
939
+ return PointHelper.getAtan2(this, to, radiusX, radiusY);
940
940
  }
941
941
  isSame(point, quick) {
942
942
  return PointHelper.isSame(this, point, quick);
@@ -4310,7 +4310,9 @@ var LeaferUI = function(exports) {
4310
4310
  set(value) {
4311
4311
  if (this.__setAttr(key, value)) {
4312
4312
  this.waitParent(() => {
4313
- this.parent.__layout.childrenSortChange();
4313
+ const {parent: parent} = this;
4314
+ parent.__layout.childrenSortChange();
4315
+ if (parent.__.flow) parent.__layout.boxChange();
4314
4316
  });
4315
4317
  }
4316
4318
  }
@@ -4691,7 +4693,7 @@ var LeaferUI = function(exports) {
4691
4693
  p = p.parent;
4692
4694
  }
4693
4695
  },
4694
- animateMove(t, move, speed = .3) {
4696
+ animateMove(t, move, speed = .3, onAnimate) {
4695
4697
  if (!move.x && !move.y) return;
4696
4698
  if (Math.abs(move.x) < 1 && Math.abs(move.y) < 1) {
4697
4699
  t.move(move);
@@ -4699,8 +4701,9 @@ var LeaferUI = function(exports) {
4699
4701
  const x = move.x * speed, y = move.y * speed;
4700
4702
  move.x -= x, move.y -= y;
4701
4703
  t.move(x, y);
4702
- Platform.requestRender(() => L$1.animateMove(t, move, speed));
4704
+ Platform.requestRender(() => L$1.animateMove(t, move, speed, onAnimate));
4703
4705
  }
4706
+ onAnimate && onAnimate();
4704
4707
  }
4705
4708
  };
4706
4709
  const L$1 = LeafHelper;
@@ -5774,6 +5777,7 @@ var LeaferUI = function(exports) {
5774
5777
  if (this.isBranch) {
5775
5778
  this.__extraUpdate();
5776
5779
  if (this.__.flow) {
5780
+ if (this.__layout.childrenSortChanged) this.__updateSortChildren();
5777
5781
  if (this.__layout.boxChanged) this.__updateFlowLayout();
5778
5782
  updateAllMatrix$3(this);
5779
5783
  updateBounds$2(this, this);
@@ -5842,11 +5846,7 @@ var LeaferUI = function(exports) {
5842
5846
  const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper, {hasSize: hasSize} = BoundsHelper;
5843
5847
  const BranchRender = {
5844
5848
  __updateChange() {
5845
- const {__layout: layout} = this;
5846
- if (layout.childrenSortChanged) {
5847
- this.__updateSortChildren();
5848
- layout.childrenSortChanged = false;
5849
- }
5849
+ if (this.__layout.childrenSortChanged) this.__updateSortChildren();
5850
5850
  this.__.__checkSingle();
5851
5851
  },
5852
5852
  __render(canvas, options) {
@@ -6336,6 +6336,7 @@ var LeaferUI = function(exports) {
6336
6336
  children.sort(sort);
6337
6337
  this.__layout.affectChildrenSort = affectSort;
6338
6338
  }
6339
+ this.__layout.childrenSortChanged = false;
6339
6340
  }
6340
6341
  add(child, index) {
6341
6342
  if (child === this || child.destroyed) return debug$6.warn("add self or destroyed");
@@ -6567,7 +6568,7 @@ var LeaferUI = function(exports) {
6567
6568
  this.levelMap = null;
6568
6569
  }
6569
6570
  }
6570
- const version = "2.1.7";
6571
+ const version = "2.1.9";
6571
6572
  const debug$5 = Debug.get("LeaferCanvas");
6572
6573
  class LeaferCanvas extends LeaferCanvasBase {
6573
6574
  set zIndex(zIndex) {
@@ -6904,7 +6905,10 @@ var LeaferUI = function(exports) {
6904
6905
  if (this.running) this.target.emit(RenderEvent.REQUEST);
6905
6906
  }
6906
6907
  __onAttrChange(event) {
6907
- if (this.config.usePartLayout) this.__updatedList.add(event.target);
6908
+ this.add(event.target);
6909
+ }
6910
+ add(leaf) {
6911
+ if (this.config.usePartLayout) this.__updatedList.add(leaf);
6908
6912
  this.update();
6909
6913
  }
6910
6914
  __onChildEvent(event) {
@@ -7890,11 +7894,7 @@ var LeaferUI = function(exports) {
7890
7894
  return this.points || this.__pathInputed;
7891
7895
  }
7892
7896
  }
7893
- class StarData extends UIData {
7894
- get __boxStroke() {
7895
- return !this.__pathInputed;
7896
- }
7897
- }
7897
+ class StarData extends UIData {}
7898
7898
  class PathData extends UIData {
7899
7899
  get __pathInputed() {
7900
7900
  return 2;
@@ -8938,7 +8938,10 @@ var LeaferUI = function(exports) {
8938
8938
  ellipse(path, rx, ry, rx, ry, 0, outerStartAngle, outerEndAngle, outerAnticlockwise);
8939
8939
  } else {
8940
8940
  if (hasAngle) {
8941
- if (!closedAngle) moveTo$3(path, rx, ry);
8941
+ if (!closedAngle) {
8942
+ if (!closed) open = true;
8943
+ if (!open) moveTo$3(path, rx, ry);
8944
+ }
8942
8945
  ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle);
8943
8946
  } else {
8944
8947
  ellipse(path, rx, ry, rx, ry);
@@ -9522,8 +9525,8 @@ var LeaferUI = function(exports) {
9522
9525
  if (!change) scale = Object.assign({}, scale);
9523
9526
  tempDragBounds.set(dragBounds);
9524
9527
  tempContent.set(content).scaleOf(origin, scale.x, scale.y);
9525
- const originLeftScale = (origin.x - content.x) / content.width, originRightScale = 1 - originLeftScale;
9526
- const originTopScale = (origin.y - content.y) / content.height, originBottomScale = 1 - originTopScale;
9528
+ const originLeftScale = float$2((origin.x - content.x) / content.width), originRightScale = float$2(1 - originLeftScale);
9529
+ const originTopScale = float$2((origin.y - content.y) / content.height), originBottomScale = float$2(1 - originTopScale);
9527
9530
  let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
9528
9531
  if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
9529
9532
  if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
@@ -9534,7 +9537,13 @@ var LeaferUI = function(exports) {
9534
9537
  correctScaleX *= max$1(aScale, bScale);
9535
9538
  } else {
9536
9539
  if (scale.x < 0) {
9537
- if (float$2(minX(content) - minX(dragBounds)) <= 0 || float$2(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9540
+ if (float$2(minX(content) - minX(dragBounds), 2) <= 0 || float$2(maxX(dragBounds) - maxX(content), 2) <= 0) {
9541
+ tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9542
+ if (tempContent.width > 1) {
9543
+ correctScaleX *= 1 / tempContent.width;
9544
+ tempContent.width = 1;
9545
+ }
9546
+ }
9538
9547
  tempContent.unsign();
9539
9548
  }
9540
9549
  aSize = float$2(tempDragBounds.minX - tempContent.minX);
@@ -9557,7 +9566,13 @@ var LeaferUI = function(exports) {
9557
9566
  }
9558
9567
  } else {
9559
9568
  if (scale.y < 0) {
9560
- if (float$2(minY(content) - minY(dragBounds)) <= 0 || float$2(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9569
+ if (float$2(minY(content) - minY(dragBounds), 2) <= 0 || float$2(maxY(dragBounds) - maxY(content), 2) <= 0) {
9570
+ tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9571
+ if (tempContent.height > 1) {
9572
+ correctScaleY *= 1 / tempContent.height;
9573
+ tempContent.height = 1;
9574
+ }
9575
+ }
9561
9576
  tempContent.unsign();
9562
9577
  }
9563
9578
  aSize = float$2(tempDragBounds.minY - tempContent.minY);
@@ -9654,6 +9669,7 @@ var LeaferUI = function(exports) {
9654
9669
  exports.DragEvent.OUT = "drag.out";
9655
9670
  exports.DragEvent.ENTER = "drag.enter";
9656
9671
  exports.DragEvent.LEAVE = "drag.leave";
9672
+ exports.DragEvent.ANIMATE = "drag.animate";
9657
9673
  exports.DragEvent = __decorate([ registerUIEvent() ], exports.DragEvent);
9658
9674
  const MyDragEvent = exports.DragEvent;
9659
9675
  exports.DropEvent = class DropEvent extends exports.PointerEvent {
@@ -9861,7 +9877,7 @@ var LeaferUI = function(exports) {
9861
9877
  x: totalX,
9862
9878
  y: totalY
9863
9879
  }, checkLimitMove || axisDrag);
9864
- if (dragLimitAnimate && !axisDrag && isDragEnd) LeafHelper.animateMove(leaf, move, isNumber(dragLimitAnimate) ? dragLimitAnimate : .3); else leaf.move(move);
9880
+ if (dragLimitAnimate && !axisDrag && isDragEnd) LeafHelper.animateMove(leaf, move, isNumber(dragLimitAnimate) ? dragLimitAnimate : .3, () => leaf.emit(exports.DragEvent.ANIMATE)); else leaf.move(move);
9865
9881
  }
9866
9882
  });
9867
9883
  }
@@ -11641,13 +11657,9 @@ var LeaferUI = function(exports) {
11641
11657
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
11642
11658
  width *= scaleX;
11643
11659
  height *= scaleY;
11644
- if (gap) {
11660
+ if (gap && !brush) {
11645
11661
  xGap = gap.x * scaleX / abs$2(data.scaleX || 1);
11646
11662
  yGap = gap.y * scaleY / abs$2(data.scaleY || 1);
11647
- if (brush) {
11648
- const brushScale = PaintImage.getBrushScale(paint, ui);
11649
- xGap /= brushScale, yGap /= brushScale;
11650
- }
11651
11663
  }
11652
11664
  if (transform || scaleX !== 1 || scaleY !== 1) {
11653
11665
  scaleX *= getFloorScale(width + (xGap || 0));