@leafer/core 1.6.2 → 1.6.3

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/lib/core.esm.js CHANGED
@@ -23,8 +23,6 @@ const Platform = {
23
23
  }
24
24
  };
25
25
 
26
- const Creator = {};
27
-
28
26
  const IncrementId = {
29
27
  RUNTIME: 'runtime',
30
28
  LEAF: 'leaf',
@@ -464,8 +462,10 @@ const PointHelper = {
464
462
  t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
465
463
  },
466
464
  move(t, x, y) {
467
- t.x += x;
468
- t.y += y;
465
+ if (typeof x === 'object')
466
+ t.x += x.x, t.y += x.y;
467
+ else
468
+ t.x += x, t.y += y;
469
469
  },
470
470
  scale(t, scaleX, scaleY = scaleX) {
471
471
  if (t.x)
@@ -801,15 +801,87 @@ const TwoPointBoundsHelper = {
801
801
  };
802
802
  const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
803
803
 
804
+ var Direction4;
805
+ (function (Direction4) {
806
+ Direction4[Direction4["top"] = 0] = "top";
807
+ Direction4[Direction4["right"] = 1] = "right";
808
+ Direction4[Direction4["bottom"] = 2] = "bottom";
809
+ Direction4[Direction4["left"] = 3] = "left";
810
+ })(Direction4 || (Direction4 = {}));
811
+ var Direction9;
812
+ (function (Direction9) {
813
+ Direction9[Direction9["topLeft"] = 0] = "topLeft";
814
+ Direction9[Direction9["top"] = 1] = "top";
815
+ Direction9[Direction9["topRight"] = 2] = "topRight";
816
+ Direction9[Direction9["right"] = 3] = "right";
817
+ Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
818
+ Direction9[Direction9["bottom"] = 5] = "bottom";
819
+ Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
820
+ Direction9[Direction9["left"] = 7] = "left";
821
+ Direction9[Direction9["center"] = 8] = "center";
822
+ Direction9[Direction9["top-left"] = 0] = "top-left";
823
+ Direction9[Direction9["top-right"] = 2] = "top-right";
824
+ Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
825
+ Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
826
+ })(Direction9 || (Direction9 = {}));
827
+
828
+ const directionData = [
829
+ { x: 0, y: 0 },
830
+ { x: 0.5, y: 0 },
831
+ { x: 1, y: 0 },
832
+ { x: 1, y: 0.5 },
833
+ { x: 1, y: 1 },
834
+ { x: 0.5, y: 1 },
835
+ { x: 0, y: 1 },
836
+ { x: 0, y: 0.5 },
837
+ { x: 0.5, y: 0.5 }
838
+ ];
839
+ directionData.forEach(item => item.type = 'percent');
840
+ const AroundHelper = {
841
+ directionData,
842
+ tempPoint: {},
843
+ get,
844
+ toPoint(around, box, to, onlyBoxSize, content, onlyContentSize) {
845
+ const point = get(around);
846
+ to.x = point.x;
847
+ to.y = point.y;
848
+ if (point.type === 'percent') {
849
+ to.x *= box.width;
850
+ to.y *= box.height;
851
+ if (content) {
852
+ if (!onlyContentSize)
853
+ to.x -= content.x, to.y -= content.y;
854
+ if (point.x)
855
+ to.x -= (point.x === 1) ? content.width : (point.x === 0.5 ? point.x * content.width : 0);
856
+ if (point.y)
857
+ to.y -= (point.y === 1) ? content.height : (point.y === 0.5 ? point.y * content.height : 0);
858
+ }
859
+ }
860
+ if (!onlyBoxSize)
861
+ to.x += box.x, to.y += box.y;
862
+ }
863
+ };
864
+ function get(around) {
865
+ return typeof around === 'string' ? directionData[Direction9[around]] : around;
866
+ }
867
+
868
+ const { toPoint: toPoint$2 } = AroundHelper;
869
+ const AlignHelper = {
870
+ toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
871
+ toPoint$2(align, box, to, onlyBoxSize, content, onlyContentSize);
872
+ }
873
+ };
874
+
804
875
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2 } = TwoPointBoundsHelper;
805
876
  const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
