@leafer-draw/miniapp 1.0.10 → 1.1.1

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
  },
@@ -1374,7 +1374,7 @@ function getNameList(name) {
1374
1374
  }
1375
1375
  const D$4 = Debug;
1376
1376
 
1377
- const debug$d = Debug.get('RunTime');
1377
+ const debug$e = Debug.get('RunTime');
1378
1378
  const Run = {
1379
1379
  currentId: 0,
1380
1380
  currentName: '',
@@ -1392,7 +1392,7 @@ const Run = {
1392
1392
  const time = R.idMap[id], name = R.nameMap[id];
1393
1393
  const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
1394
1394
  R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
1395
- debug$d.log(name, duration, 'ms');
1395
+ debug$e.log(name, duration, 'ms');
1396
1396
  },
1397
1397
  endOfName(name, microsecond) {
1398
1398
  const id = R.nameToIdMap[name];
@@ -1406,18 +1406,18 @@ function needPlugin(name) {
1406
1406
  console.error('need plugin: @leafer-in/' + name);
1407
1407
  }
1408
1408
 
1409
- const debug$c = Debug.get('UICreator');
1409
+ const debug$d = Debug.get('UICreator');
1410
1410
  const UICreator = {
1411
1411
  list: {},
1412
1412
  register(UI) {
1413
1413
  const { __tag: tag } = UI.prototype;
1414
1414
  if (list$1[tag])
1415
- debug$c.repeat(tag);
1415
+ debug$d.repeat(tag);
1416
1416
  list$1[tag] = UI;
1417
1417
  },
1418
1418
  get(tag, data, x, y, width, height) {
1419
1419
  if (!list$1[tag])
1420
- debug$c.error('not register ' + tag);
1420
+ debug$d.error('not register ' + tag);
1421
1421
  const ui = new list$1[tag](data);
1422
1422
  if (x !== undefined) {
1423
1423
  ui.x = x;
@@ -1433,7 +1433,7 @@ const UICreator = {
1433
1433
  };
1434
1434
  const { list: list$1 } = UICreator;
1435
1435
 
1436
- const debug$b = Debug.get('EventCreator');
1436
+ const debug$c = Debug.get('EventCreator');
1437
1437
  const EventCreator = {
1438
1438
  nameList: {},
1439
1439
  register(Event) {
@@ -1441,7 +1441,7 @@ const EventCreator = {
1441
1441
  Object.keys(Event).forEach(key => {
1442
1442
  name = Event[key];
1443
1443
  if (typeof name === 'string')
1444
- nameList[name] && debug$b.repeat(name), nameList[name] = Event;
1444
+ nameList[name] && debug$c.repeat(name), nameList[name] = Event;
1445
1445
  });
1446
1446
  },
1447
1447
  changeName(oldName, newName) {
@@ -1513,17 +1513,19 @@ const DataHelper = {
1513
1513
  assign(t, defaultData);
1514
1514
  return t;
1515
1515
  },
1516
- assign(t, merge) {
1516
+ assign(t, merge, exclude) {
1517
1517
  let value;
1518
1518
  Object.keys(merge).forEach(key => {
1519
- var _a;
1519
+ var _a, _b;
1520
1520
  value = merge[key];
1521
- if ((value === null || value === void 0 ? void 0 : value.constructor) === Object) {
1522
- (((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) ? assign(t[key], merge[key]) : t[key] = merge[key];
1523
- }
1524
- else {
1525
- t[key] = merge[key];
1521
+ if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object)
1522
+ return assign(t[key], merge[key], exclude && exclude[key]);
1523
+ if (exclude && (key in exclude)) {
1524
+ if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object)
1525
+ assign(t[key] = {}, merge[key], exclude[key]);
1526
+ return;
1526
1527
  }
1528
+ t[key] = merge[key];
1527
1529
  });
1528
1530
  },
1529
1531
  copyAttrs(t, from, include) {
@@ -2595,7 +2597,7 @@ const EllipseHelper = {
2595
2597
  const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
2596
2598
  const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2597
2599
  const { ellipticalArc } = EllipseHelper;
2598
- const debug$a = Debug.get('PathConvert');
2600
+ const debug$b = Debug.get('PathConvert');
2599
2601
  const setEndPoint$1 = {};
2600
2602
  const PathConvert = {
2601
2603
  current: { dot: 0 },
@@ -2836,7 +2838,7 @@ const PathConvert = {
2836
2838
  i += 6;
2837
2839
  break;
2838
2840
  default:
2839
- debug$a.error(`command: ${command} [index:${i}]`, old);
2841
+ debug$b.error(`command: ${command} [index:${i}]`, old);
2840
2842
  return data;
2841
2843
  }
2842
2844
  lastCommand = command;
@@ -3061,7 +3063,7 @@ class PathCreator {
3061
3063
  }
3062
3064
 
3063
3065
  const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
3064
- const debug$9 = Debug.get('PathDrawer');
3066
+ const debug$a = Debug.get('PathDrawer');
3065
3067
  const PathDrawer = {
3066
3068
  drawPathByData(drawer, data) {
3067
3069
  if (!data)
@@ -3124,7 +3126,7 @@ const PathDrawer = {
3124
3126
  i += 6;
3125
3127
  break;
3126
3128
  default:
3127
- debug$9.error(`command: ${command} [index:${i}]`, data);
3129
+ debug$a.error(`command: ${command} [index:${i}]`, data);
3128
3130
  return;
3129
3131
  }
3130
3132
  }
@@ -3134,7 +3136,7 @@ const PathDrawer = {
3134
3136
  const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
3135
3137
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3136
3138
  const { addPointBounds, copy: copy$7, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3137
- const debug$8 = Debug.get('PathBounds');
3139
+ const debug$9 = Debug.get('PathBounds');
3138
3140
  let radius, radiusX, radiusY;
3139
3141
  const tempPointBounds = {};
3140
3142
  const setPointBounds = {};
@@ -3242,7 +3244,7 @@ const PathBounds = {
3242
3244
  i += 6;
3243
3245
  break;
3244
3246
  default:
3245
- debug$8.error(`command: ${command} [index:${i}]`, data);
3247
+ debug$9.error(`command: ${command} [index:${i}]`, data);
3246
3248
  return;
3247
3249
  }
3248
3250
  }
@@ -3358,7 +3360,7 @@ const FileHelper = {
3358
3360
  const F = FileHelper;
3359
3361
  F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3360
3362
 
3361
- const debug$7 = Debug.get('TaskProcessor');
3363
+ const debug$8 = Debug.get('TaskProcessor');
3362
3364
  class TaskItem {
3363
3365
  constructor(task) {
3364
3366
  this.parallel = true;
@@ -3373,7 +3375,7 @@ class TaskItem {
3373
3375
  yield this.task();
3374
3376
  }
3375
3377
  catch (error) {
3376
- debug$7.error(error);
3378
+ debug$8.error(error);
3377
3379
  }
3378
3380
  });
3379
3381
  }
@@ -3891,6 +3893,8 @@ function opacityType(defaultValue) {
3891
3893
  return decorateLeafAttr(defaultValue, (key) => attr({
3892
3894
  set(value) {
3893
3895
  this.__setAttr(key, value) && (this.__layout.opacityChanged || this.__layout.opacityChange());
3896
+ if (this.mask)
3897
+ checkMask(this);
3894
3898
  }
3895
3899
  }));
3896
3900
  }
@@ -3907,9 +3911,20 @@ function visibleType(defaultValue) {
3907
3911
  this.__runAnimation('in');
3908
3912
  }
3909
3913
  doVisible(this, key, value, oldValue);
3914
+ if (this.mask)
3915
+ checkMask(this);
3910
3916
  }
3911
3917
  }));
3912
3918
  }
3919
+ function checkMask(leaf) {
3920
+ const { parent } = leaf;
3921
+ if (parent) {
3922
+ const { __hasMask } = parent;
3923
+ parent.__updateMask();
3924
+ if (__hasMask !== parent.__hasMask)
3925
+ parent.forceUpdate();
3926
+ }
3927
+ }
3913
3928
  function doVisible(leaf, key, value, oldValue) {
3914
3929
  if (leaf.__setAttr(key, value)) {
3915
3930
  leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
@@ -4047,7 +4062,7 @@ function defineDataProcessor(target, key, defaultValue) {
4047
4062
  defineKey(data, key, property);
4048
4063
  }
4049
4064
 
4050
- const debug$6 = new Debug('rewrite');
4065
+ const debug$7 = new Debug('rewrite');
4051
4066
  const list = [];
4052
4067
  const excludeNames = ['destroy', 'constructor'];
4053
4068
  function rewrite(method) {
@@ -4064,7 +4079,7 @@ function doRewrite(error) {
4064
4079
  if (list.length) {
4065
4080
  list.forEach(item => {
4066
4081
  if (error)
4067
- debug$6.error(item.name, '需在Class上装饰@rewriteAble()');
4082
+ debug$7.error(item.name, '需在Class上装饰@rewriteAble()');
4068
4083
  item.run();
4069
4084
  });
4070
4085
  list.length = 0;
@@ -4165,20 +4180,17 @@ const LeafHelper = {
4165
4180
  }
4166
4181
  return true;
4167
4182
  },
4168
- moveWorld(t, x, y = 0, isInnerPoint) {
4183
+ moveWorld(t, x, y = 0, isInnerPoint, transition) {
4169
4184
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4170
4185
  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);
4186
+ L.moveLocal(t, local.x, local.y, transition);
4172
4187
  },
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
- }
4188
+ moveLocal(t, x, y = 0, transition) {
4189
+ if (typeof x === 'object')
4190
+ y = x.y, x = x.x;
4191
+ x += t.x;
4192
+ y += t.y;
4193
+ transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4182
4194
  },
4183
4195
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4184
4196
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -4975,13 +4987,13 @@ const { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroy } =
4975
4987
  const LeafEventer = { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroyEventer: destroy };
4976
4988
 
4977
4989
  const { isFinite } = Number;
4978
- const debug$5 = Debug.get('setAttr');
4990
+ const debug$6 = Debug.get('setAttr');
4979
4991
  const LeafDataProxy = {
4980
4992
  __setAttr(name, newValue, checkFiniteNumber) {
4981
4993
  if (this.leaferIsCreated) {
4982
4994
  const oldValue = this.__.__getInput(name);
4983
4995
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4984
- debug$5.warn(this.innerName, name, newValue);
4996
+ debug$6.warn(this.innerName, name, newValue);
4985
4997
  newValue = undefined;
4986
4998
  }
4987
4999
  if (typeof newValue === 'object' || oldValue !== newValue) {
@@ -5437,8 +5449,8 @@ let Leaf = class Leaf {
5437
5449
  canvas.clearRect(r.x, r.y, r.width, r.height);
5438
5450
  canvas.restore();
5439
5451
  }
5440
- __updateMask(value) {
5441
- this.__hasMask = value ? true : this.children.some(item => item.__.mask);
5452
+ __updateMask(_value) {
5453
+ this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
5442
5454
  }
5443
5455
  __renderMask(_canvas, _options) { }
5444
5456
  __getNowWorld(options) {
@@ -5558,11 +5570,11 @@ let Leaf = class Leaf {
5558
5570
  transform(matrix, resize) {
5559
5571
  transform(this, matrix, resize);
5560
5572
  }
5561
- move(x, y) {
5562
- moveLocal(this, x, y);
5573
+ move(x, y, transition) {
5574
+ moveLocal(this, x, y, transition);
5563
5575
  }
5564
- moveInner(x, y) {
5565
- moveWorld(this, x, y, true);
5576
+ moveInner(x, y, transition) {
5577
+ moveWorld(this, x, y, true, transition);
5566
5578
  }
5567
5579
  scaleOf(origin, scaleX, scaleY, resize) {
5568
5580
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
@@ -5576,8 +5588,8 @@ let Leaf = class Leaf {
5576
5588
  transformWorld(worldTransform, resize) {
5577
5589
  transformWorld(this, worldTransform, resize);
5578
5590
  }
5579
- moveWorld(x, y) {
5580
- moveWorld(this, x, y);
5591
+ moveWorld(x, y, transition) {
5592
+ moveWorld(this, x, y, false, transition);
5581
5593
  }
5582
5594
  scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5583
5595
  zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
@@ -5681,6 +5693,7 @@ Leaf = __decorate([
5681
5693
  const { setListWithFn } = BoundsHelper;
5682
5694
  const { sort } = BranchHelper;
5683
5695
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5696
+ const debug$5 = new Debug('Branch');
5684
5697
  let Branch = class Branch extends Leaf {
5685
5698
  __updateStrokeSpread() {
5686
5699
  const { children } = this;
@@ -5721,8 +5734,8 @@ let Branch = class Branch extends Leaf {
5721
5734
  }
5722
5735
  }
5723
5736
  add(child, index) {
5724
- if (child === this)
5725
- return;
5737
+ if (child === this || child.destroyed)
5738
+ return debug$5.warn('add self or destroyed');
5726
5739
  const noIndex = index === undefined;
5727
5740
  if (!child.__) {
5728
5741
  if (child instanceof Array)
@@ -5736,8 +5749,9 @@ let Branch = class Branch extends Leaf {
5736
5749
  noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
5737
5750
  if (child.isBranch)
5738
5751
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5739
- child.__layout.boxChanged || child.__layout.boxChange();
5740
- child.__layout.matrixChanged || child.__layout.matrixChange();
5752
+ const childLayout = child.__layout;
5753
+ childLayout.boxChanged || childLayout.boxChange();
5754
+ childLayout.matrixChanged || childLayout.matrixChange();
5741
5755
  if (child.__bubbleMap)
5742
5756
  child.__emitLifeEvent(ChildEvent.ADD);
5743
5757
  if (this.leafer) {
@@ -5975,7 +5989,7 @@ class LeafLevelList {
5975
5989
  }
5976
5990
  }
5977
5991
 
5978
- const version = "1.0.10";
5992
+ const version = "1.1.1";
5979
5993
 
5980
5994
  class LeaferCanvas extends LeaferCanvasBase {
5981
5995
  get allowBackgroundColor() { return false; }
@@ -6560,25 +6574,25 @@ class Renderer {
6560
6574
  if (userConfig)
6561
6575
  this.config = DataHelper.default(userConfig, this.config);
6562
6576
  this.__listenEvents();
6563
- this.__requestRender();
6564
6577
  }
6565
6578
  start() {
6566
6579
  this.running = true;
6580
+ this.update(false);
6567
6581
  }
6568
6582
  stop() {
6569
6583
  this.running = false;
6570
6584
  }
6571
- update() {
6572
- this.changed = true;
6585
+ update(change = true) {
6586
+ if (!this.changed)
6587
+ this.changed = change;
6588
+ this.__requestRender();
6573
6589
  }
6574
6590
  requestLayout() {
6575
6591
  this.target.emit(LayoutEvent.REQUEST);
6576
6592
  }
6577
6593
  render(callback) {
6578
- if (!(this.running && this.canvas.view)) {
6579
- this.changed = true;
6580
- return;
6581
- }
6594
+ if (!(this.running && this.canvas.view))
6595
+ return this.update();
6582
6596
  const { target } = this;
6583
6597
  this.times = 0;
6584
6598
  this.totalBounds = new Bounds();
@@ -6712,16 +6726,17 @@ class Renderer {
6712
6726
  }
6713
6727
  }
6714
6728
  __requestRender() {
6715
- const startTime = Date.now();
6729
+ if (this.requestTime)
6730
+ return;
6731
+ const requestTime = this.requestTime = Date.now();
6716
6732
  Platform.requestRender(() => {
6717
- this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
6733
+ this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
6734
+ this.requestTime = 0;
6718
6735
  if (this.running) {
6719
6736
  if (this.changed && this.canvas.view)
6720
6737
  this.render();
6721
6738
  this.target.emit(RenderEvent.NEXT);
6722
6739
  }
6723
- if (this.target)
6724
- this.__requestRender();
6725
6740
  });
6726
6741
  }
6727
6742
  __onResize(e) {
@@ -6737,7 +6752,7 @@ class Renderer {
6737
6752
  }
6738
6753
  }
6739
6754
  this.addBlock(new Bounds(0, 0, 1, 1));
6740
- this.changed = true;
6755
+ this.update();
6741
6756
  }
6742
6757
  __onLayoutEnd(event) {
6743
6758
  if (event.data)
@@ -6872,7 +6887,7 @@ class UIData extends LeafData {
6872
6887
  return true;
6873
6888
  return t.fill && this.__hasStroke;
6874
6889
  }
6875
- get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
6890
+ get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
6876
6891
  get __autoWidth() { return !this._width; }
6877
6892
  get __autoHeight() { return !this._height; }
6878
6893
  get __autoSide() { return !this._width || !this._height; }
@@ -6986,7 +7001,7 @@ class GroupData extends UIData {
6986
7001
 
6987
7002
  class BoxData extends GroupData {
6988
7003
  get __boxStroke() { return !this.__pathInputed; }
6989
- get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
7004
+ get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
6990
7005
  get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
6991
7006
  }
6992
7007
 
@@ -7272,11 +7287,15 @@ let UI = UI_1 = class UI extends Leaf {
7272
7287
  super(data);
7273
7288
  }
7274
7289
  reset(_data) { }
7275
- set(data, isTemp) {
7276
- if (isTemp) {
7277
- this.lockNormalStyle = true;
7278
- Object.assign(this, data);
7279
- this.lockNormalStyle = false;
7290
+ set(data, transition) {
7291
+ if (transition) {
7292
+ if (transition === 'temp') {
7293
+ this.lockNormalStyle = true;
7294
+ Object.assign(this, data);
7295
+ this.lockNormalStyle = false;
7296
+ }
7297
+ else
7298
+ this.animate(data, transition);
7280
7299
  }
7281
7300
  else
7282
7301
  Object.assign(this, data);
@@ -7586,17 +7605,17 @@ let Group = class Group extends UI {
7586
7605
  if (!this.children)
7587
7606
  this.children = [];
7588
7607
  }
7589
- set(data, isTemp) {
7608
+ set(data, transition) {
7590
7609
  if (data.children) {
7591
7610
  const { children } = data;
7592
7611
  delete data.children;
7593
7612
  this.children ? this.clear() : this.__setBranch();
7594
- super.set(data, isTemp);
7613
+ super.set(data, transition);
7595
7614
  children.forEach(child => this.add(child));
7596
7615
  data.children = children;
7597
7616
  }
7598
7617
  else
7599
- super.set(data, isTemp);
7618
+ super.set(data, transition);
7600
7619
  }
7601
7620
  toJSON(options) {
7602
7621
  const data = super.toJSON(options);
@@ -7642,20 +7661,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7642
7661
  constructor(userConfig, data) {
7643
7662
  super(data);
7644
7663
  this.config = {
7645
- type: 'design',
7646
7664
  start: true,
7647
7665
  hittable: true,
7648
7666
  smooth: true,
7649
- lazySpeard: 100,
7650
- zoom: {
7651
- min: 0.01,
7652
- max: 256
7653
- },
7654
- move: {
7655
- holdSpaceKey: true,
7656
- holdMiddleKey: true,
7657
- autoDistance: 2
7658
- }
7667
+ lazySpeard: 100
7659
7668
  };
7660
7669
  this.leafs = 0;
7661
7670
  this.__eventIds = [];
@@ -7672,23 +7681,27 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7672
7681
  init(userConfig, parentApp) {
7673
7682
  if (this.canvas)
7674
7683
  return;
7675
- this.__setLeafer(this);
7676
- if (userConfig)
7677
- DataHelper.assign(this.config, userConfig);
7678
7684
  let start;
7679
7685
  const { config } = this;
7680
- this.initType(config.type);
7686
+ this.__setLeafer(this);
7687
+ if (parentApp) {
7688
+ this.parentApp = parentApp;
7689
+ this.__bindApp(parentApp);
7690
+ start = parentApp.running;
7691
+ }
7692
+ if (userConfig) {
7693
+ this.parent = parentApp;
7694
+ this.initType(userConfig.type);
7695
+ this.parent = undefined;
7696
+ DataHelper.assign(config, userConfig);
7697
+ }
7681
7698
  const canvas = this.canvas = Creator.canvas(config);
7682
7699
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7683
7700
  if (this.isApp)
7684
7701
  this.__setApp();
7685
7702
  this.__checkAutoLayout(config, parentApp);
7686
7703
  this.view = canvas.view;
7687
- if (parentApp) {
7688
- this.__bindApp(parentApp);
7689
- start = parentApp.running;
7690
- }
7691
- else {
7704
+ if (!parentApp) {
7692
7705
  this.selector = Creator.selector(this);
7693
7706
  this.interaction = Creator.interaction(this, canvas, this.selector, config);
7694
7707
  if (this.interaction) {
@@ -7709,8 +7722,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7709
7722
  }
7710
7723
  onInit() { }
7711
7724
  initType(_type) { }
7712
- set(data) {
7713
- this.waitInit(() => { super.set(data); });
7725
+ set(data, transition) {
7726
+ this.waitInit(() => { super.set(data, transition); });
7714
7727
  }
7715
7728
  start() {
7716
7729
  clearTimeout(this.__startTimer);
@@ -7745,7 +7758,11 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7745
7758
  forceRender(bounds) {
7746
7759
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7747
7760
  if (this.viewReady)
7748
- this.renderer.update();
7761
+ this.renderer.render();
7762
+ }
7763
+ requestRender(change = false) {
7764
+ if (this.renderer)
7765
+ this.renderer.update(change);
7749
7766
  }
7750
7767
  updateCursor(cursor) {
7751
7768
  const i = this.interaction;
@@ -7853,8 +7870,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7853
7870
  const { imageReady } = this;
7854
7871
  if (imageReady && !this.viewCompleted)
7855
7872
  this.__checkViewCompleted();
7856
- if (!imageReady)
7873
+ if (!imageReady) {
7857
7874
  this.viewCompleted = false;
7875
+ this.requestRender();
7876
+ }
7858
7877
  }
7859
7878
  }
7860
7879
  __checkViewCompleted(emit = true) {
@@ -7912,6 +7931,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7912
7931
  }
7913
7932
  else
7914
7933
  list.push(item);
7934
+ this.requestRender();
7915
7935
  }
7916
7936
  zoom(_zoomType, _padding, _fixedScale) {
7917
7937
  return needPlugin('view');
@@ -7965,7 +7985,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7965
7985
  this.canvasManager.destroy();
7966
7986
  }
7967
7987
  this.canvas.destroy();
7968
- this.config.view = this.view = null;
7988
+ this.config.view = this.view = this.parentApp = null;
7969
7989
  if (this.userConfig)
7970
7990
  this.userConfig.view = null;
7971
7991
  super.destroy();
@@ -8805,6 +8825,8 @@ function stroke(stroke, ui, canvas) {
8805
8825
  case 'center':
8806
8826
  canvas.setStroke(stroke, __strokeWidth, options);
8807
8827
  canvas.stroke();
8828
+ if (options.__useArrow)
8829
+ strokeArrow(ui, canvas);
8808
8830
  break;
8809
8831
  case 'inside':
8810
8832
  canvas.save();
@@ -8842,6 +8864,8 @@ function strokes(strokes, ui, canvas) {
8842
8864
  case 'center':
8843
8865
  canvas.setStroke(undefined, __strokeWidth, options);
8844
8866
  drawStrokesStyle(strokes, false, ui, canvas);
8867
+ if (options.__useArrow)
8868
+ strokeArrow(ui, canvas);
8845
8869
  break;
8846
8870
  case 'inside':
8847
8871
  canvas.save();
@@ -8867,6 +8891,14 @@ function strokes(strokes, ui, canvas) {
8867
8891
  }
8868
8892
  }
8869
8893
  }
8894
+ function strokeArrow(ui, canvas) {
8895
+ if (ui.__.dashPattern) {
8896
+ canvas.beginPath();
8897
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
8898
+ canvas.dashPattern = null;
8899
+ canvas.stroke();
8900
+ }
8901
+ }
8870
8902
 
8871
8903
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
8872
8904
  function shape(ui, current, options) {