@leafer-draw/worker 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
  class LeaferCanvas extends LeaferCanvasBase {
5981
5978
  get allowBackgroundColor() { return true; }
@@ -7132,11 +7129,15 @@ let UI = UI_1 = class UI extends Leaf {
7132
7129
  super(data);
7133
7130
  }
7134
7131
  reset(_data) { }
7135
- set(data, isTemp) {
7136
- if (isTemp) {
7137
- this.lockNormalStyle = true;
7138
- Object.assign(this, data);
7139
- this.lockNormalStyle = false;
7132
+ set(data, transition) {
7133
+ if (transition) {
7134
+ if (transition === 'temp') {
7135
+ this.lockNormalStyle = true;
7136
+ Object.assign(this, data);
7137
+ this.lockNormalStyle = false;
7138
+ }
7139
+ else
7140
+ this.animate(data, transition);
7140
7141
  }
7141
7142
  else
7142
7143
  Object.assign(this, data);
@@ -7446,17 +7447,17 @@ let Group = class Group extends UI {
7446
7447
  if (!this.children)
7447
7448
  this.children = [];
7448
7449
  }
7449
- set(data, isTemp) {
7450
+ set(data, transition) {
7450
7451
  if (data.children) {
7451
7452
  const { children } = data;
7452
7453
  delete data.children;
7453
7454
  this.children ? this.clear() : this.__setBranch();
7454
- super.set(data, isTemp);
7455
+ super.set(data, transition);
7455
7456
  children.forEach(child => this.add(child));
7456
7457
  data.children = children;
7457
7458
  }
7458
7459
  else
7459
- super.set(data, isTemp);
7460
+ super.set(data, transition);
7460
7461
  }
7461
7462
  toJSON(options) {
7462
7463
  const data = super.toJSON(options);
@@ -7569,8 +7570,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7569
7570
  }
7570
7571
  onInit() { }
7571
7572
  initType(_type) { }
7572
- set(data) {
7573
- this.waitInit(() => { super.set(data); });
7573
+ set(data, transition) {
7574
+ this.waitInit(() => { super.set(data, transition); });
7574
7575
  }
7575
7576
  start() {
7576
7577
  clearTimeout(this.__startTimer);
@@ -8665,6 +8666,8 @@ function stroke(stroke, ui, canvas) {
8665
8666
  case 'center':
8666
8667
  canvas.setStroke(stroke, __strokeWidth, options);
8667
8668
  canvas.stroke();
8669
+ if (options.__useArrow)
8670
+ strokeArrow(ui, canvas);
8668
8671
  break;
8669
8672
  case 'inside':
8670
8673
  canvas.save();
@@ -8702,6 +8705,8 @@ function strokes(strokes, ui, canvas) {
8702
8705
  case 'center':
8703
8706
  canvas.setStroke(undefined, __strokeWidth, options);
8704
8707
  drawStrokesStyle(strokes, false, ui, canvas);
8708
+ if (options.__useArrow)
8709
+ strokeArrow(ui, canvas);
8705
8710
  break;
8706
8711
  case 'inside':
8707
8712
  canvas.save();
@@ -8727,6 +8732,14 @@ function strokes(strokes, ui, canvas) {
8727
8732
  }
8728
8733
  }
8729
8734
  }
8735
+ function strokeArrow(ui, canvas) {
8736
+ if (ui.__.dashPattern) {
8737
+ canvas.beginPath();
8738
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
8739
+ canvas.dashPattern = null;
8740
+ canvas.stroke();
8741
+ }
8742
+ }
8730
8743
 
8731
8744
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
8732
8745
  function shape(ui, current, options) {