@leafer-editor/worker 1.1.0 → 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/worker.js CHANGED
@@ -433,7 +433,7 @@ var LeaferUI = (function (exports) {
433
433
  const M$9 = MatrixHelper;
434
434
 
435
435
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
436
- const { sin: sin$4, cos: cos$4, abs: abs$5, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
436
+ const { sin: sin$4, cos: cos$4, abs: abs$6, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
437
437
  const PointHelper = {
438
438
  defaultPoint: getPointData(),
439
439
  tempPoint: {},
@@ -522,8 +522,8 @@ var LeaferUI = (function (exports) {
522
522
  return getDistanceFrom(t.x, t.y, point.x, point.y);
523
523
  },
524
524
  getDistanceFrom(x1, y1, x2, y2) {
525
- const x = abs$5(x2 - x1);
526
- const y = abs$5(y2 - y1);
525
+ const x = abs$6(x2 - x1);
526
+ const y = abs$6(y2 - y1);
527
527
  return sqrt$2(x * x + y * y);
528
528
  },
529
529
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
@@ -1377,7 +1377,7 @@ var LeaferUI = (function (exports) {
1377
1377
  }
1378
1378
  const D$6 = Debug;
1379
1379
 
1380
- const debug$g = Debug.get('RunTime');
1380
+ const debug$h = 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$g.log(name, duration, 'ms');
1398
+ debug$h.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$f = Debug.get('UICreator');
1412
+ const debug$g = 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$3[tag])
1418
- debug$f.repeat(tag);
1418
+ debug$g.repeat(tag);
1419
1419
  list$3[tag] = UI;
1420
1420
  },
1421
1421
  get(tag, data, x, y, width, height) {
1422
1422
  if (!list$3[tag])
1423
- debug$f.error('not register ' + tag);
1423
+ debug$g.error('not register ' + tag);
1424
1424
  const ui = new list$3[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$3 } = UICreator;
1438
1438
 
1439
- const debug$e = Debug.get('EventCreator');
1439
+ const debug$f = 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$e.repeat(name), nameList[name] = Event;
1447
+ nameList[name] && debug$f.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) {
@@ -2330,7 +2332,7 @@ var LeaferUI = (function (exports) {
2330
2332
  }
2331
2333
  };
2332
2334
 
2333
- const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$4, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2335
+ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$5, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2334
2336
  const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2335
2337
  const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
2336
2338
  const { M: M$8, L: L$9, C: C$8, Q: Q$7, Z: Z$7 } = PathCommandMap;
@@ -2403,7 +2405,7 @@ var LeaferUI = (function (exports) {
2403
2405
  let totalRadian = endRadian - startRadian;
2404
2406
  if (totalRadian < 0)
2405
2407
  totalRadian += PI2;
2406
- if (totalRadian === PI$2 || (abs$4(BAx + BAy) < 1.e-12) || (abs$4(CBx + CBy) < 1.e-12)) {
2408
+ if (totalRadian === PI$2 || (abs$5(BAx + BAy) < 1.e-12) || (abs$5(CBx + CBy) < 1.e-12)) {
2407
2409
  if (data)
2408
2410
  data.push(L$9, x1, y1);
2409
2411
  if (setPointBounds) {
@@ -2445,7 +2447,7 @@ var LeaferUI = (function (exports) {
2445
2447
  totalRadian -= PI2;
2446
2448
  if (anticlockwise)
2447
2449
  totalRadian -= PI2;
2448
- const parts = ceil$1(abs$4(totalRadian / PI_2));
2450
+ const parts = ceil$1(abs$5(totalRadian / PI_2));
2449
2451
  const partRadian = totalRadian / parts;
2450
2452
  const partRadian4Sin = sin$3(partRadian / 4);
2451
2453
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -2598,7 +2600,7 @@ var LeaferUI = (function (exports) {
2598
2600
  const { M: M$7, m, L: L$8, l, H, h, V, v, C: C$7, c, S, s, Q: Q$6, q, T, t, A, a, Z: Z$6, z, N: N$5, D: D$5, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5 } = PathCommandMap;
2599
2601
  const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2600
2602
  const { ellipticalArc } = EllipseHelper;
2601
- const debug$d = Debug.get('PathConvert');
2603
+ const debug$e = 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$d.error(`command: ${command} [index:${i}]`, old);
2844
+ debug$e.error(`command: ${command} [index:${i}]`, old);
2843
2845
  return data;
2844
2846
  }
2845
2847
  lastCommand = command;
@@ -2886,7 +2888,7 @@ var LeaferUI = (function (exports) {
2886
2888
 
2887
2889
  const { M: M$6, L: L$7, C: C$6, Q: Q$5, Z: Z$5, N: N$4, D: D$4, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4 } = PathCommandMap;
2888
2890
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2889
- const { tan, min, abs: abs$3 } = Math;
2891
+ const { tan, min, abs: abs$4 } = Math;
2890
2892
  const startPoint = {};
2891
2893
  const PathCommandDataHelper = {
2892
2894
  beginPath(data) {
@@ -2949,7 +2951,7 @@ var LeaferUI = (function (exports) {
2949
2951
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
2950
2952
  if (lastX !== undefined) {
2951
2953
  const maxRadius = tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2) * (getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / 2);
2952
- data.push(U$4, x1, y1, x2, y2, min(radius, abs$3(maxRadius)));
2954
+ data.push(U$4, x1, y1, x2, y2, min(radius, abs$4(maxRadius)));
2953
2955
  }
2954
2956
  else {
2955
2957
  data.push(U$4, x1, y1, x2, y2, radius);
@@ -3064,7 +3066,7 @@ var LeaferUI = (function (exports) {
3064
3066
  }
3065
3067
 
3066
3068
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$4, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$4, P: P$3, U: U$3 } = PathCommandMap;
3067
- const debug$c = Debug.get('PathDrawer');
3069
+ const debug$d = 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$c.error(`command: ${command} [index:${i}]`, data);
3132
+ debug$d.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$4, L: L$5, C: C$4, Q: Q$3, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$3, O: O$3, P: P$2, U: U$2 } = PathCommandMap;
3138
3140
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3139
3141
  const { addPointBounds, copy: copy$b, addPoint: addPoint$1, setPoint: setPoint$3, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3140
- const debug$b = Debug.get('PathBounds');
3142
+ const debug$c = 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$b.error(`command: ${command} [index:${i}]`, data);
3250
+ debug$c.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$2 = FileHelper;
3362
3364
  F$2.opacityTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
3363
3365
 
3364
- const debug$a = Debug.get('TaskProcessor');
3366
+ const debug$b = 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$a.error(error);
3381
+ debug$b.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$9 = new Debug('rewrite');
4068
+ const debug$a = new Debug('rewrite');
4054
4069
  const list$2 = [];
4055
4070
  const excludeNames = ['destroy', 'constructor'];
4056
4071
  function rewrite(method) {
@@ -4067,7 +4082,7 @@ var LeaferUI = (function (exports) {
4067
4082
  if (list$2.length) {
4068
4083
  list$2.forEach(item => {
4069
4084
  if (error)
4070
- debug$9.error(item.name, '需在Class上装饰@rewriteAble()');
4085
+ debug$a.error(item.name, '需在Class上装饰@rewriteAble()');
4071
4086
  item.run();
4072
4087
  });
4073
4088
  list$2.length = 0;
@@ -4975,13 +4990,13 @@ var LeaferUI = (function (exports) {
4975
4990
  const LeafEventer = { on, on_, off, off_, once, emit: emit$2, emitEvent: emitEvent$1, hasEvent, destroyEventer: destroy };
4976
4991
 
4977
4992
  const { isFinite } = Number;
4978
- const debug$8 = Debug.get('setAttr');
4993
+ const debug$9 = Debug.get('setAttr');
4979
4994
  const LeafDataProxy = {
4980
4995
  __setAttr(name, newValue, checkFiniteNumber) {
4981
4996
  if (this.leaferIsCreated) {
4982
4997
  const oldValue = this.__.__getInput(name);
4983
4998
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4984
- debug$8.warn(this.innerName, name, newValue);
4999
+ debug$9.warn(this.innerName, name, newValue);
4985
5000
  newValue = undefined;
4986
5001
  }
4987
5002
  if (typeof newValue === 'object' || oldValue !== newValue) {
@@ -5437,8 +5452,8 @@ var LeaferUI = (function (exports) {
5437
5452
  canvas.clearRect(r.x, r.y, r.width, r.height);
5438
5453
  canvas.restore();
5439
5454
  }
5440
- __updateMask(value) {
5441
- 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);
5442
5457
  }
5443
5458
  __renderMask(_canvas, _options) { }
5444
5459
  __getNowWorld(options) {
@@ -5678,9 +5693,10 @@ var LeaferUI = (function (exports) {
5678
5693
  useModule(LeafRender)
5679
5694
  ], exports.Leaf);
5680
5695
 
5681
- const { setListWithFn } = BoundsHelper;
5696
+ const { setListWithFn: setListWithFn$1 } = BoundsHelper;
5682
5697
  const { sort } = BranchHelper;
5683
5698
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5699
+ const debug$8 = new Debug('Branch');
5684
5700
  exports.Branch = class Branch extends exports.Leaf {
5685
5701
  __updateStrokeSpread() {
5686
5702
  const { children } = this;
@@ -5699,13 +5715,13 @@ var LeaferUI = (function (exports) {
5699
5715
  return 0;
5700
5716
  }
5701
5717
  __updateBoxBounds() {
5702
- setListWithFn(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds);
5718
+ setListWithFn$1(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds);
5703
5719
  }
5704
5720
  __updateStrokeBounds() {
5705
- setListWithFn(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalStrokeBounds : localStrokeBounds);
5721
+ setListWithFn$1(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalStrokeBounds : localStrokeBounds);
5706
5722
  }
5707
5723
  __updateRenderBounds() {
5708
- setListWithFn(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds);
5724
+ setListWithFn$1(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds);
5709
5725
  }
5710
5726
  __updateSortChildren() {
5711
5727
  let affectSort;
@@ -5721,8 +5737,8 @@ var LeaferUI = (function (exports) {
5721
5737
  }
5722
5738
  }
5723
5739
  add(child, index) {
5724
- if (child === this)
5725
- return;
5740
+ if (child === this || child.destroyed)
5741
+ return debug$8.warn('add self or destroyed');
5726
5742
  const noIndex = index === undefined;
5727
5743
  if (!child.__) {
5728
5744
  if (child instanceof Array)
@@ -5736,8 +5752,9 @@ var LeaferUI = (function (exports) {
5736
5752
  noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
5737
5753
  if (child.isBranch)
5738
5754
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5739
- child.__layout.boxChanged || child.__layout.boxChange();
5740
- child.__layout.matrixChanged || child.__layout.matrixChange();
5755
+ const childLayout = child.__layout;
5756
+ childLayout.boxChanged || childLayout.boxChange();
5757
+ childLayout.matrixChanged || childLayout.matrixChange();
5741
5758
  if (child.__bubbleMap)
5742
5759
  child.__emitLifeEvent(ChildEvent.ADD);
5743
5760
  if (this.leafer) {
@@ -5975,7 +5992,7 @@ var LeaferUI = (function (exports) {
5975
5992
  }
5976
5993
  }
5977
5994
 
5978
- const version = "1.1.0";
5995
+ const version = "1.1.1";
5979
5996
 
5980
5997
  class LeaferCanvas extends LeaferCanvasBase {
5981
5998
  get allowBackgroundColor() { return true; }
@@ -6213,7 +6230,7 @@ var LeaferUI = (function (exports) {
6213
6230
  });
6214
6231
  }
6215
6232
 
6216
- const { worldBounds } = LeafBoundsHelper;
6233
+ const { worldBounds: worldBounds$1 } = LeafBoundsHelper;
6217
6234
  const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
6218
6235
  class LayoutBlockData {
6219
6236
  constructor(list) {
@@ -6225,7 +6242,7 @@ var LeaferUI = (function (exports) {
6225
6242
  this.updatedList = list;
6226
6243
  }
6227
6244
  setBefore() {
6228
- this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
6245
+ this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds$1);
6229
6246
  }
6230
6247
  setAfter() {
6231
6248
  const { list } = this.updatedList;
@@ -6233,7 +6250,7 @@ var LeaferUI = (function (exports) {
6233
6250
  this.afterBounds.set(bigBounds);
6234
6251
  }
6235
6252
  else {
6236
- this.afterBounds.setListWithFn(list, worldBounds);
6253
+ this.afterBounds.setListWithFn(list, worldBounds$1);
6237
6254
  }
6238
6255
  this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
6239
6256
  }
@@ -6420,25 +6437,25 @@ var LeaferUI = (function (exports) {
6420
6437
  if (userConfig)
6421
6438
  this.config = DataHelper.default(userConfig, this.config);
6422
6439
  this.__listenEvents();
6423
- this.__requestRender();
6424
6440
  }
6425
6441
  start() {
6426
6442
  this.running = true;
6443
+ this.update(false);
6427
6444
  }
6428
6445
  stop() {
6429
6446
  this.running = false;
6430
6447
  }
6431
- update() {
6432
- this.changed = true;
6448
+ update(change = true) {
6449
+ if (!this.changed)
6450
+ this.changed = change;
6451
+ this.__requestRender();
6433
6452
  }
6434
6453
  requestLayout() {
6435
6454
  this.target.emit(LayoutEvent.REQUEST);
6436
6455
  }
6437
6456
  render(callback) {
6438
- if (!(this.running && this.canvas.view)) {
6439
- this.changed = true;
6440
- return;
6441
- }
6457
+ if (!(this.running && this.canvas.view))
6458
+ return this.update();
6442
6459
  const { target } = this;
6443
6460
  this.times = 0;
6444
6461
  this.totalBounds = new Bounds();
@@ -6572,16 +6589,17 @@ var LeaferUI = (function (exports) {
6572
6589
  }
6573
6590
  }
6574
6591
  __requestRender() {
6575
- const startTime = Date.now();
6592
+ if (this.requestTime)
6593
+ return;
6594
+ const requestTime = this.requestTime = Date.now();
6576
6595
  Platform.requestRender(() => {
6577
- this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
6596
+ this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
6597
+ this.requestTime = 0;
6578
6598
  if (this.running) {
6579
6599
  if (this.changed && this.canvas.view)
6580
6600
  this.render();
6581
6601
  this.target.emit(RenderEvent.NEXT);
6582
6602
  }
6583
- if (this.target)
6584
- this.__requestRender();
6585
6603
  });
6586
6604
  }
6587
6605
  __onResize(e) {
@@ -6597,7 +6615,7 @@ var LeaferUI = (function (exports) {
6597
6615
  }
6598
6616
  }
6599
6617
  this.addBlock(new Bounds(0, 0, 1, 1));
6600
- this.changed = true;
6618
+ this.update();
6601
6619
  }
6602
6620
  __onLayoutEnd(event) {
6603
6621
  if (event.data)
@@ -7005,7 +7023,7 @@ var LeaferUI = (function (exports) {
7005
7023
  return true;
7006
7024
  return t.fill && this.__hasStroke;
7007
7025
  }
7008
- get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
7026
+ get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7009
7027
  get __autoWidth() { return !this._width; }
7010
7028
  get __autoHeight() { return !this._height; }
7011
7029
  get __autoSide() { return !this._width || !this._height; }
@@ -7119,7 +7137,7 @@ var LeaferUI = (function (exports) {
7119
7137
 
7120
7138
  class BoxData extends GroupData {
7121
7139
  get __boxStroke() { return !this.__pathInputed; }
7122
- get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
7140
+ get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7123
7141
  get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7124
7142
  }
7125
7143
 
@@ -7779,20 +7797,10 @@ var LeaferUI = (function (exports) {
7779
7797
  constructor(userConfig, data) {
7780
7798
  super(data);
7781
7799
  this.config = {
7782
- type: 'design',
7783
7800
  start: true,
7784
7801
  hittable: true,
7785
7802
  smooth: true,
7786
- lazySpeard: 100,
7787
- zoom: {
7788
- min: 0.01,
7789
- max: 256
7790
- },
7791
- move: {
7792
- holdSpaceKey: true,
7793
- holdMiddleKey: true,
7794
- autoDistance: 2
7795
- }
7803
+ lazySpeard: 100
7796
7804
  };
7797
7805
  this.leafs = 0;
7798
7806
  this.__eventIds = [];
@@ -7809,23 +7817,27 @@ var LeaferUI = (function (exports) {
7809
7817
  init(userConfig, parentApp) {
7810
7818
  if (this.canvas)
7811
7819
  return;
7812
- this.__setLeafer(this);
7813
- if (userConfig)
7814
- DataHelper.assign(this.config, userConfig);
7815
7820
  let start;
7816
7821
  const { config } = this;
7817
- this.initType(config.type);
7822
+ this.__setLeafer(this);
7823
+ if (parentApp) {
7824
+ this.parentApp = parentApp;
7825
+ this.__bindApp(parentApp);
7826
+ start = parentApp.running;
7827
+ }
7828
+ if (userConfig) {
7829
+ this.parent = parentApp;
7830
+ this.initType(userConfig.type);
7831
+ this.parent = undefined;
7832
+ DataHelper.assign(config, userConfig);
7833
+ }
7818
7834
  const canvas = this.canvas = Creator.canvas(config);
7819
7835
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7820
7836
  if (this.isApp)
7821
7837
  this.__setApp();
7822
7838
  this.__checkAutoLayout(config, parentApp);
7823
7839
  this.view = canvas.view;
7824
- if (parentApp) {
7825
- this.__bindApp(parentApp);
7826
- start = parentApp.running;
7827
- }
7828
- else {
7840
+ if (!parentApp) {
7829
7841
  this.selector = Creator.selector(this);
7830
7842
  this.interaction = Creator.interaction(this, canvas, this.selector, config);
7831
7843
  if (this.interaction) {
@@ -7882,7 +7894,11 @@ var LeaferUI = (function (exports) {
7882
7894
  forceRender(bounds) {
7883
7895
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7884
7896
  if (this.viewReady)
7885
- this.renderer.update();
7897
+ this.renderer.render();
7898
+ }
7899
+ requestRender(change = false) {
7900
+ if (this.renderer)
7901
+ this.renderer.update(change);
7886
7902
  }
7887
7903
  updateCursor(cursor) {
7888
7904
  const i = this.interaction;
@@ -7990,8 +8006,10 @@ var LeaferUI = (function (exports) {
7990
8006
  const { imageReady } = this;
7991
8007
  if (imageReady && !this.viewCompleted)
7992
8008
  this.__checkViewCompleted();
7993
- if (!imageReady)
8009
+ if (!imageReady) {
7994
8010
  this.viewCompleted = false;
8011
+ this.requestRender();
8012
+ }
7995
8013
  }
7996
8014
  }
7997
8015
  __checkViewCompleted(emit = true) {
@@ -8049,6 +8067,7 @@ var LeaferUI = (function (exports) {
8049
8067
  }
8050
8068
  else
8051
8069
  list.push(item);
8070
+ this.requestRender();
8052
8071
  }
8053
8072
  zoom(_zoomType, _padding, _fixedScale) {
8054
8073
  return needPlugin('view');
@@ -8102,7 +8121,7 @@ var LeaferUI = (function (exports) {
8102
8121
  this.canvasManager.destroy();
8103
8122
  }
8104
8123
  this.canvas.destroy();
8105
- this.config.view = this.view = null;
8124
+ this.config.view = this.view = this.parentApp = null;
8106
8125
  if (this.userConfig)
8107
8126
  this.userConfig.view = null;
8108
8127
  super.destroy();
@@ -8829,9 +8848,9 @@ var LeaferUI = (function (exports) {
8829
8848
  if (ground)
8830
8849
  this.ground = this.addLeafer(ground);
8831
8850
  if (tree || editor)
8832
- this.tree = this.addLeafer(tree);
8851
+ this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
8833
8852
  if (sky || editor)
8834
- this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
8853
+ this.sky = this.addLeafer(sky);
8835
8854
  if (editor)
8836
8855
  this.sky.add(this.editor = Creator.editor(editor));
8837
8856
  }
@@ -9185,184 +9204,7 @@ var LeaferUI = (function (exports) {
9185
9204
  registerUIEvent()
9186
9205
  ], exports.KeyEvent);
9187
9206
 
9188
- function addInteractionWindow(leafer) {
9189
- if (leafer.isApp)
9190
- return;
9191
- leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => {
9192
- leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
9193
- }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
9194
- const { zoomLayer } = leafer;
9195
- const changeScale = leafer.getValidScale(e.scale);
9196
- if (changeScale !== 1) {
9197
- PointHelper.scaleOf(zoomLayer, e, changeScale);
9198
- zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
9199
- }
9200
- }));
9201
- }
9202
-
9203
- function document$1(leafer) {
9204
- addInteractionWindow(leafer);
9205
- const { move, zoom } = leafer.config;
9206
- move.scroll = 'limit';
9207
- zoom.min = 1;
9208
- }
9209
-
9210
- function block(leafer) {
9211
- const { config } = leafer;
9212
- (config.wheel || (config.wheel = {})).preventDefault = false;
9213
- (config.touch || (config.touch = {})).preventDefault = 'auto';
9214
- }
9215
-
9216
- const debug$3 = Debug.get('LeaferTypeCreator');
9217
- const LeaferTypeCreator = {
9218
- list: {},
9219
- register(name, fn) {
9220
- list$1[name] && debug$3.repeat(name);
9221
- list$1[name] = fn;
9222
- },
9223
- run(name, leafer) {
9224
- const fn = list$1[name];
9225
- fn && fn(leafer);
9226
- }
9227
- };
9228
- const { list: list$1, register } = LeaferTypeCreator;
9229
- register('design', addInteractionWindow);
9230
- register('document', document$1);
9231
- register('block', block);
9232
-
9233
- const leafer = exports.Leafer.prototype;
9234
- leafer.initType = function (type) {
9235
- LeaferTypeCreator.run(type, this);
9236
- };
9237
- leafer.getValidMove = function (moveX, moveY) {
9238
- const { scroll, disabled } = this.app.config.move;
9239
- if (scroll) {
9240
- Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
9241
- if (scroll === 'limit') {
9242
- const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
9243
- const right = x + width - this.width, bottom = y + height - this.height;
9244
- if (x >= 0 && right <= 0)
9245
- moveX = 0;
9246
- else if (moveX > 0) {
9247
- if (x + moveX > 0)
9248
- moveX = -x;
9249
- }
9250
- else if (moveX < 0 && right + moveX < 0)
9251
- moveX = -right;
9252
- if (y >= 0 && bottom <= 0)
9253
- moveY = 0;
9254
- else if (moveY > 0) {
9255
- if (y + moveY > 0)
9256
- moveY = -y;
9257
- }
9258
- else if (moveY < 0 && bottom + moveY < 0)
9259
- moveY = -bottom;
9260
- }
9261
- }
9262
- return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
9263
- };
9264
- leafer.getValidScale = function (changeScale) {
9265
- const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
9266
- if (absScale < min)
9267
- changeScale = min / scaleX;
9268
- else if (absScale > max)
9269
- changeScale = max / scaleX;
9270
- return disabled ? 1 : changeScale;
9271
- };
9272
-
9273
- class Transformer {
9274
- get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
9275
- constructor(interaction) {
9276
- this.interaction = interaction;
9277
- }
9278
- move(data) {
9279
- const { interaction } = this;
9280
- if (!data.moveType)
9281
- data.moveType = 'move';
9282
- if (!this.moveData) {
9283
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9284
- data.path = path;
9285
- this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
9286
- interaction.cancelHover();
9287
- interaction.emit(exports.MoveEvent.START, this.moveData);
9288
- }
9289
- data.path = this.moveData.path;
9290
- interaction.emit(exports.MoveEvent.BEFORE_MOVE, data);
9291
- interaction.emit(exports.MoveEvent.MOVE, data);
9292
- this.transformEndWait();
9293
- }
9294
- zoom(data) {
9295
- const { interaction } = this;
9296
- if (!this.zoomData) {
9297
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9298
- data.path = path;
9299
- this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
9300
- interaction.cancelHover();
9301
- interaction.emit(exports.ZoomEvent.START, this.zoomData);
9302
- }
9303
- data.path = this.zoomData.path;
9304
- interaction.emit(exports.ZoomEvent.BEFORE_ZOOM, data);
9305
- interaction.emit(exports.ZoomEvent.ZOOM, data);
9306
- this.transformEndWait();
9307
- }
9308
- rotate(data) {
9309
- const { interaction } = this;
9310
- if (!this.rotateData) {
9311
- const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9312
- data.path = path;
9313
- this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
9314
- interaction.cancelHover();
9315
- interaction.emit(exports.RotateEvent.START, this.rotateData);
9316
- }
9317
- data.path = this.rotateData.path;
9318
- interaction.emit(exports.RotateEvent.BEFORE_ROTATE, data);
9319
- interaction.emit(exports.RotateEvent.ROTATE, data);
9320
- this.transformEndWait();
9321
- }
9322
- transformEndWait() {
9323
- clearTimeout(this.transformTimer);
9324
- this.transformTimer = setTimeout(() => {
9325
- this.transformEnd();
9326
- }, this.interaction.config.pointer.transformTime);
9327
- }
9328
- transformEnd() {
9329
- this.moveEnd();
9330
- this.zoomEnd();
9331
- this.rotateEnd();
9332
- }
9333
- moveEnd() {
9334
- if (this.moveData) {
9335
- this.interaction.emit(exports.MoveEvent.END, this.moveData);
9336
- this.moveData = null;
9337
- }
9338
- }
9339
- zoomEnd() {
9340
- if (this.zoomData) {
9341
- this.interaction.emit(exports.ZoomEvent.END, this.zoomData);
9342
- this.zoomData = null;
9343
- }
9344
- }
9345
- rotateEnd() {
9346
- if (this.rotateData) {
9347
- this.interaction.emit(exports.RotateEvent.END, this.rotateData);
9348
- this.rotateData = null;
9349
- }
9350
- }
9351
- destroy() {
9352
- this.zoomData = this.moveData = this.rotateData = null;
9353
- }
9354
- }
9355
-
9356
9207
  const InteractionHelper = {
9357
- getMoveEventData(center, move, event) {
9358
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, moveX: move.x, moveY: move.y });
9359
- },
9360
- getRotateEventData(center, angle, event) {
9361
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, rotation: angle });
9362
- },
9363
- getZoomEventData(center, scale, event) {
9364
- return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, scale });
9365
- },
9366
9208
  getDragEventData(startPoint, lastPoint, event) {
9367
9209
  return Object.assign(Object.assign({}, event), { x: event.x, y: event.y, moveX: event.x - lastPoint.x, moveY: event.y - lastPoint.y, totalX: event.x - startPoint.x, totalY: event.y - startPoint.y });
9368
9210
  },
@@ -9371,18 +9213,14 @@ var LeaferUI = (function (exports) {
9371
9213
  data });
9372
9214
  },
9373
9215
  getSwipeDirection(angle) {
9374
- if (angle < -45 && angle > -135) {
9216
+ if (angle < -45 && angle > -135)
9375
9217
  return exports.SwipeEvent.UP;
9376
- }
9377
- else if (angle > 45 && angle < 135) {
9218
+ else if (angle > 45 && angle < 135)
9378
9219
  return exports.SwipeEvent.DOWN;
9379
- }
9380
- else if (angle <= 45 && angle >= -45) {
9220
+ else if (angle <= 45 && angle >= -45)
9381
9221
  return exports.SwipeEvent.RIGHT;
9382
- }
9383
- else {
9222
+ else
9384
9223
  return exports.SwipeEvent.LEFT;
9385
- }
9386
9224
  },
9387
9225
  getSwipeEventData(startPoint, lastDragData, event) {
9388
9226
  return Object.assign(Object.assign({}, event), { moveX: lastDragData.moveX, moveY: lastDragData.moveY, totalX: event.x - startPoint.x, totalY: event.y - startPoint.y, type: I.getSwipeDirection(PointHelper.getAngle(startPoint, event)) });
@@ -9455,9 +9293,8 @@ var LeaferUI = (function (exports) {
9455
9293
  interaction.emit(exports.MoveEvent.START, this.dragData);
9456
9294
  }
9457
9295
  }
9458
- if (!this.moving) {
9296
+ if (!this.moving)
9459
9297
  this.dragStart(data, canDrag);
9460
- }
9461
9298
  this.drag(data);
9462
9299
  }
9463
9300
  dragStart(data, canDrag) {
@@ -9535,16 +9372,9 @@ var LeaferUI = (function (exports) {
9535
9372
  dragEnd(data, speed) {
9536
9373
  if (!this.dragging && !this.moving)
9537
9374
  return;
9538
- const { moveX, moveY } = this.dragData;
9539
- if (this.interaction.config.move.dragAnimate && this.canAnimate && this.moving && (Math.abs(moveX) > 1 || Math.abs(moveY) > 1)) {
9540
- data = Object.assign({}, data);
9541
- speed = (speed || (data.pointerType === 'touch' ? 2 : 1)) * 0.9;
9542
- PointHelper.move(data, moveX * speed, moveY * speed);
9543
- this.drag(data);
9544
- this.animate(() => { this.dragEnd(data, 1); });
9545
- }
9546
- else
9547
- this.dragEndReal(data);
9375
+ if (this.checkDragEndAnimate(data, speed))
9376
+ return;
9377
+ this.dragEndReal(data);
9548
9378
  }
9549
9379
  dragEndReal(data) {
9550
9380
  const { interaction, downData, dragData } = this;
@@ -9571,12 +9401,6 @@ var LeaferUI = (function (exports) {
9571
9401
  this.dragReset();
9572
9402
  this.animate(null, 'off');
9573
9403
  }
9574
- animate(func, off) {
9575
- const animateWait = func || this.animateWait;
9576
- if (animateWait)
9577
- this.interaction.target.nextRender(animateWait, null, off);
9578
- this.animateWait = func;
9579
- }
9580
9404
  swipe(data, downData, dragData, endDragData) {
9581
9405
  const { interaction } = this;
9582
9406
  if (PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
@@ -9593,45 +9417,17 @@ var LeaferUI = (function (exports) {
9593
9417
  dragReset() {
9594
9418
  exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9595
9419
  }
9596
- checkDragOut(data) {
9597
- const { interaction } = this;
9598
- this.autoMoveCancel();
9599
- if (this.dragging && !interaction.shrinkCanvasBounds.hitPoint(data))
9600
- this.autoMoveOnDragOut(data);
9601
- }
9602
- autoMoveOnDragOut(data) {
9603
- const { interaction, downData, canDragOut } = this;
9604
- const { autoDistance, dragOut } = interaction.config.move;
9605
- if (!dragOut || !canDragOut || !autoDistance)
9606
- return;
9607
- const bounds = interaction.shrinkCanvasBounds;
9608
- const { x, y } = bounds;
9609
- const right = BoundsHelper.maxX(bounds);
9610
- const bottom = BoundsHelper.maxY(bounds);
9611
- const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
9612
- const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
9613
- let totalX = 0, totalY = 0;
9614
- this.autoMoveTimer = setInterval(() => {
9615
- totalX += moveX;
9616
- totalY += moveY;
9617
- PointHelper.move(downData, moveX, moveY);
9618
- PointHelper.move(this.dragData, moveX, moveY);
9619
- interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
9620
- interaction.pointerMoveReal(data);
9621
- }, 10);
9622
- }
9623
- autoMoveCancel() {
9624
- if (this.autoMoveTimer) {
9625
- clearInterval(this.autoMoveTimer);
9626
- this.autoMoveTimer = 0;
9627
- }
9628
- }
9420
+ checkDragEndAnimate(_data, _speed) { return false; }
9421
+ animate(_func, _off) { }
9422
+ checkDragOut(_data) { }
9423
+ autoMoveOnDragOut(_data) { }
9424
+ autoMoveCancel() { }
9629
9425
  destroy() {
9630
9426
  this.dragReset();
9631
9427
  }
9632
9428
  }
9633
9429
 
9634
- const debug$2 = Debug.get('emit');
9430
+ const debug$3 = Debug.get('emit');
9635
9431
  function emit$1(type, data, path, excludePath) {
9636
9432
  if (!path && !data.path)
9637
9433
  return;
@@ -9661,7 +9457,7 @@ var LeaferUI = (function (exports) {
9661
9457
  }
9662
9458
  }
9663
9459
  catch (e) {
9664
- debug$2.error(e);
9460
+ debug$3.error(e);
9665
9461
  }
9666
9462
  }
9667
9463
  const allowTypes = ['move', 'zoom', 'rotate', 'key'];
@@ -9695,28 +9491,12 @@ var LeaferUI = (function (exports) {
9695
9491
  return excludePath && excludePath.has(leaf);
9696
9492
  }
9697
9493
 
9698
- const MultiTouchHelper = {
9699
- getData(list) {
9700
- const a = list[0];
9701
- const b = list[1];
9702
- const lastCenter = PointHelper.getCenter(a.from, b.from);
9703
- const center = PointHelper.getCenter(a.to, b.to);
9704
- const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
9705
- const lastDistance = PointHelper.getDistance(a.from, b.from);
9706
- const distance = PointHelper.getDistance(a.to, b.to);
9707
- const scale = distance / lastDistance;
9708
- const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
9709
- return { move, scale, angle, center };
9710
- }
9711
- };
9712
-
9713
9494
  const config$1 = {
9714
9495
  wheel: {
9715
9496
  zoomSpeed: 0.5,
9716
9497
  moveSpeed: 0.5,
9717
9498
  rotateSpeed: 0.5,
9718
9499
  delta: { x: 80 / 4, y: 8.0 },
9719
- preventDefault: true
9720
9500
  },
9721
9501
  pointer: {
9722
9502
  hitRadius: 5,
@@ -9727,17 +9507,18 @@ var LeaferUI = (function (exports) {
9727
9507
  dragHover: true,
9728
9508
  dragDistance: 2,
9729
9509
  swipeDistance: 20,
9730
- preventDefaultMenu: true
9731
9510
  },
9732
9511
  touch: {
9733
- preventDefault: true
9512
+ preventDefault: 'auto'
9734
9513
  },
9735
9514
  multiTouch: {},
9515
+ move: { autoDistance: 2 },
9516
+ zoom: {},
9736
9517
  cursor: true,
9737
9518
  keyEvent: true
9738
9519
  };
9739
9520
 
9740
- const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag, pathHasOutside } = InteractionHelper;
9521
+ const { pathHasEventType, pathCanDrag, pathHasOutside } = InteractionHelper;
9741
9522
  class InteractionBase {
9742
9523
  get dragging() { return this.dragger.dragging; }
9743
9524
  get transforming() { return this.transformer.transforming; }
@@ -9759,7 +9540,7 @@ var LeaferUI = (function (exports) {
9759
9540
  this.canvas = canvas;
9760
9541
  this.selector = selector;
9761
9542
  this.defaultPath = new LeafList(target);
9762
- this.transformer = new Transformer(this);
9543
+ this.createTransformer();
9763
9544
  this.dragger = new Dragger(this);
9764
9545
  if (userConfig)
9765
9546
  this.config = DataHelper.default(userConfig, this.config);
@@ -9860,14 +9641,6 @@ var LeaferUI = (function (exports) {
9860
9641
  data.isCancel = true;
9861
9642
  this.pointerUp(data);
9862
9643
  }
9863
- multiTouch(data, list) {
9864
- if (this.config.multiTouch.disabled)
9865
- return;
9866
- const { move, angle, scale, center } = MultiTouchHelper.getData(list);
9867
- this.rotate(getRotateEventData(center, angle, data));
9868
- this.zoom(getZoomEventData(center, scale, data));
9869
- this.move(getMoveEventData(center, move, data));
9870
- }
9871
9644
  menu(data) {
9872
9645
  this.findPath(data);
9873
9646
  this.emit(exports.PointerEvent.MENU, data);
@@ -9881,18 +9654,13 @@ var LeaferUI = (function (exports) {
9881
9654
  this.waitRightTap = this.waitMenuTap = false;
9882
9655
  }
9883
9656
  }
9884
- move(data) {
9885
- this.transformer.move(data);
9886
- }
9887
- zoom(data) {
9888
- this.transformer.zoom(data);
9889
- }
9890
- rotate(data) {
9891
- this.transformer.rotate(data);
9892
- }
9893
- transformEnd() {
9894
- this.transformer.transformEnd();
9895
- }
9657
+ createTransformer() { }
9658
+ move(_data) { }
9659
+ zoom(_data) { }
9660
+ rotate(_data) { }
9661
+ transformEnd() { }
9662
+ wheel(_data) { }
9663
+ multiTouch(_data, _list) { }
9896
9664
  keyDown(data) {
9897
9665
  if (!this.config.keyEvent)
9898
9666
  return;
@@ -10130,8 +9898,9 @@ var LeaferUI = (function (exports) {
10130
9898
  this.longPressed = false;
10131
9899
  }
10132
9900
  __onResize() {
9901
+ const { dragOut } = this.m;
10133
9902
  this.shrinkCanvasBounds = new Bounds(this.canvas.bounds);
10134
- this.shrinkCanvasBounds.spread(-2);
9903
+ this.shrinkCanvasBounds.spread(-(typeof dragOut === 'number' ? dragOut : 2));
10135
9904
  }
10136
9905
  __listenEvents() {
10137
9906
  const { target } = this;
@@ -10151,7 +9920,8 @@ var LeaferUI = (function (exports) {
10151
9920
  this.stop();
10152
9921
  this.__removeListenEvents();
10153
9922
  this.dragger.destroy();
10154
- this.transformer.destroy();
9923
+ if (this.transformer)
9924
+ this.transformer.destroy();
10155
9925
  this.downData = this.overPath = this.enterPath = null;
10156
9926
  }
10157
9927
  }
@@ -10877,13 +10647,13 @@ var LeaferUI = (function (exports) {
10877
10647
  }
10878
10648
 
10879
10649
  const { get: get$1, scale: scale$2, copy: copy$4 } = MatrixHelper;
10880
- const { ceil, abs: abs$2 } = Math;
10650
+ const { ceil, abs: abs$3 } = Math;
10881
10651
  function createPattern(ui, paint, pixelRatio) {
10882
10652
  let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
10883
10653
  const id = scaleX + '-' + scaleY + '-' + pixelRatio;
10884
10654
  if (paint.patternId !== id && !ui.destroyed) {
10885
- scaleX = abs$2(scaleX);
10886
- scaleY = abs$2(scaleY);
10655
+ scaleX = abs$3(scaleX);
10656
+ scaleY = abs$3(scaleY);
10887
10657
  const { image, data } = paint;
10888
10658
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
10889
10659
  if (sx) {
@@ -10939,7 +10709,7 @@ var LeaferUI = (function (exports) {
10939
10709
  }
10940
10710
  }
10941
10711
 
10942
- const { abs: abs$1 } = Math;
10712
+ const { abs: abs$2 } = Math;
10943
10713
  function checkImage(ui, canvas, paint, allowPaint) {
10944
10714
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
10945
10715
  const { pixelRatio } = canvas;
@@ -10951,8 +10721,8 @@ var LeaferUI = (function (exports) {
10951
10721
  if (allowPaint) {
10952
10722
  if (!data.repeat) {
10953
10723
  let { width, height } = data;
10954
- width *= abs$1(scaleX) * pixelRatio;
10955
- height *= abs$1(scaleY) * pixelRatio;
10724
+ width *= abs$2(scaleX) * pixelRatio;
10725
+ height *= abs$2(scaleY) * pixelRatio;
10956
10726
  if (data.scaleX) {
10957
10727
  width *= data.scaleX;
10958
10728
  height *= data.scaleY;
@@ -11431,15 +11201,15 @@ var LeaferUI = (function (exports) {
11431
11201
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11432
11202
  let word, row, wordWidth, rowWidth, realWidth;
11433
11203
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11434
- let textDrawData, rows = [], bounds$1, findMaxWidth;
11204
+ let textDrawData, rows = [], bounds$3, findMaxWidth;
11435
11205
  function createRows(drawData, content, style) {
11436
11206
  textDrawData = drawData;
11437
11207
  rows = drawData.rows;
11438
- bounds$1 = drawData.bounds;
11439
- findMaxWidth = !bounds$1.width && !style.autoSizeAlign;
11208
+ bounds$3 = drawData.bounds;
11209
+ findMaxWidth = !bounds$3.width && !style.autoSizeAlign;
11440
11210
  const { __letterSpacing, paraIndent, textCase } = style;
11441
11211
  const { canvas } = Platform;
11442
- const { width, height } = bounds$1;
11212
+ const { width, height } = bounds$3;
11443
11213
  const charMode = width || height || __letterSpacing || (textCase !== 'none');
11444
11214
  if (charMode) {
11445
11215
  const wrap = style.textWrap !== 'none';
@@ -11553,7 +11323,7 @@ var LeaferUI = (function (exports) {
11553
11323
  startCharSize = 0;
11554
11324
  }
11555
11325
  row.width = rowWidth;
11556
- if (bounds$1.width)
11326
+ if (bounds$3.width)
11557
11327
  trimRight(row);
11558
11328
  else if (findMaxWidth)
11559
11329
  setMaxWidth();
@@ -11990,7 +11760,7 @@ var LeaferUI = (function (exports) {
11990
11760
  }
11991
11761
 
11992
11762
  const canvas = LeaferCanvasBase.prototype;
11993
- const debug$1 = Debug.get('@leafer-ui/export');
11763
+ const debug$2 = Debug.get('@leafer-ui/export');
11994
11764
  canvas.export = function (filename, options) {
11995
11765
  const { quality, blob } = FileHelper.getExportOptions(options);
11996
11766
  if (filename.includes('.'))
@@ -12005,7 +11775,7 @@ var LeaferUI = (function (exports) {
12005
11775
  Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
12006
11776
  resolve(blob);
12007
11777
  }).catch((e) => {
12008
- debug$1.error(e);
11778
+ debug$2.error(e);
12009
11779
  resolve(null);
12010
11780
  });
12011
11781
  });
@@ -12018,7 +11788,7 @@ var LeaferUI = (function (exports) {
12018
11788
  Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
12019
11789
  resolve(true);
12020
11790
  }).catch((e) => {
12021
- debug$1.error(e);
11791
+ debug$2.error(e);
12022
11792
  resolve(false);
12023
11793
  });
12024
11794
  });
@@ -12308,9 +12078,12 @@ var LeaferUI = (function (exports) {
12308
12078
  };
12309
12079
  }
12310
12080
 
12311
- const matrix = MatrixHelper.get();
12312
- const { abs } = Math;
12081
+ const { abs: abs$1 } = Math;
12313
12082
  const { copy: copy$2, scale: scale$1 } = MatrixHelper;
12083
+ const { setListWithFn } = BoundsHelper;
12084
+ const { worldBounds } = LeafBoundsHelper;
12085
+ const matrix = getMatrixData();
12086
+ const bounds$2 = getBoundsData();
12314
12087
  class Stroker extends exports.UI {
12315
12088
  constructor() {
12316
12089
  super();
@@ -12321,6 +12094,17 @@ var LeaferUI = (function (exports) {
12321
12094
  setTarget(target, style) {
12322
12095
  this.set(style);
12323
12096
  this.target = target;
12097
+ this.update();
12098
+ }
12099
+ update() {
12100
+ const { list } = this;
12101
+ if (list.length) {
12102
+ setListWithFn(bounds$2, list, worldBounds);
12103
+ this.set(bounds$2);
12104
+ }
12105
+ else {
12106
+ this.width = this.height = 1;
12107
+ }
12324
12108
  }
12325
12109
  __draw(canvas, options) {
12326
12110
  const { list } = this;
@@ -12330,8 +12114,8 @@ var LeaferUI = (function (exports) {
12330
12114
  for (let i = 0; i < list.length; i++) {
12331
12115
  leaf = list[i];
12332
12116
  const { worldTransform, worldRenderBounds } = leaf;
12333
- if (bounds && bounds.hit(worldRenderBounds, options.matrix)) {
12334
- const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
12117
+ if (!bounds || bounds.hit(worldRenderBounds, options.matrix)) {
12118
+ const aScaleX = abs$1(worldTransform.scaleX), aScaleY = abs$1(worldTransform.scaleY);
12335
12119
  if (aScaleX !== aScaleY) {
12336
12120
  copy$2(matrix, worldTransform);
12337
12121
  scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
@@ -12348,7 +12132,7 @@ var LeaferUI = (function (exports) {
12348
12132
  leaf.__drawPath(canvas);
12349
12133
  else
12350
12134
  leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12351
- data.strokeWidth = strokeWidth / abs(worldTransform.scaleX);
12135
+ data.strokeWidth = strokeWidth / abs$1(worldTransform.scaleX);
12352
12136
  }
12353
12137
  if (stroke)
12354
12138
  typeof stroke === 'string' ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
@@ -12370,7 +12154,6 @@ var LeaferUI = (function (exports) {
12370
12154
  function onTarget$1(stroker) {
12371
12155
  const value = stroker.target;
12372
12156
  stroker.list = value ? (value instanceof Array ? value : [value]) : [];
12373
- stroker.forceUpdate();
12374
12157
  }
12375
12158
 
12376
12159
  class SelectArea extends exports.Group {
@@ -12455,8 +12238,8 @@ var LeaferUI = (function (exports) {
12455
12238
  }
12456
12239
  }
12457
12240
  update() {
12458
- if (this.targetStroker.target)
12459
- this.targetStroker.forceUpdate();
12241
+ this.hoverStroker.update();
12242
+ this.targetStroker.update();
12460
12243
  }
12461
12244
  onPointerMove(e) {
12462
12245
  const { app, editor } = this;
@@ -13274,11 +13057,11 @@ ${filterStyle}
13274
13057
  skewable: true
13275
13058
  };
13276
13059
 
13277
- const bounds = new Bounds();
13060
+ const bounds$1 = new Bounds();
13278
13061
  function simulate(editor) {
13279
13062
  const { simulateTarget, list } = editor;
13280
13063
  const { zoomLayer } = list[0].leafer.zoomLayer;
13281
- simulateTarget.safeChange(() => simulateTarget.reset(bounds.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page')).get()));
13064
+ simulateTarget.safeChange(() => simulateTarget.reset(bounds$1.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page')).get()));
13282
13065
  zoomLayer.add(simulateTarget);
13283
13066
  }
13284
13067
 
@@ -13374,7 +13157,7 @@ ${filterStyle}
13374
13157
  }
13375
13158
  };
13376
13159
 
13377
- const debug = Debug.get('EditToolCreator');
13160
+ const debug$1 = Debug.get('EditToolCreator');
13378
13161
  function registerEditTool() {
13379
13162
  return (target) => {
13380
13163
  EditToolCreator.register(target);
@@ -13385,14 +13168,14 @@ ${filterStyle}
13385
13168
  list: {},
13386
13169
  register(EditTool) {
13387
13170
  const { tag } = EditTool.prototype;
13388
- list[tag] && debug.repeat(tag);
13389
- list[tag] = EditTool;
13171
+ list$1[tag] && debug$1.repeat(tag);
13172
+ list$1[tag] = EditTool;
13390
13173
  },
13391
13174
  get(tag, editor) {
13392
- return new list[tag](editor);
13175
+ return new list$1[tag](editor);
13393
13176
  }
13394
13177
  };
13395
- const { list } = EditToolCreator;
13178
+ const { list: list$1 } = EditToolCreator;
13396
13179
 
13397
13180
  class InnerEditorEvent extends EditorEvent {
13398
13181
  constructor(type, data) {
@@ -14109,6 +13892,349 @@ ${filterStyle}
14109
13892
  });
14110
13893
  };
14111
13894
 
13895
+ function addViewport(leafer, mergeConfig, custom) {
13896
+ addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);
13897
+ if (leafer.isApp || custom)
13898
+ return;
13899
+ leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => {
13900
+ leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
13901
+ }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
13902
+ const { zoomLayer } = leafer;
13903
+ const changeScale = leafer.getValidScale(e.scale);
13904
+ if (changeScale !== 1) {
13905
+ PointHelper.scaleOf(zoomLayer, e, changeScale);
13906
+ zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
13907
+ }
13908
+ }));
13909
+ }
13910
+ function addViewportConfig(leafer, mergeConfig) {
13911
+ if (mergeConfig)
13912
+ DataHelper.assign(leafer.config, mergeConfig);
13913
+ DataHelper.assign(leafer.config, {
13914
+ wheel: { preventDefault: true },
13915
+ touch: { preventDefault: true },
13916
+ pointer: { preventDefaultMenu: true }
13917
+ }, leafer.userConfig);
13918
+ }
13919
+
13920
+ function custom(leafer) {
13921
+ addViewport(leafer, null, true);
13922
+ }
13923
+
13924
+ function design(leafer) {
13925
+ addViewport(leafer, {
13926
+ zoom: {
13927
+ min: 0.01,
13928
+ max: 256
13929
+ },
13930
+ move: {
13931
+ holdSpaceKey: true,
13932
+ holdMiddleKey: true,
13933
+ }
13934
+ });
13935
+ }
13936
+
13937
+ function document$1(leafer) {
13938
+ addViewport(leafer, {
13939
+ zoom: { min: 1 },
13940
+ move: { scroll: 'limit' }
13941
+ });
13942
+ }
13943
+
13944
+ const debug = Debug.get('LeaferTypeCreator');
13945
+ const LeaferTypeCreator = {
13946
+ list: {},
13947
+ register(name, fn) {
13948
+ list[name] && debug.repeat(name);
13949
+ list[name] = fn;
13950
+ },
13951
+ run(name, leafer) {
13952
+ const fn = list[name];
13953
+ fn && fn(leafer);
13954
+ }
13955
+ };
13956
+ const { list, register } = LeaferTypeCreator;
13957
+ register('viewport', addViewport);
13958
+ register('custom', custom);
13959
+ register('design', design);
13960
+ register('document', document$1);
13961
+
13962
+ const MultiTouchHelper = {
13963
+ getData(list) {
13964
+ const a = list[0], b = list[1];
13965
+ const lastCenter = PointHelper.getCenter(a.from, b.from);
13966
+ const center = PointHelper.getCenter(a.to, b.to);
13967
+ const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
13968
+ const lastDistance = PointHelper.getDistance(a.from, b.from);
13969
+ const distance = PointHelper.getDistance(a.to, b.to);
13970
+ const scale = distance / lastDistance;
13971
+ const rotation = PointHelper.getRotation(a.from, b.from, a.to, b.to);
13972
+ return { move, scale, rotation, center };
13973
+ }
13974
+ };
13975
+
13976
+ const WheelEventHelper = {
13977
+ getMove(event, config) {
13978
+ let { moveSpeed } = config;
13979
+ let { deltaX, deltaY } = event;
13980
+ if (event.shiftKey && !deltaX) {
13981
+ deltaX = deltaY;
13982
+ deltaY = 0;
13983
+ }
13984
+ if (deltaX > 50)
13985
+ deltaX = Math.max(50, deltaX / 3);
13986
+ if (deltaY > 50)
13987
+ deltaY = Math.max(50, deltaY / 3);
13988
+ return { x: -deltaX * moveSpeed * 2, y: -deltaY * moveSpeed * 2 };
13989
+ },
13990
+ getScale(event, config) {
13991
+ let zoom;
13992
+ let scale = 1;
13993
+ let { zoomMode, zoomSpeed } = config;
13994
+ const delta = event.deltaY || event.deltaX;
13995
+ if (zoomMode) {
13996
+ zoom = (zoomMode === 'mouse') ? true : (!event.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta));
13997
+ if (event.shiftKey || event.metaKey || event.ctrlKey)
13998
+ zoom = true;
13999
+ }
14000
+ else {
14001
+ zoom = !event.shiftKey && (event.metaKey || event.ctrlKey);
14002
+ }
14003
+ if (zoom) {
14004
+ zoomSpeed = MathHelper.within(zoomSpeed, 0, 1);
14005
+ const min = event.deltaY ? config.delta.y : config.delta.x;
14006
+ scale = 1 - delta / (min * 4) * zoomSpeed;
14007
+ if (scale < 0.5)
14008
+ scale = 0.5;
14009
+ if (scale >= 1.5)
14010
+ scale = 1.5;
14011
+ }
14012
+ return scale;
14013
+ }
14014
+ };
14015
+
14016
+ class Transformer {
14017
+ get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
14018
+ constructor(interaction) {
14019
+ this.interaction = interaction;
14020
+ }
14021
+ move(data) {
14022
+ const { interaction } = this;
14023
+ if (!data.moveType)
14024
+ data.moveType = 'move';
14025
+ if (!this.moveData) {
14026
+ this.setPath(data);
14027
+ this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
14028
+ interaction.emit(exports.MoveEvent.START, this.moveData);
14029
+ }
14030
+ data.path = this.moveData.path;
14031
+ interaction.emit(exports.MoveEvent.BEFORE_MOVE, data);
14032
+ interaction.emit(exports.MoveEvent.MOVE, data);
14033
+ this.transformEndWait();
14034
+ }
14035
+ zoom(data) {
14036
+ const { interaction } = this;
14037
+ if (!this.zoomData) {
14038
+ this.setPath(data);
14039
+ this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
14040
+ interaction.emit(exports.ZoomEvent.START, this.zoomData);
14041
+ }
14042
+ data.path = this.zoomData.path;
14043
+ interaction.emit(exports.ZoomEvent.BEFORE_ZOOM, data);
14044
+ interaction.emit(exports.ZoomEvent.ZOOM, data);
14045
+ this.transformEndWait();
14046
+ }
14047
+ rotate(data) {
14048
+ const { interaction } = this;
14049
+ if (!this.rotateData) {
14050
+ this.setPath(data);
14051
+ this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
14052
+ interaction.emit(exports.RotateEvent.START, this.rotateData);
14053
+ }
14054
+ data.path = this.rotateData.path;
14055
+ interaction.emit(exports.RotateEvent.BEFORE_ROTATE, data);
14056
+ interaction.emit(exports.RotateEvent.ROTATE, data);
14057
+ this.transformEndWait();
14058
+ }
14059
+ setPath(data) {
14060
+ const { interaction } = this;
14061
+ const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
14062
+ data.path = path;
14063
+ interaction.cancelHover();
14064
+ }
14065
+ transformEndWait() {
14066
+ clearTimeout(this.transformTimer);
14067
+ this.transformTimer = setTimeout(() => {
14068
+ this.transformEnd();
14069
+ }, this.interaction.p.transformTime);
14070
+ }
14071
+ transformEnd() {
14072
+ const { interaction, moveData, zoomData, rotateData } = this;
14073
+ if (moveData)
14074
+ interaction.emit(exports.MoveEvent.END, moveData);
14075
+ if (zoomData)
14076
+ interaction.emit(exports.ZoomEvent.END, zoomData);
14077
+ if (rotateData)
14078
+ interaction.emit(exports.RotateEvent.END, rotateData);
14079
+ this.reset();
14080
+ }
14081
+ reset() {
14082
+ this.zoomData = this.moveData = this.rotateData = null;
14083
+ }
14084
+ destroy() {
14085
+ this.reset();
14086
+ }
14087
+ }
14088
+
14089
+ const leafer = exports.Leafer.prototype;
14090
+ const bounds = new Bounds();
14091
+ leafer.initType = function (type) {
14092
+ LeaferTypeCreator.run(type, this);
14093
+ };
14094
+ leafer.getValidMove = function (moveX, moveY) {
14095
+ const { scroll, disabled } = this.app.config.move;
14096
+ if (scroll) {
14097
+ const type = scroll === true ? '' : scroll;
14098
+ if (type.includes('x'))
14099
+ moveX = moveX || moveY, moveY = 0;
14100
+ else if (type.includes('y'))
14101
+ moveY = moveY || moveX, moveX = 0;
14102
+ else
14103
+ Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
14104
+ if (type.includes('limit')) {
14105
+ const { x, y, width, height } = bounds.set(this.__world).addPoint(this.zoomLayer);
14106
+ const right = x + width - this.width, bottom = y + height - this.height;
14107
+ if (x >= 0 && right <= 0)
14108
+ moveX = 0;
14109
+ else if (moveX > 0) {
14110
+ if (x + moveX > 0)
14111
+ moveX = -x;
14112
+ }
14113
+ else if (moveX < 0 && right + moveX < 0)
14114
+ moveX = -right;
14115
+ if (y >= 0 && bottom <= 0)
14116
+ moveY = 0;
14117
+ else if (moveY > 0) {
14118
+ if (y + moveY > 0)
14119
+ moveY = -y;
14120
+ }
14121
+ else if (moveY < 0 && bottom + moveY < 0)
14122
+ moveY = -bottom;
14123
+ }
14124
+ }
14125
+ return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
14126
+ };
14127
+ leafer.getValidScale = function (changeScale) {
14128
+ const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
14129
+ if (min && absScale < min)
14130
+ changeScale = min / scaleX;
14131
+ else if (max && absScale > max)
14132
+ changeScale = max / scaleX;
14133
+ return disabled ? 1 : MathHelper.float(changeScale);
14134
+ };
14135
+
14136
+ function getMoveEventData(move, event) {
14137
+ return Object.assign(Object.assign({}, event), { moveX: move.x, moveY: move.y });
14138
+ }
14139
+ function getRotateEventData(rotation, event) {
14140
+ return Object.assign(Object.assign({}, event), { rotation });
14141
+ }
14142
+ function getZoomEventData(scale, event) {
14143
+ return Object.assign(Object.assign({}, event), { scale });
14144
+ }
14145
+ const interaction = InteractionBase.prototype;
14146
+ interaction.createTransformer = function () {
14147
+ this.transformer = new Transformer(this);
14148
+ };
14149
+ interaction.move = function (data) {
14150
+ this.transformer.move(data);
14151
+ };
14152
+ interaction.zoom = function (data) {
14153
+ this.transformer.zoom(data);
14154
+ };
14155
+ interaction.rotate = function (data) {
14156
+ this.transformer.rotate(data);
14157
+ };
14158
+ interaction.transformEnd = function () {
14159
+ this.transformer.transformEnd();
14160
+ };
14161
+ interaction.wheel = function (data) {
14162
+ const { wheel } = this.config;
14163
+ if (wheel.disabled)
14164
+ return;
14165
+ const scale = wheel.getScale ? wheel.getScale(data, wheel) : WheelEventHelper.getScale(data, wheel);
14166
+ scale !== 1 ? this.zoom(getZoomEventData(scale, data)) : this.move(getMoveEventData(wheel.getMove ? wheel.getMove(data, wheel) : WheelEventHelper.getMove(data, wheel), data));
14167
+ };
14168
+ interaction.multiTouch = function (data, list) {
14169
+ if (this.config.multiTouch.disabled)
14170
+ return;
14171
+ const { move, rotation, scale, center } = MultiTouchHelper.getData(list);
14172
+ Object.assign(data, center);
14173
+ this.rotate(getRotateEventData(rotation, data));
14174
+ this.zoom(getZoomEventData(scale, data));
14175
+ this.move(getMoveEventData(move, data));
14176
+ };
14177
+
14178
+ const dragger = Dragger.prototype;
14179
+ const { abs } = Math;
14180
+ dragger.checkDragEndAnimate = function (data, speed) {
14181
+ const { moveX, moveY } = this.dragData;
14182
+ const absMoveX = abs(moveX), absMoveY = abs(moveY), minMove = speed ? 1 : 0.1;
14183
+ const dragAnimate = this.interaction.m.dragAnimate && this.canAnimate && this.moving && (absMoveX > minMove || absMoveY > minMove);
14184
+ if (dragAnimate) {
14185
+ const inertia = data.pointerType === 'touch' ? 3 : 1, maxMove = 70;
14186
+ speed = speed ? 0.95 : inertia;
14187
+ if (absMoveX * speed > maxMove)
14188
+ speed = maxMove / absMoveX;
14189
+ else if (absMoveY * speed > maxMove)
14190
+ speed = maxMove / absMoveY;
14191
+ data = Object.assign({}, data);
14192
+ PointHelper.move(data, moveX * speed, moveY * speed);
14193
+ this.drag(data);
14194
+ this.animate(() => { this.dragEnd(data, 1); });
14195
+ }
14196
+ return dragAnimate;
14197
+ };
14198
+ dragger.animate = function (func, off) {
14199
+ const animateWait = func || this.animateWait;
14200
+ if (animateWait)
14201
+ this.interaction.target.nextRender(animateWait, null, off);
14202
+ this.animateWait = func;
14203
+ };
14204
+ dragger.checkDragOut = function (data) {
14205
+ const { interaction } = this;
14206
+ this.autoMoveCancel();
14207
+ if (this.dragging && !interaction.shrinkCanvasBounds.hitPoint(data))
14208
+ this.autoMoveOnDragOut(data);
14209
+ };
14210
+ dragger.autoMoveOnDragOut = function (data) {
14211
+ const { interaction, downData, canDragOut } = this;
14212
+ const { autoDistance, dragOut } = interaction.m;
14213
+ if (!dragOut || !canDragOut || !autoDistance)
14214
+ return;
14215
+ const bounds = interaction.shrinkCanvasBounds;
14216
+ const { x, y } = bounds;
14217
+ const right = BoundsHelper.maxX(bounds);
14218
+ const bottom = BoundsHelper.maxY(bounds);
14219
+ const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
14220
+ const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
14221
+ let totalX = 0, totalY = 0;
14222
+ this.autoMoveTimer = setInterval(() => {
14223
+ totalX += moveX;
14224
+ totalY += moveY;
14225
+ PointHelper.move(downData, moveX, moveY);
14226
+ PointHelper.move(this.dragData, moveX, moveY);
14227
+ interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
14228
+ interaction.pointerMoveReal(data);
14229
+ }, 10);
14230
+ };
14231
+ dragger.autoMoveCancel = function () {
14232
+ if (this.autoMoveTimer) {
14233
+ clearInterval(this.autoMoveTimer);
14234
+ this.autoMoveTimer = 0;
14235
+ }
14236
+ };
14237
+
14112
14238
  function getZoomScale(scaleX, type) {
14113
14239
  let scale = 1;
14114
14240
  const out = type === 'out', absScale = Math.abs(scaleX);
@@ -14138,7 +14264,7 @@ ${filterStyle}
14138
14264
 
14139
14265
  exports.Leafer.prototype.zoom = function (zoomType, padding, fixed) {
14140
14266
  const { zoomLayer } = this;
14141
- const limitBounds = this.canvas.bounds.clone().shrink(padding ? padding : 30), bounds = new Bounds();
14267
+ const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
14142
14268
  const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
14143
14269
  let changeScale;
14144
14270
  const { scaleX } = this.__;
@@ -14850,6 +14976,7 @@ ${filterStyle}
14850
14976
  exports.Cursor = Cursor;
14851
14977
  exports.DataHelper = DataHelper;
14852
14978
  exports.Debug = Debug;
14979
+ exports.Dragger = Dragger;
14853
14980
  exports.EditBox = EditBox;
14854
14981
  exports.EditDataHelper = EditDataHelper;
14855
14982
  exports.EditPoint = EditPoint;
@@ -14959,6 +15086,7 @@ ${filterStyle}
14959
15086
  exports.TaskProcessor = TaskProcessor;
14960
15087
  exports.TextConvert = TextConvert;
14961
15088
  exports.TextData = TextData;
15089
+ exports.Transformer = Transformer;
14962
15090
  exports.Transition = Transition;
14963
15091
  exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
14964
15092
  exports.UIBounds = UIBounds;
@@ -14970,7 +15098,9 @@ ${filterStyle}
14970
15098
  exports.WaitHelper = WaitHelper;
14971
15099
  exports.WatchEvent = WatchEvent;
14972
15100
  exports.Watcher = Watcher;
14973
- exports.addInteractionWindow = addInteractionWindow;
15101
+ exports.WheelEventHelper = WheelEventHelper;
15102
+ exports.addViewport = addViewport;
15103
+ exports.addViewportConfig = addViewportConfig;
14974
15104
  exports.affectRenderBoundsType = affectRenderBoundsType;
14975
15105
  exports.affectStrokeBoundsType = affectStrokeBoundsType;
14976
15106
  exports.arrowType = arrowType;