806
877
  const { float, fourNumber } = MathHelper;
807
878
  const { floor, ceil: ceil$1 } = Math;
808
879
  let right, bottom, boundsRight, boundsBottom;
809
880
  const point = {};
810
- const toPoint$2 = {};
881
+ const toPoint$1 = {};
882
+ const tempBounds$1 = {};
811
883
  const BoundsHelper = {
812
- tempBounds: {},
884
+ tempBounds: tempBounds$1,
813
885
  set(t, x = 0, y = 0, width = 0, height = 0) {
814
886
  t.x = x;
815
887
  t.y = y;
@@ -872,8 +944,8 @@ const BoundsHelper = {
872
944
  }
873
945
  B.move(to, -to.offsetX, -to.offsetY);
874
946
  },
875
- scale(t, scaleX, scaleY = scaleX) {
876
- PointHelper.scale(t, scaleX, scaleY);
947
+ scale(t, scaleX, scaleY = scaleX, onlySize) {
948
+ onlySize || PointHelper.scale(t, scaleX, scaleY);
877
949
  t.width *= scaleX;
878
950
  t.height *= scaleY;
879
951
  },
@@ -883,9 +955,9 @@ const BoundsHelper = {
883
955
  t.height *= scaleY;
884
956
  },
885
957
  tempToOuterOf(t, matrix) {
886
- B.copy(B.tempBounds, t);
887
- B.toOuterOf(B.tempBounds, matrix);
888
- return B.tempBounds;
958
+ B.copy(tempBounds$1, t);
959
+ B.toOuterOf(tempBounds$1, matrix);
960
+ return tempBounds$1;
889
961
  },
890
962
  getOuterOf(t, matrix) {
891
963
  t = Object.assign({}, t);
@@ -916,17 +988,17 @@ const BoundsHelper = {
916
988
  else {
917
989
  point.x = t.x;
918
990
  point.y = t.y;
919
- toOuterPoint$2(matrix, point, toPoint$2);
920
- setPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
991
+ toOuterPoint$2(matrix, point, toPoint$1);
992
+ setPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
921
993
  point.x = t.x + t.width;
922
- toOuterPoint$2(matrix, point, toPoint$2);
923
- addPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
994
+ toOuterPoint$2(matrix, point, toPoint$1);
995
+ addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
924
996
  point.y = t.y + t.height;
925
- toOuterPoint$2(matrix, point, toPoint$2);
926
- addPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
997
+ toOuterPoint$2(matrix, point, toPoint$1);
998
+ addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
927
999
  point.x = t.x;
928
- toOuterPoint$2(matrix, point, toPoint$2);
929
- addPoint$2(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
1000
+ toOuterPoint$2(matrix, point, toPoint$1);
1001
+ addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
930
1002
  toBounds$2(tempPointBounds$1, to);
931
1003
  }
932
1004
  },
@@ -936,9 +1008,21 @@ const BoundsHelper = {
936
1008
  B.scale(to, 1 / matrix.a, 1 / matrix.d);
937
1009
  },
938
1010
  getFitMatrix(t, put, baseScale = 1) {
939
- const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
1011
+ const scale = Math.min(baseScale, B.getFitScale(t, put));
940
1012
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
941
1013
  },
1014
+ getFitScale(t, put, isCoverMode) {
1015
+ const sw = t.width / put.width, sh = t.height / put.height;
1016
+ return isCoverMode ? Math.max(sw, sh) : Math.min(sw, sh);
1017
+ },
1018
+ put(t, put, align = 'center', putScale = 1, changeSize = true, to) {
1019
+ to || (to = put);
1020
+ if (typeof putScale === 'string')
1021
+ putScale = B.getFitScale(t, put, putScale === 'cover');
1022
+ tempBounds$1.width = changeSize ? put.width *= putScale : put.width * putScale;
1023
+ tempBounds$1.height = changeSize ? put.height *= putScale : put.height * putScale;
1024
+ AlignHelper.toPoint(align, tempBounds$1, t, to, true, true);
1025
+ },
942
1026
  getSpread(t, spread, side) {
943
1027
  const n = {};
944
1028
  B.copyAndSpread(n, t, spread, false, side);
@@ -1112,8 +1196,8 @@ class Bounds {
1112
1196
  BoundsHelper.move(this, x, y);
1113
1197
  return this;
1114
1198
  }
1115
- scale(scaleX, scaleY) {
1116
- BoundsHelper.scale(this, scaleX, scaleY);
1199
+ scale(scaleX, scaleY, onlySize) {
1200
+ BoundsHelper.scale(this, scaleX, scaleY, onlySize);
1117
1201
  return this;
1118
1202
  }
1119
1203
  scaleOf(origin, scaleX, scaleY) {
@@ -1131,6 +1215,9 @@ class Bounds {
1131
1215
  getFitMatrix(put, baseScale) {
1132
1216
  return BoundsHelper.getFitMatrix(this, put, baseScale);
1133
1217
  }
1218
+ put(put, align, putScale) {
1219
+ BoundsHelper.put(this, put, align, putScale);
1220
+ }
1134
1221
  spread(fourNumber, side) {
1135
1222
  BoundsHelper.spread(this, fourNumber, side);
1136
1223
  return this;
@@ -1239,79 +1326,6 @@ class AutoBounds {
1239
1326
  }
1240
1327
  }
1241
1328
 
1242
- var Direction4;
1243
- (function (Direction4) {
1244
- Direction4[Direction4["top"] = 0] = "top";
1245
- Direction4[Direction4["right"] = 1] = "right";
1246
- Direction4[Direction4["bottom"] = 2] = "bottom";
1247
- Direction4[Direction4["left"] = 3] = "left";
1248
- })(Direction4 || (Direction4 = {}));
1249
- var Direction9;
1250
- (function (Direction9) {
1251
- Direction9[Direction9["topLeft"] = 0] = "topLeft";
1252
- Direction9[Direction9["top"] = 1] = "top";
1253
- Direction9[Direction9["topRight"] = 2] = "topRight";
1254
- Direction9[Direction9["right"] = 3] = "right";
1255
- Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
1256
- Direction9[Direction9["bottom"] = 5] = "bottom";
1257
- Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
1258
- Direction9[Direction9["left"] = 7] = "left";
1259
- Direction9[Direction9["center"] = 8] = "center";
1260
- Direction9[Direction9["top-left"] = 0] = "top-left";
1261
- Direction9[Direction9["top-right"] = 2] = "top-right";
1262
- Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
1263
- Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
1264
- })(Direction9 || (Direction9 = {}));
1265
-
1266
- const directionData = [
1267
- { x: 0, y: 0 },
1268
- { x: 0.5, y: 0 },
1269
- { x: 1, y: 0 },
1270
- { x: 1, y: 0.5 },
1271
- { x: 1, y: 1 },
1272
- { x: 0.5, y: 1 },
1273
- { x: 0, y: 1 },
1274
- { x: 0, y: 0.5 },
1275
- { x: 0.5, y: 0.5 }
1276
- ];
1277
- directionData.forEach(item => item.type = 'percent');
1278
- const AroundHelper = {
1279
- directionData,
1280
- tempPoint: {},
1281
- get,
1282
- toPoint(around, bounds, to, onlySize, pointBounds) {
1283
- const point = get(around);
1284
- to.x = point.x;
1285
- to.y = point.y;
1286
- if (point.type === 'percent') {
1287
- to.x *= bounds.width;
1288
- to.y *= bounds.height;
1289
- if (pointBounds) {
1290
- to.x -= pointBounds.x;
1291
- to.y -= pointBounds.y;
1292
- if (point.x)
1293
- to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1294
- if (point.y)
1295
- to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1296
- }
1297
- }
1298
- if (!onlySize) {
1299
- to.x += bounds.x;
1300
- to.y += bounds.y;
1301
- }
1302
- }
1303
- };
1304
- function get(around) {
1305
- return typeof around === 'string' ? directionData[Direction9[around]] : around;
1306
- }
1307
-
1308
- const { toPoint: toPoint$1 } = AroundHelper;
1309
- const AlignHelper = {
1310
- toPoint(align, contentBounds, bounds, to, onlySize) {
1311
- toPoint$1(align, bounds, to, onlySize, contentBounds);
1312
- }
1313
- };
1314
-
1315
1329
  const StringNumberMap = {
1316
1330
  '0': 1,
1317
1331
  '1': 1,
@@ -1442,11 +1456,17 @@ const Plugin = {
1442
1456
  return rs;
1443
1457
  },
1444
1458
  need(name) {
1445
- console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1459
+ console.error('please install and import plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1446
1460
  }
1447
1461
  };
1448
1462
  setTimeout(() => check.forEach(name => Plugin.has(name, true)));
1449
1463
 
1464
+ const Creator = {
1465
+ editor(_options) {
1466
+ return Plugin.need('editor');
1467
+ }
1468
+ };
1469
+
1450
1470
  const debug$9 = Debug.get('UICreator');
1451
1471
  const UICreator = {
1452
1472
  list: {},
@@ -1584,6 +1604,10 @@ const DataHelper = {
1584
1604
  for (let i = 0, len = list.length; i < len; i++)
1585
1605
  map[list[i]] = true;
1586
1606
  return map;
1607
+ },
1608
+ stintSet(data, attrName, value) {
1609
+ value || (value = undefined);
1610
+ data[attrName] !== value && (data[attrName] = value);
1587
1611
  }
1588
1612
  };
1589
1613
  const { assign } = DataHelper;
@@ -2407,6 +2431,8 @@ const BezierHelper = {
2407
2431
  cY = points[i + 3];
2408
2432
  ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
2409
2433
  cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
2434
+ if (!ba && !cb)
2435
+ continue;
2410
2436
  d = ba + cb;
2411
2437
  ba = (t * ba) / d;
2412
2438
  cb = (t * cb) / d;
@@ -3386,7 +3412,7 @@ function canvasPatch(drawer) {
3386
3412
  }
3387
3413
 
3388
3414
  const FileHelper = {
3389
- opacityTypes: ['png', 'webp', 'svg'],
3415
+ alphaPixelTypes: ['png', 'webp', 'svg'],
3390
3416
  upperCaseTypeMap: {},
3391
3417
  mineType(type) {
3392
3418
  if (!type || type.startsWith('image'))
@@ -3413,7 +3439,7 @@ const FileHelper = {
3413
3439
  }
3414
3440
  };
3415
3441
  const F = FileHelper;
3416
- F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3442
+ F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3417
3443
 
3418
3444
  const debug$4 = Debug.get('TaskProcessor');
3419
3445
  class TaskItem {
@@ -3730,8 +3756,8 @@ const ImageManager = {
3730
3756
  list.length = 0;
3731
3757
  }
3732
3758
  },
3733
- hasOpacityPixel(config) {
3734
- return FileHelper.opacityTypes.some(item => I.isFormat(item, config));
3759
+ hasAlphaPixel(config) {
3760
+ return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
3735
3761
  },
3736
3762
  isFormat(format, config) {
3737
3763
  if (config.format === format)
@@ -3769,7 +3795,7 @@ class LeaferImage {
3769
3795
  this.setView(view.config ? view.view : view);
3770
3796
  }
3771
3797
  ImageManager.isFormat('svg', config) && (this.isSVG = true);
3772
- ImageManager.hasOpacityPixel(config) && (this.hasOpacityPixel = true);
3798
+ ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
3773
3799
  }
3774
3800
  load(onSuccess, onError) {
3775
3801
  if (!this.loading) {
@@ -4457,7 +4483,7 @@ const LeafBoundsHelper = {
4457
4483
  }
4458
4484
  };
4459
4485
 
4460
- const { updateBounds: updateBounds$1 } = LeafHelper;
4486
+ const { updateBounds: updateBounds$2 } = LeafHelper;
4461
4487
  const BranchHelper = {
4462
4488
  sort(a, b) {
4463
4489
  return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
@@ -4519,11 +4545,11 @@ const BranchHelper = {
4519
4545
  branch = branchStack[i];
4520
4546
  children = branch.children;
4521
4547
  for (let j = 0, len = children.length; j < len; j++) {
4522
- updateBounds$1(children[j]);
4548
+ updateBounds$2(children[j]);
4523
4549
  }
4524
4550
  if (exclude && exclude === branch)
4525
4551
  continue;
4526
- updateBounds$1(branch);
4552
+ updateBounds$2(branch);
4527
4553
  }
4528
4554
  }
4529
4555
  };
@@ -4541,7 +4567,7 @@ const WaitHelper = {
4541
4567
  }
4542
4568
  };
4543
4569
 
4544
- const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4570
+ const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$1 } = LeafHelper;
4545
4571
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$2 } = BoundsHelper;
4546
4572
  const localContent = '_localContentBounds';
4547
4573
  const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
@@ -4585,7 +4611,9 @@ class LeafLayout {
4585
4611
  this._localRenderBounds = local;
4586
4612
  }
4587
4613
  update() {
4588
- const { leafer } = this.leaf;
4614
+ const { leaf } = this, { leafer } = leaf;
4615
+ if (leaf.isApp)
4616
+ return updateBounds$1(leaf);
4589
4617
  if (leafer) {
4590
4618
  if (leafer.ready)
4591
4619
  leafer.watcher.changed && leafer.layouter.layout();
@@ -4593,7 +4621,7 @@ class LeafLayout {
4593
4621
  leafer.start();
4594
4622
  }
4595
4623
  else {
4596
- let root = this.leaf;
4624
+ let root = leaf;
4597
4625
  while (root.parent && !root.parent.leafer) {
4598
4626
  root = root.parent;
4599
4627
  }
@@ -4815,7 +4843,7 @@ class LeafLayout {
4815
4843
  }
4816
4844
  childrenSortChange() {
4817
4845
  if (!this.childrenSortChanged) {
4818
- this.childrenSortChanged = true;
4846
+ this.childrenSortChanged = this.affectChildrenSort = true;
4819
4847
  this.leaf.forceUpdate('surface');
4820
4848
  }
4821
4849
  }
@@ -4882,6 +4910,40 @@ ImageEvent.LOAD = 'image.load';
4882
4910
  ImageEvent.LOADED = 'image.loaded';
4883
4911
  ImageEvent.ERROR = 'image.error';
4884
4912
 
4913
+ class BoundsEvent extends Event {
4914
+ static checkHas(leaf, type, mode) {
4915
+ if (mode === 'on') {
4916
+ type === WORLD ? leaf.__hasWorldEvent = true : leaf.__hasLocalEvent = true;
4917
+ }
4918
+ else {
4919
+ leaf.__hasLocalEvent = leaf.hasEvent(RESIZE) || leaf.hasEvent(INNER) || leaf.hasEvent(LOCAL);
4920
+ leaf.__hasWorldEvent = leaf.hasEvent(WORLD);
4921
+ }
4922
+ }
4923
+ static emitLocal(leaf) {
4924
+ if (leaf.leaferIsReady) {
4925
+ const { resized } = leaf.__layout;
4926
+ if (resized !== 'local') {
4927
+ leaf.emit(RESIZE, leaf);
4928
+ if (resized === 'inner')
4929
+ leaf.emit(INNER, leaf);
4930
+ }
4931
+ leaf.emit(LOCAL, leaf);
4932
+ }
4933
+ }
4934
+ static emitWorld(leaf) {
4935
+ if (leaf.leaferIsReady)
4936
+ leaf.emit(WORLD, this);
4937
+ }
4938
+ }
4939
+ BoundsEvent.RESIZE = 'bounds.resize';
4940
+ BoundsEvent.INNER = 'bounds.inner';
4941
+ BoundsEvent.LOCAL = 'bounds.local';
4942
+ BoundsEvent.WORLD = 'bounds.world';
4943
+ const { RESIZE, INNER, LOCAL, WORLD } = BoundsEvent;
4944
+ const boundsEventMap = {};
4945
+ [RESIZE, INNER, LOCAL, WORLD].forEach(key => boundsEventMap[key] = 1);
4946
+
4885
4947
  class ResizeEvent extends Event {
4886
4948
  get bigger() {
4887
4949
  if (!this.old)
@@ -4978,9 +5040,12 @@ class Eventer {
4978
5040
  set event(map) { this.on(map); }
4979
5041
  on(type, listener, options) {
4980
5042
  if (!listener) {
4981
- let event, map = type;
4982
- for (let key in map)
4983
- event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
5043
+ let event;
5044
+ if (type instanceof Array)
5045
+ type.forEach(item => this.on(item[0], item[1], item[2]));
5046
+ else
5047
+ for (let key in type)
5048
+ (event = type[key]) instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
4984
5049
  return;
4985
5050
  }
4986
5051
  let capture, once;
@@ -5010,6 +5075,8 @@ class Eventer {
5010
5075
  else {
5011
5076
  map[type] = [item];
5012
5077
  }
5078
+ if (boundsEventMap[type])
5079
+ BoundsEvent.checkHas(this, type, 'on');
5013
5080
  }
5014
5081
  });
5015
5082
  }
@@ -5031,6 +5098,8 @@ class Eventer {
5031
5098
  events.splice(index, 1);
5032
5099
  if (!events.length)
5033
5100
  delete map[type];
5101
+ if (boundsEventMap[type])
5102
+ BoundsEvent.checkHas(this, type, 'off');
5034
5103
  }
5035
5104
  }
5036
5105
  });
@@ -5050,19 +5119,31 @@ class Eventer {
5050
5119
  }
5051
5120
  }
5052
5121
  on_(type, listener, bind, options) {
5053
- if (bind)
5054
- listener = listener.bind(bind);
5055
- this.on(type, listener, options);
5122
+ if (!listener)
5123
+ (type instanceof Array) && type.forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]));
5124
+ else
5125
+ this.on(type, bind ? listener = listener.bind(bind) : listener, options);
5056
5126
  return { type, current: this, listener, options };
5057
5127
  }
5058
5128
  off_(id) {
5059
5129
  if (!id)
5060
5130
  return;
5061
5131
  const list = id instanceof Array ? id : [id];
5062
- list.forEach(item => item.current.off(item.type, item.listener, item.options));
5132
+ list.forEach(item => {
5133
+ if (!item.listener)
5134
+ (item.type instanceof Array) && item.type.forEach(v => item.current.off(v[0], v[1], v[3]));
5135
+ else
5136
+ item.current.off(item.type, item.listener, item.options);
5137
+ });
5063
5138
  list.length = 0;
5064
5139
  }
5065
- once(type, listener, capture) {
5140
+ once(type, listener, captureOrBind, capture) {
5141
+ if (!listener)
5142
+ return (type instanceof Array) && type.forEach(item => this.once(item[0], item[1], item[2], item[3]));
5143
+ if (typeof captureOrBind === 'object')
5144
+ listener = listener.bind(captureOrBind);
5145
+ else
5146
+ capture = captureOrBind;
5066
5147
  this.on(type, listener, { once: true, capture });
5067
5148
  }
5068
5149
  emit(type, event, capture) {
@@ -5183,9 +5264,9 @@ const LeafMatrix = {
5183
5264
  if (this.__local) {
5184
5265
  const layout = this.__layout, local = this.__local, data = this.__;
5185
5266
  if (layout.affectScaleOrRotation) {
5186
- if (layout.scaleChanged || layout.rotationChanged) {
5267
+ if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5187
5268
  setLayout(local, data, null, null, layout.affectRotation);
5188
- layout.scaleChanged = layout.rotationChanged = false;
5269
+ layout.scaleChanged = layout.rotationChanged = undefined;
5189
5270
  }
5190
5271
  }
5191
5272
  local.e = data.x + data.offsetX;
@@ -5195,7 +5276,7 @@ const LeafMatrix = {
5195
5276
  translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
5196
5277
  }
5197
5278
  }
5198
- this.__layout.matrixChanged = false;
5279
+ this.__layout.matrixChanged = undefined;
5199
5280
  }
5200
5281
  };
5201
5282
 
@@ -5205,11 +5286,17 @@ const { toOuterOf: toOuterOf$1, copyAndSpread, copy: copy$1 } = BoundsHelper;
5205
5286
  const { toBounds } = PathBounds;
5206
5287
  const LeafBounds = {
5207
5288
  __updateWorldBounds() {
5208
- toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
5209
- if (this.__layout.resized) {
5210
- this.__onUpdateSize();
5211
- this.__layout.resized = false;
5289
+ const layout = this.__layout;
5290
+ toOuterOf$1(layout.renderBounds, this.__world, this.__world);
5291
+ if (layout.resized) {
5292
+ if (layout.resized === 'inner')
5293
+ this.__onUpdateSize();
5294
+ if (this.__hasLocalEvent)
5295
+ BoundsEvent.emitLocal(this);
5296
+ layout.resized = undefined;
5212
5297
  }
5298
+ if (this.__hasWorldEvent)
5299
+ BoundsEvent.emitWorld(this);
5213
5300
  },
5214
5301
  __updateLocalBounds() {
5215
5302
  const layout = this.__layout;
@@ -5218,12 +5305,12 @@ const LeafBounds = {
5218
5305
  this.__updatePath();
5219
5306
  this.__updateRenderPath();
5220
5307
  this.__updateBoxBounds();
5221
- layout.resized = true;
5308
+ layout.resized = 'inner';
5222
5309
  }
5223
5310
  if (layout.localBoxChanged) {
5224
5311
  if (this.__local)
5225
5312
  this.__updateLocalBoxBounds();
5226
- layout.localBoxChanged = false;
5313
+ layout.localBoxChanged = undefined;
5227
5314
  if (layout.strokeSpread)
5228
5315
  layout.strokeChanged = true;
5229
5316
  if (layout.renderSpread)
@@ -5231,7 +5318,7 @@ const LeafBounds = {
5231
5318
  if (this.parent)
5232
5319
  this.parent.__layout.boxChange();
5233
5320
  }
5234
- layout.boxChanged = false;
5321
+ layout.boxChanged = undefined;
5235
5322
  if (layout.strokeChanged) {
5236
5323
  layout.strokeSpread = this.__updateStrokeSpread();
5237
5324
  if (layout.strokeSpread) {
@@ -5243,12 +5330,12 @@ const LeafBounds = {
5243
5330
  else {
5244
5331
  layout.spreadStrokeCancel();
5245
5332
  }
5246
- layout.strokeChanged = false;
5333
+ layout.strokeChanged = undefined;
5247
5334
  if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
5248
5335
  layout.renderChanged = true;
5249
5336
  if (this.parent)
5250
5337
  this.parent.__layout.strokeChange();
5251
- layout.resized = true;
5338
+ layout.resized = 'inner';
5252
5339
  }
5253
5340
  if (layout.renderChanged) {
5254
5341
  layout.renderSpread = this.__updateRenderSpread();
@@ -5261,11 +5348,12 @@ const LeafBounds = {
5261
5348
  else {
5262
5349
  layout.spreadRenderCancel();
5263
5350
  }
5264
- layout.renderChanged = false;
5351
+ layout.renderChanged = undefined;
5265
5352
  if (this.parent)
5266
5353
  this.parent.__layout.renderChange();
5267
5354
  }
5268
- layout.boundsChanged = false;
5355
+ layout.resized || (layout.resized = 'local');
5356
+ layout.boundsChanged = undefined;
5269
5357
  },
5270
5358
  __updateLocalBoxBounds() {
5271
5359
  if (this.__hasMotionPath)
@@ -5805,7 +5893,7 @@ let Leaf = class Leaf {
5805
5893
  off(_type, _listener, _options) { }
5806
5894
  on_(_type, _listener, _bind, _options) { return undefined; }
5807
5895
  off_(_id) { }
5808
- once(_type, _listener, _capture) { }
5896
+ once(_type, _listener, _captureOrBind, _capture) { }
5809
5897
  emit(_type, _event, _capture) { }
5810
5898
  emitEvent(_event, _capture) { }
5811
5899
  hasEvent(_type, _capture) { return false; }
@@ -6142,6 +6230,6 @@ class LeafLevelList {
6142
6230
  }
6143
6231
  }
6144
6232
 
6145
- const version = "1.6.2";
6233
+ const version = "1.6.3";
6146
6234
 
6147
- export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, useModule, version, visibleType };
6235
+ export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, useModule, version, visibleType };