leafer-draw 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.
package/dist/web.js CHANGED
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
111
111
  return rotation - oldRotation;
112
112
  },
113
113
  float(num, maxLength) {
114
- const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
114
+ const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
115
115
  num = round(num * a) / a;
116
116
  return num === -0 ? 0 : num;
117
117
  },
@@ -1377,7 +1377,7 @@ var LeaferUI = (function (exports) {
1377
1377
  }
1378
1378
  const D$4 = Debug;
1379
1379
 
1380
- const debug$e = Debug.get('RunTime');
1380
+ const debug$f = Debug.get('RunTime');
1381
1381
  const Run = {
1382
1382
  currentId: 0,
1383
1383
  currentName: '',
@@ -1395,7 +1395,7 @@ var LeaferUI = (function (exports) {
1395
1395
  const time = R.idMap[id], name = R.nameMap[id];
1396
1396
  const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
1397
1397
  R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
1398
- debug$e.log(name, duration, 'ms');
1398
+ debug$f.log(name, duration, 'ms');
1399
1399
  },
1400
1400
  endOfName(name, microsecond) {
1401
1401
  const id = R.nameToIdMap[name];
@@ -1409,18 +1409,18 @@ var LeaferUI = (function (exports) {
1409
1409
  console.error('need plugin: @leafer-in/' + name);
1410
1410
  }
1411
1411
 
1412
- const debug$d = Debug.get('UICreator');
1412
+ const debug$e = Debug.get('UICreator');
1413
1413
  const UICreator = {
1414
1414
  list: {},
1415
1415
  register(UI) {
1416
1416
  const { __tag: tag } = UI.prototype;
1417
1417
  if (list$1[tag])
1418
- debug$d.repeat(tag);
1418
+ debug$e.repeat(tag);
1419
1419
  list$1[tag] = UI;
1420
1420
  },
1421
1421
  get(tag, data, x, y, width, height) {
1422
1422
  if (!list$1[tag])
1423
- debug$d.error('not register ' + tag);
1423
+ debug$e.error('not register ' + tag);
1424
1424
  const ui = new list$1[tag](data);
1425
1425
  if (x !== undefined) {
1426
1426
  ui.x = x;
@@ -1436,7 +1436,7 @@ var LeaferUI = (function (exports) {
1436
1436
  };
1437
1437
  const { list: list$1 } = UICreator;
1438
1438
 
1439
- const debug$c = Debug.get('EventCreator');
1439
+ const debug$d = Debug.get('EventCreator');
1440
1440
  const EventCreator = {
1441
1441
  nameList: {},
1442
1442
  register(Event) {
@@ -1444,7 +1444,7 @@ var LeaferUI = (function (exports) {
1444
1444
  Object.keys(Event).forEach(key => {
1445
1445
  name = Event[key];
1446
1446
  if (typeof name === 'string')
1447
- nameList[name] && debug$c.repeat(name), nameList[name] = Event;
1447
+ nameList[name] && debug$d.repeat(name), nameList[name] = Event;
1448
1448
  });
1449
1449
  },
1450
1450
  changeName(oldName, newName) {
@@ -1516,17 +1516,19 @@ var LeaferUI = (function (exports) {
1516
1516
  assign(t, defaultData);
1517
1517
  return t;
1518
1518
  },
1519
- assign(t, merge) {
1519
+ assign(t, merge, exclude) {
1520
1520
  let value;
1521
1521
  Object.keys(merge).forEach(key => {
1522
- var _a;
1522
+ var _a, _b;
1523
1523
  value = merge[key];
1524
- if ((value === null || value === void 0 ? void 0 : value.constructor) === Object) {
1525
- (((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) ? assign(t[key], merge[key]) : t[key] = merge[key];
1526
- }
1527
- else {
1528
- t[key] = merge[key];
1524
+ if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object)
1525
+ return assign(t[key], merge[key], exclude && exclude[key]);
1526
+ if (exclude && (key in exclude)) {
1527
+ if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object)
1528
+ assign(t[key] = {}, merge[key], exclude[key]);
1529
+ return;
1529
1530
  }
1531
+ t[key] = merge[key];
1530
1532
  });
1531
1533
  },
1532
1534
  copyAttrs(t, from, include) {
@@ -2598,7 +2600,7 @@ var LeaferUI = (function (exports) {
2598
2600
  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;
2599
2601
  const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2600
2602
  const { ellipticalArc } = EllipseHelper;
2601
- const debug$b = Debug.get('PathConvert');
2603
+ const debug$c = Debug.get('PathConvert');
2602
2604
  const setEndPoint$1 = {};
2603
2605
  const PathConvert = {
2604
2606
  current: { dot: 0 },
@@ -2839,7 +2841,7 @@ var LeaferUI = (function (exports) {
2839
2841
  i += 6;
2840
2842
  break;
2841
2843
  default:
2842
- debug$b.error(`command: ${command} [index:${i}]`, old);
2844
+ debug$c.error(`command: ${command} [index:${i}]`, old);
2843
2845
  return data;
2844
2846
  }
2845
2847
  lastCommand = command;
@@ -3064,7 +3066,7 @@ var LeaferUI = (function (exports) {
3064
3066
  }
3065
3067
 
3066
3068
  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;
3067
- const debug$a = Debug.get('PathDrawer');
3069
+ const debug$b = Debug.get('PathDrawer');
3068
3070
  const PathDrawer = {
3069
3071
  drawPathByData(drawer, data) {
3070
3072
  if (!data)
@@ -3127,7 +3129,7 @@ var LeaferUI = (function (exports) {
3127
3129
  i += 6;
3128
3130
  break;
3129
3131
  default:
3130
- debug$a.error(`command: ${command} [index:${i}]`, data);
3132
+ debug$b.error(`command: ${command} [index:${i}]`, data);
3131
3133
  return;
3132
3134
  }
3133
3135
  }
@@ -3137,7 +3139,7 @@ var LeaferUI = (function (exports) {
3137
3139
  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;
3138
3140
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3139
3141
  const { addPointBounds, copy: copy$7, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3140
- const debug$9 = Debug.get('PathBounds');
3142
+ const debug$a = Debug.get('PathBounds');
3141
3143
  let radius, radiusX, radiusY;
3142
3144
  const tempPointBounds = {};
3143
3145
  const setPointBounds = {};
@@ -3245,7 +3247,7 @@ var LeaferUI = (function (exports) {
3245
3247
  i += 6;
3246
3248
  break;
3247
3249
  default:
3248
- debug$9.error(`command: ${command} [index:${i}]`, data);
3250
+ debug$a.error(`command: ${command} [index:${i}]`, data);
3249
3251
  return;
3250
3252
  }
3251
3253
  }
@@ -3361,7 +3363,7 @@ var LeaferUI = (function (exports) {
3361
3363
  const F = FileHelper;
3362
3364
  F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3363
3365
 
3364
- const debug$8 = Debug.get('TaskProcessor');
3366
+ const debug$9 = Debug.get('TaskProcessor');
3365
3367
  class TaskItem {
3366
3368
  constructor(task) {
3367
3369
  this.parallel = true;
@@ -3376,7 +3378,7 @@ var LeaferUI = (function (exports) {
3376
3378
  yield this.task();
3377
3379
  }
3378
3380
  catch (error) {
3379
- debug$8.error(error);
3381
+ debug$9.error(error);
3380
3382
  }
3381
3383
  });
3382
3384
  }
@@ -3894,6 +3896,8 @@ var LeaferUI = (function (exports) {
3894
3896
  return decorateLeafAttr(defaultValue, (key) => attr({
3895
3897
  set(value) {
3896
3898
  this.__setAttr(key, value) && (this.__layout.opacityChanged || this.__layout.opacityChange());
3899
+ if (this.mask)
3900
+ checkMask(this);
3897
3901
  }
3898
3902
  }));
3899
3903
  }
@@ -3910,9 +3914,20 @@ var LeaferUI = (function (exports) {
3910
3914
  this.__runAnimation('in');
3911
3915
  }
3912
3916
  doVisible(this, key, value, oldValue);
3917
+ if (this.mask)
3918
+ checkMask(this);
3913
3919
  }
3914
3920
  }));
3915
3921
  }
3922
+ function checkMask(leaf) {
3923
+ const { parent } = leaf;
3924
+ if (parent) {
3925
+ const { __hasMask } = parent;
3926
+ parent.__updateMask();
3927
+ if (__hasMask !== parent.__hasMask)
3928
+ parent.forceUpdate();
3929
+ }
3930
+ }
3916
3931
  function doVisible(leaf, key, value, oldValue) {
3917
3932
  if (leaf.__setAttr(key, value)) {
3918
3933
  leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
@@ -4050,7 +4065,7 @@ var LeaferUI = (function (exports) {
4050
4065
  defineKey(data, key, property);
4051
4066
  }
4052
4067
 
4053
- const debug$7 = new Debug('rewrite');
4068
+ const debug$8 = new Debug('rewrite');
4054
4069
  const list = [];
4055
4070
  const excludeNames = ['destroy', 'constructor'];
4056
4071
  function rewrite(method) {
@@ -4067,7 +4082,7 @@ var LeaferUI = (function (exports) {
4067
4082
  if (list.length) {
4068
4083
  list.forEach(item => {
4069
4084
  if (error)
4070
- debug$7.error(item.name, '需在Class上装饰@rewriteAble()');
4085
+ debug$8.error(item.name, '需在Class上装饰@rewriteAble()');
4071
4086
  item.run();
4072
4087
  });
4073
4088
  list.length = 0;
@@ -4168,20 +4183,17 @@ var LeaferUI = (function (exports) {
4168
4183
  }
4169
4184
  return true;
4170
4185
  },
4171
- moveWorld(t, x, y = 0, isInnerPoint) {
4186
+ moveWorld(t, x, y = 0, isInnerPoint, transition) {
4172
4187
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4173
4188
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
4174
- L.moveLocal(t, local.x, local.y);
4189
+ L.moveLocal(t, local.x, local.y, transition);
4175
4190
  },
4176
- moveLocal(t, x, y = 0) {
4177
- if (typeof x === 'object') {
4178
- t.x += x.x;
4179
- t.y += x.y;
4180
- }
4181
- else {
4182
- t.x += x;
4183
- t.y += y;
4184
- }
4191
+ moveLocal(t, x, y = 0, transition) {
4192
+ if (typeof x === 'object')
4193
+ y = x.y, x = x.x;
4194
+ x += t.x;
4195
+ y += t.y;
4196
+ transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4185
4197
  },
4186
4198
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4187
4199
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -4978,13 +4990,13 @@ var LeaferUI = (function (exports) {
4978
4990
  const LeafEventer = { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroyEventer: destroy };
4979
4991
 
4980
4992
  const { isFinite } = Number;
4981
- const debug$6 = Debug.get('setAttr');
4993
+ const debug$7 = Debug.get('setAttr');
4982
4994
  const LeafDataProxy = {
4983
4995
  __setAttr(name, newValue, checkFiniteNumber) {
4984
4996
  if (this.leaferIsCreated) {
4985
4997
  const oldValue = this.__.__getInput(name);
4986
4998
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4987
- debug$6.warn(this.innerName, name, newValue);
4999
+ debug$7.warn(this.innerName, name, newValue);
4988
5000
  newValue = undefined;
4989
5001
  }
4990
5002
  if (typeof newValue === 'object' || oldValue !== newValue) {
@@ -5440,8 +5452,8 @@ var LeaferUI = (function (exports) {
5440
5452
  canvas.clearRect(r.x, r.y, r.width, r.height);
5441
5453
  canvas.restore();
5442
5454
  }
5443
- __updateMask(value) {
5444
- this.__hasMask = value ? true : this.children.some(item => item.__.mask);
5455
+ __updateMask(_value) {
5456
+ this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
5445
5457
  }
5446
5458
  __renderMask(_canvas, _options) { }
5447
5459
  __getNowWorld(options) {
@@ -5561,11 +5573,11 @@ var LeaferUI = (function (exports) {
5561
5573
  transform(matrix, resize) {
5562
5574
  transform(this, matrix, resize);
5563
5575
  }
5564
- move(x, y) {
5565
- moveLocal(this, x, y);
5576
+ move(x, y, transition) {
5577
+ moveLocal(this, x, y, transition);
5566
5578
  }
5567
- moveInner(x, y) {
5568
- moveWorld(this, x, y, true);
5579
+ moveInner(x, y, transition) {
5580
+ moveWorld(this, x, y, true, transition);
5569
5581
  }
5570
5582
  scaleOf(origin, scaleX, scaleY, resize) {
5571
5583
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
@@ -5579,8 +5591,8 @@ var LeaferUI = (function (exports) {
5579
5591
  transformWorld(worldTransform, resize) {
5580
5592
  transformWorld(this, worldTransform, resize);
5581
5593
  }
5582
- moveWorld(x, y) {
5583
- moveWorld(this, x, y);
5594
+ moveWorld(x, y, transition) {
5595
+ moveWorld(this, x, y, false, transition);
5584
5596
  }
5585
5597
  scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5586
5598
  zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
@@ -5684,6 +5696,7 @@ var LeaferUI = (function (exports) {
5684
5696
  const { setListWithFn } = BoundsHelper;
5685
5697
  const { sort } = BranchHelper;
5686
5698
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5699
+ const debug$6 = new Debug('Branch');
5687
5700
  exports.Branch = class Branch extends exports.Leaf {
5688
5701
  __updateStrokeSpread() {
5689
5702
  const { children } = this;
@@ -5724,8 +5737,8 @@ var LeaferUI = (function (exports) {
5724
5737
  }
5725
5738
  }
5726
5739
  add(child, index) {
5727
- if (child === this)
5728
- return;
5740
+ if (child === this || child.destroyed)
5741
+ return debug$6.warn('add self or destroyed');
5729
5742
  const noIndex = index === undefined;
5730
5743
  if (!child.__) {
5731
5744
  if (child instanceof Array)
@@ -5739,8 +5752,9 @@ var LeaferUI = (function (exports) {
5739
5752
  noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
5740
5753
  if (child.isBranch)
5741
5754
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5742
- child.__layout.boxChanged || child.__layout.boxChange();
5743
- child.__layout.matrixChanged || child.__layout.matrixChange();
5755
+ const childLayout = child.__layout;
5756
+ childLayout.boxChanged || childLayout.boxChange();
5757
+ childLayout.matrixChanged || childLayout.matrixChange();
5744
5758
  if (child.__bubbleMap)
5745
5759
  child.__emitLifeEvent(ChildEvent.ADD);
5746
5760
  if (this.leafer) {
@@ -5978,7 +5992,7 @@ var LeaferUI = (function (exports) {
5978
5992
  }
5979
5993
  }
5980
5994
 
5981
- const version = "1.0.10";
5995
+ const version = "1.1.1";
5982
5996
 
5983
5997
  const debug$5 = Debug.get('LeaferCanvas');
5984
5998
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6596,25 +6610,25 @@ var LeaferUI = (function (exports) {
6596
6610
  if (userConfig)
6597
6611
  this.config = DataHelper.default(userConfig, this.config);
6598
6612
  this.__listenEvents();
6599
- this.__requestRender();
6600
6613
  }
6601
6614
  start() {
6602
6615
  this.running = true;
6616
+ this.update(false);
6603
6617
  }
6604
6618
  stop() {
6605
6619
  this.running = false;
6606
6620
  }
6607
- update() {
6608
- this.changed = true;
6621
+ update(change = true) {
6622
+ if (!this.changed)
6623
+ this.changed = change;
6624
+ this.__requestRender();
6609
6625
  }
6610
6626
  requestLayout() {
6611
6627
  this.target.emit(LayoutEvent.REQUEST);
6612
6628
  }
6613
6629
  render(callback) {
6614
- if (!(this.running && this.canvas.view)) {
6615
- this.changed = true;
6616
- return;
6617
- }
6630
+ if (!(this.running && this.canvas.view))
6631
+ return this.update();
6618
6632
  const { target } = this;
6619
6633
  this.times = 0;
6620
6634
  this.totalBounds = new Bounds();
@@ -6748,16 +6762,17 @@ var LeaferUI = (function (exports) {
6748
6762
  }
6749
6763
  }
6750
6764
  __requestRender() {
6751
- const startTime = Date.now();
6765
+ if (this.requestTime)
6766
+ return;
6767
+ const requestTime = this.requestTime = Date.now();
6752
6768
  Platform.requestRender(() => {
6753
- this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
6769
+ this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
6770
+ this.requestTime = 0;
6754
6771
  if (this.running) {
6755
6772
  if (this.changed && this.canvas.view)
6756
6773
  this.render();
6757
6774
  this.target.emit(RenderEvent.NEXT);
6758
6775
  }
6759
- if (this.target)
6760
- this.__requestRender();
6761
6776
  });
6762
6777
  }
6763
6778
  __onResize(e) {
@@ -6773,7 +6788,7 @@ var LeaferUI = (function (exports) {
6773
6788
  }
6774
6789
  }
6775
6790
  this.addBlock(new Bounds(0, 0, 1, 1));
6776
- this.changed = true;
6791
+ this.update();
6777
6792
  }
6778
6793
  __onLayoutEnd(event) {
6779
6794
  if (event.data)
@@ -6908,7 +6923,7 @@ var LeaferUI = (function (exports) {
6908
6923
  return true;
6909
6924
  return t.fill && this.__hasStroke;
6910
6925
  }
6911
- get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
6926
+ get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
6912
6927
  get __autoWidth() { return !this._width; }
6913
6928
  get __autoHeight() { return !this._height; }
6914
6929
  get __autoSide() { return !this._width || !this._height; }
@@ -7022,7 +7037,7 @@ var LeaferUI = (function (exports) {
7022
7037
 
7023
7038
  class BoxData extends GroupData {
7024
7039
  get __boxStroke() { return !this.__pathInputed; }
7025
- get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
7040
+ get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7026
7041
  get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7027
7042
  }
7028
7043
 
@@ -7308,11 +7323,15 @@ var LeaferUI = (function (exports) {
7308
7323
  super(data);
7309
7324
  }
7310
7325
  reset(_data) { }
7311
- set(data, isTemp) {
7312
- if (isTemp) {
7313
- this.lockNormalStyle = true;
7314
- Object.assign(this, data);
7315
- this.lockNormalStyle = false;
7326
+ set(data, transition) {
7327
+ if (transition) {
7328
+ if (transition === 'temp') {
7329
+ this.lockNormalStyle = true;
7330
+ Object.assign(this, data);
7331
+ this.lockNormalStyle = false;
7332
+ }
7333
+ else
7334
+ this.animate(data, transition);
7316
7335
  }
7317
7336
  else
7318
7337
  Object.assign(this, data);
@@ -7622,17 +7641,17 @@ var LeaferUI = (function (exports) {
7622
7641
  if (!this.children)
7623
7642
  this.children = [];
7624
7643
  }
7625
- set(data, isTemp) {
7644
+ set(data, transition) {
7626
7645
  if (data.children) {
7627
7646
  const { children } = data;
7628
7647
  delete data.children;
7629
7648
  this.children ? this.clear() : this.__setBranch();
7630
- super.set(data, isTemp);
7649
+ super.set(data, transition);
7631
7650
  children.forEach(child => this.add(child));
7632
7651
  data.children = children;
7633
7652
  }
7634
7653
  else
7635
- super.set(data, isTemp);
7654
+ super.set(data, transition);
7636
7655
  }
7637
7656
  toJSON(options) {
7638
7657
  const data = super.toJSON(options);
@@ -7678,20 +7697,10 @@ var LeaferUI = (function (exports) {
7678
7697
  constructor(userConfig, data) {
7679
7698
  super(data);
7680
7699
  this.config = {
7681
- type: 'design',
7682
7700
  start: true,
7683
7701
  hittable: true,
7684
7702
  smooth: true,
7685
- lazySpeard: 100,
7686
- zoom: {
7687
- min: 0.01,
7688
- max: 256
7689
- },
7690
- move: {
7691
- holdSpaceKey: true,
7692
- holdMiddleKey: true,
7693
- autoDistance: 2
7694
- }
7703
+ lazySpeard: 100
7695
7704
  };
7696
7705
  this.leafs = 0;
7697
7706
  this.__eventIds = [];
@@ -7708,23 +7717,27 @@ var LeaferUI = (function (exports) {
7708
7717
  init(userConfig, parentApp) {
7709
7718
  if (this.canvas)
7710
7719
  return;
7711
- this.__setLeafer(this);
7712
- if (userConfig)
7713
- DataHelper.assign(this.config, userConfig);
7714
7720
  let start;
7715
7721
  const { config } = this;
7716
- this.initType(config.type);
7722
+ this.__setLeafer(this);
7723
+ if (parentApp) {
7724
+ this.parentApp = parentApp;
7725
+ this.__bindApp(parentApp);
7726
+ start = parentApp.running;
7727
+ }
7728
+ if (userConfig) {
7729
+ this.parent = parentApp;
7730
+ this.initType(userConfig.type);
7731
+ this.parent = undefined;
7732
+ DataHelper.assign(config, userConfig);
7733
+ }
7717
7734
  const canvas = this.canvas = Creator.canvas(config);
7718
7735
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7719
7736
  if (this.isApp)
7720
7737
  this.__setApp();
7721
7738
  this.__checkAutoLayout(config, parentApp);
7722
7739
  this.view = canvas.view;
7723
- if (parentApp) {
7724
- this.__bindApp(parentApp);
7725
- start = parentApp.running;
7726
- }
7727
- else {
7740
+ if (!parentApp) {
7728
7741
  this.selector = Creator.selector(this);
7729
7742
  this.interaction = Creator.interaction(this, canvas, this.selector, config);
7730
7743
  if (this.interaction) {
@@ -7745,8 +7758,8 @@ var LeaferUI = (function (exports) {
7745
7758
  }
7746
7759
  onInit() { }
7747
7760
  initType(_type) { }
7748
- set(data) {
7749
- this.waitInit(() => { super.set(data); });
7761
+ set(data, transition) {
7762
+ this.waitInit(() => { super.set(data, transition); });
7750
7763
  }
7751
7764
  start() {
7752
7765
  clearTimeout(this.__startTimer);
@@ -7781,7 +7794,11 @@ var LeaferUI = (function (exports) {
7781
7794
  forceRender(bounds) {
7782
7795
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7783
7796
  if (this.viewReady)
7784
- this.renderer.update();
7797
+ this.renderer.render();
7798
+ }
7799
+ requestRender(change = false) {
7800
+ if (this.renderer)
7801
+ this.renderer.update(change);
7785
7802
  }
7786
7803
  updateCursor(cursor) {
7787
7804
  const i = this.interaction;
@@ -7889,8 +7906,10 @@ var LeaferUI = (function (exports) {
7889
7906
  const { imageReady } = this;
7890
7907
  if (imageReady && !this.viewCompleted)
7891
7908
  this.__checkViewCompleted();
7892
- if (!imageReady)
7909
+ if (!imageReady) {
7893
7910
  this.viewCompleted = false;
7911
+ this.requestRender();
7912
+ }
7894
7913
  }
7895
7914
  }
7896
7915
  __checkViewCompleted(emit = true) {
@@ -7948,6 +7967,7 @@ var LeaferUI = (function (exports) {
7948
7967
  }
7949
7968
  else
7950
7969
  list.push(item);
7970
+ this.requestRender();
7951
7971
  }
7952
7972
  zoom(_zoomType, _padding, _fixedScale) {
7953
7973
  return needPlugin('view');
@@ -8001,7 +8021,7 @@ var LeaferUI = (function (exports) {
8001
8021
  this.canvasManager.destroy();
8002
8022
  }
8003
8023
  this.canvas.destroy();
8004
- this.config.view = this.view = null;
8024
+ this.config.view = this.view = this.parentApp = null;
8005
8025
  if (this.userConfig)
8006
8026
  this.userConfig.view = null;
8007
8027
  super.destroy();
@@ -8841,6 +8861,8 @@ var LeaferUI = (function (exports) {
8841
8861
  case 'center':
8842
8862
  canvas.setStroke(stroke, __strokeWidth, options);
8843
8863
  canvas.stroke();
8864
+ if (options.__useArrow)
8865
+ strokeArrow(ui, canvas);
8844
8866
  break;
8845
8867
  case 'inside':
8846
8868
  canvas.save();
@@ -8878,6 +8900,8 @@ var LeaferUI = (function (exports) {
8878
8900
  case 'center':
8879
8901
  canvas.setStroke(undefined, __strokeWidth, options);
8880
8902
  drawStrokesStyle(strokes, false, ui, canvas);
8903
+ if (options.__useArrow)
8904
+ strokeArrow(ui, canvas);
8881
8905
  break;
8882
8906
  case 'inside':
8883
8907
  canvas.save();
@@ -8903,6 +8927,14 @@ var LeaferUI = (function (exports) {
8903
8927
  }
8904
8928
  }
8905
8929
  }
8930
+ function strokeArrow(ui, canvas) {
8931
+ if (ui.__.dashPattern) {
8932
+ canvas.beginPath();
8933
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
8934
+ canvas.dashPattern = null;
8935
+ canvas.stroke();
8936
+ }
8937
+ }
8906
8938
 
8907
8939
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
8908
8940
  function shape(ui, current, options) {