leafer-ui 1.0.10 → 1.1.0

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.
@@ -108,7 +108,7 @@ const MathHelper = {
108
108
  return rotation - oldRotation;
109
109
  },
110
110
  float(num, maxLength) {
111
- const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
111
+ const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
112
112
  num = round(num * a) / a;
113
113
  return num === -0 ? 0 : num;
114
114
  },
@@ -4165,20 +4165,17 @@ const LeafHelper = {
4165
4165
  }
4166
4166
  return true;
4167
4167
  },
4168
- moveWorld(t, x, y = 0, isInnerPoint) {
4168
+ moveWorld(t, x, y = 0, isInnerPoint, transition) {
4169
4169
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4170
4170
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
4171
- L.moveLocal(t, local.x, local.y);
4171
+ L.moveLocal(t, local.x, local.y, transition);
4172
4172
  },
4173
- moveLocal(t, x, y = 0) {
4174
- if (typeof x === 'object') {
4175
- t.x += x.x;
4176
- t.y += x.y;
4177
- }
4178
- else {
4179
- t.x += x;
4180
- t.y += y;
4181
- }
4173
+ moveLocal(t, x, y = 0, transition) {
4174
+ if (typeof x === 'object')
4175
+ y = x.y, x = x.x;
4176
+ x += t.x;
4177
+ y += t.y;
4178
+ transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4182
4179
  },
4183
4180
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4184
4181
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -5558,11 +5555,11 @@ let Leaf = class Leaf {
5558
5555
  transform(matrix, resize) {
5559
5556
  transform(this, matrix, resize);
5560
5557
  }
5561
- move(x, y) {
5562
- moveLocal(this, x, y);
5558
+ move(x, y, transition) {
5559
+ moveLocal(this, x, y, transition);
5563
5560
  }
5564
- moveInner(x, y) {
5565
- moveWorld(this, x, y, true);
5561
+ moveInner(x, y, transition) {
5562
+ moveWorld(this, x, y, true, transition);
5566
5563
  }
5567
5564
  scaleOf(origin, scaleX, scaleY, resize) {
5568
5565
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
@@ -5576,8 +5573,8 @@ let Leaf = class Leaf {
5576
5573
  transformWorld(worldTransform, resize) {
5577
5574
  transformWorld(this, worldTransform, resize);
5578
5575
  }
5579
- moveWorld(x, y) {
5580
- moveWorld(this, x, y);
5576
+ moveWorld(x, y, transition) {
5577
+ moveWorld(this, x, y, false, transition);
5581
5578
  }
5582
5579
  scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5583
5580
  zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
@@ -5975,7 +5972,7 @@ class LeafLevelList {
5975
5972
  }
5976
5973
  }
5977
5974
 
5978
- const version = "1.0.10";
5975
+ const version = "1.1.0";
5979
5976
 
5980
5977
  const debug$7 = Debug.get('LeaferCanvas');
5981
5978
  class LeaferCanvas extends LeaferCanvasBase {
@@ -7578,11 +7575,15 @@ let UI = UI_1 = class UI extends Leaf {
7578
7575
  super(data);
7579
7576
  }
7580
7577
  reset(_data) { }
7581
- set(data, isTemp) {
7582
- if (isTemp) {
7583
- this.lockNormalStyle = true;
7584
- Object.assign(this, data);
7585
- this.lockNormalStyle = false;
7578
+ set(data, transition) {
7579
+ if (transition) {
7580
+ if (transition === 'temp') {
7581
+ this.lockNormalStyle = true;
7582
+ Object.assign(this, data);
7583
+ this.lockNormalStyle = false;
7584
+ }
7585
+ else
7586
+ this.animate(data, transition);
7586
7587
  }
7587
7588
  else
7588
7589
  Object.assign(this, data);
@@ -7892,17 +7893,17 @@ let Group = class Group extends UI {
7892
7893
  if (!this.children)
7893
7894
  this.children = [];
7894
7895
  }
7895
- set(data, isTemp) {
7896
+ set(data, transition) {
7896
7897
  if (data.children) {
7897
7898
  const { children } = data;
7898
7899
  delete data.children;
7899
7900
  this.children ? this.clear() : this.__setBranch();
7900
- super.set(data, isTemp);
7901
+ super.set(data, transition);
7901
7902
  children.forEach(child => this.add(child));
7902
7903
  data.children = children;
7903
7904
  }
7904
7905
  else
7905
- super.set(data, isTemp);
7906
+ super.set(data, transition);
7906
7907
  }
7907
7908
  toJSON(options) {
7908
7909
  const data = super.toJSON(options);
@@ -8015,8 +8016,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8015
8016
  }
8016
8017
  onInit() { }
8017
8018
  initType(_type) { }
8018
- set(data) {
8019
- this.waitInit(() => { super.set(data); });
8019
+ set(data, transition) {
8020
+ this.waitInit(() => { super.set(data, transition); });
8020
8021
  }
8021
8022
  start() {
8022
8023
  clearTimeout(this.__startTimer);
@@ -9205,10 +9206,8 @@ let DragEvent = class DragEvent extends PointerEvent {
9205
9206
  this.data = data;
9206
9207
  }
9207
9208
  static getValidMove(leaf, start, total) {
9208
- const { draggable, dragBounds, x, y } = leaf;
9209
- const move = leaf.getLocalPoint(total, null, true);
9210
- move.x += start.x - x;
9211
- move.y += start.y - y;
9209
+ const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
9210
+ PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9212
9211
  if (dragBounds)
9213
9212
  this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
9214
9213
  if (draggable === 'x')
@@ -9218,8 +9217,7 @@ let DragEvent = class DragEvent extends PointerEvent {
9218
9217
  return move;
9219
9218
  }
9220
9219
  static getMoveInDragBounds(childBox, dragBounds, move, change) {
9221
- const x = childBox.x + move.x, y = childBox.y + move.y;
9222
- const right = x + childBox.width, bottom = y + childBox.height;
9220
+ const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
9223
9221
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9224
9222
  if (!change)
9225
9223
  move = Object.assign({}, move);
@@ -9271,9 +9269,7 @@ let DragEvent = class DragEvent extends PointerEvent {
9271
9269
  return this.getLocalMove(relative, true);
9272
9270
  }
9273
9271
  getPageBounds() {
9274
- const total = this.getPageTotal();
9275
- const start = this.getPagePoint();
9276
- const bounds = {};
9272
+ const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
9277
9273
  BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
9278
9274
  BoundsHelper.unsign(bounds);
9279
9275
  return bounds;
@@ -11013,6 +11009,8 @@ function stroke(stroke, ui, canvas) {
11013
11009
  case 'center':
11014
11010
  canvas.setStroke(stroke, __strokeWidth, options);
11015
11011
  canvas.stroke();
11012
+ if (options.__useArrow)
11013
+ strokeArrow(ui, canvas);
11016
11014
  break;
11017
11015
  case 'inside':
11018
11016
  canvas.save();
@@ -11050,6 +11048,8 @@ function strokes(strokes, ui, canvas) {
11050
11048
  case 'center':
11051
11049
  canvas.setStroke(undefined, __strokeWidth, options);
11052
11050
  drawStrokesStyle(strokes, false, ui, canvas);
11051
+ if (options.__useArrow)
11052
+ strokeArrow(ui, canvas);
11053
11053
  break;
11054
11054
  case 'inside':
11055
11055
  canvas.save();
@@ -11075,6 +11075,14 @@ function strokes(strokes, ui, canvas) {
11075
11075
  }
11076
11076
  }
11077
11077
  }
11078
+ function strokeArrow(ui, canvas) {
11079
+ if (ui.__.dashPattern) {
11080
+ canvas.beginPath();
11081
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
11082
+ canvas.dashPattern = null;
11083
+ canvas.stroke();
11084
+ }
11085
+ }
11078
11086
 
11079
11087
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
11080
11088
  function shape(ui, current, options) {