leafer-ui 1.0.0-rc.20 → 1.0.0-rc.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.js CHANGED
@@ -120,7 +120,7 @@ var LeaferUI = (function (exports) {
120
120
 
121
121
  const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
122
122
  const { float: float$1 } = MathHelper;
123
- const tempPoint$3 = {};
123
+ const tempPoint$4 = {};
124
124
  function getWorld() {
125
125
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
126
126
  }
@@ -161,8 +161,8 @@ var LeaferUI = (function (exports) {
161
161
  t.d *= scaleY;
162
162
  },
163
163
  scaleOfOuter(t, origin, scaleX, scaleY) {
164
- M$6.toInnerPoint(t, origin, tempPoint$3);
165
- M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
164
+ M$6.toInnerPoint(t, origin, tempPoint$4);
165
+ M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
166
166
  },
167
167
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
168
168
  M$6.translateInner(t, origin.x, origin.y);
@@ -180,8 +180,8 @@ var LeaferUI = (function (exports) {
180
180
  t.d = c * sinR + d * cosR;
181
181
  },
182
182
  rotateOfOuter(t, origin, rotation) {
183
- M$6.toInnerPoint(t, origin, tempPoint$3);
184
- M$6.rotateOfInner(t, tempPoint$3, rotation);
183
+ M$6.toInnerPoint(t, origin, tempPoint$4);
184
+ M$6.rotateOfInner(t, tempPoint$4, rotation);
185
185
  },
186
186
  rotateOfInner(t, origin, rotation) {
187
187
  M$6.translateInner(t, origin.x, origin.y);
@@ -202,8 +202,8 @@ var LeaferUI = (function (exports) {
202
202
  }
203
203
  },
204
204
  skewOfOuter(t, origin, skewX, skewY) {
205
- M$6.toInnerPoint(t, origin, tempPoint$3);
206
- M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
205
+ M$6.toInnerPoint(t, origin, tempPoint$4);
206
+ M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
207
207
  },
208
208
  skewOfInner(t, origin, skewX, skewY = 0) {
209
209
  M$6.translateInner(t, origin.x, origin.y);
@@ -597,7 +597,7 @@ var LeaferUI = (function (exports) {
597
597
  return this;
598
598
  }
599
599
  }
600
- const tempPoint$2 = new Point();
600
+ const tempPoint$3 = new Point();
601
601
 
602
602
  class Matrix {
603
603
  constructor(a, b, c, d, e, f) {
@@ -1209,11 +1209,19 @@ var LeaferUI = (function (exports) {
1209
1209
  directionData,
1210
1210
  tempPoint: {},
1211
1211
  get: get$5,
1212
- toPoint(around, bounds, to, onlySize) {
1212
+ toPoint(around, bounds, to, onlySize, pointBounds) {
1213
1213
  to || (to = {});
1214
1214
  const point = get$5(around);
1215
1215
  to.x = point.x * bounds.width;
1216
1216
  to.y = point.y * bounds.height;
1217
+ if (pointBounds) {
1218
+ to.x -= pointBounds.x;
1219
+ to.y -= pointBounds.y;
1220
+ if (point.x)
1221
+ to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1222
+ if (point.y)
1223
+ to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1224
+ }
1217
1225
  if (!onlySize) {
1218
1226
  to.x += bounds.x;
1219
1227
  to.y += bounds.y;
@@ -1268,7 +1276,8 @@ var LeaferUI = (function (exports) {
1268
1276
  this.warn(...messages);
1269
1277
  }
1270
1278
  warn(...messages) {
1271
- console.warn(this.name, ...messages);
1279
+ if (D$4.showWarn)
1280
+ console.warn(this.name, ...messages);
1272
1281
  }
1273
1282
  repeat(name, ...messages) {
1274
1283
  if (!this.repeatMap[name]) {
@@ -1287,6 +1296,7 @@ var LeaferUI = (function (exports) {
1287
1296
  }
1288
1297
  Debug.filterList = [];
1289
1298
  Debug.excludeList = [];
1299
+ Debug.showWarn = true;
1290
1300
  function getNameList(name) {
1291
1301
  if (!name)
1292
1302
  name = [];
@@ -2209,7 +2219,7 @@ var LeaferUI = (function (exports) {
2209
2219
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2210
2220
  const { set: set$2 } = PointHelper;
2211
2221
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2212
- const tempPoint$1 = {};
2222
+ const tempPoint$2 = {};
2213
2223
  const BezierHelper = {
2214
2224
  points(data, points, curve, close) {
2215
2225
  data.push(M$5, points[0], points[1]);
@@ -2399,8 +2409,8 @@ var LeaferUI = (function (exports) {
2399
2409
  addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$2(pointBounds, fromX, fromY);
2400
2410
  addPoint$2(pointBounds, toX, toY);
2401
2411
  for (let i = 0, len = tList.length; i < len; i++) {
2402
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2403
- addPoint$2(pointBounds, tempPoint$1.x, tempPoint$1.y);
2412
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2413
+ addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
2404
2414
  }
2405
2415
  },
2406
2416
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2470,7 +2480,7 @@ var LeaferUI = (function (exports) {
2470
2480
  };
2471
2481
 
2472
2482
  const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
2473
- const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2483
+ const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2474
2484
  const { ellipticalArc } = EllipseHelper;
2475
2485
  const debug$d = Debug.get('PathConvert');
2476
2486
  const setEndPoint$1 = {};
@@ -2663,7 +2673,7 @@ var LeaferUI = (function (exports) {
2663
2673
  case N$3:
2664
2674
  x = old[i + 1];
2665
2675
  y = old[i + 2];
2666
- curveMode ? rect$2(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2676
+ curveMode ? rect$3(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2667
2677
  i += 5;
2668
2678
  break;
2669
2679
  case D$3:
@@ -2820,7 +2830,7 @@ var LeaferUI = (function (exports) {
2820
2830
  };
2821
2831
  const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
2822
2832
 
2823
- const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$1, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
2833
+ const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$2, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
2824
2834
  class PathCreator {
2825
2835
  set path(value) { this.__path = value; }
2826
2836
  get path() { return this.__path; }
@@ -2862,7 +2872,7 @@ var LeaferUI = (function (exports) {
2862
2872
  return this;
2863
2873
  }
2864
2874
  rect(x, y, width, height) {
2865
- rect$1(this.__path, x, y, width, height);
2875
+ rect$2(this.__path, x, y, width, height);
2866
2876
  return this;
2867
2877
  }
2868
2878
  roundRect(x, y, width, height, cornerRadius) {
@@ -3957,15 +3967,21 @@ var LeaferUI = (function (exports) {
3957
3967
  }
3958
3968
  return true;
3959
3969
  },
3960
- moveWorld(t, x, y) {
3961
- const local = { x, y };
3970
+ moveWorld(t, x, y = 0) {
3971
+ const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
3962
3972
  if (t.parent)
3963
3973
  toInnerPoint$1(t.parent.worldTransform, local, local, true);
3964
3974
  L.moveLocal(t, local.x, local.y);
3965
3975
  },
3966
3976
  moveLocal(t, x, y = 0) {
3967
- t.x += x;
3968
- t.y += y;
3977
+ if (typeof x === 'object') {
3978
+ t.x += x.x;
3979
+ t.y += x.y;
3980
+ }
3981
+ else {
3982
+ t.x += x;
3983
+ t.y += y;
3984
+ }
3969
3985
  },
3970
3986
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
3971
3987
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -4527,12 +4543,15 @@ var LeaferUI = (function (exports) {
4527
4543
  break;
4528
4544
  }
4529
4545
  }
4546
+ this.syncEventer && this.syncEventer.emitEvent(event, capture);
4530
4547
  },
4531
4548
  emitEvent(event, capture) {
4532
4549
  event.current = this;
4533
4550
  this.emit(event.type, event, capture);
4534
4551
  },
4535
4552
  hasEvent(type, capture) {
4553
+ if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
4554
+ return true;
4536
4555
  const { __bubbleMap: b, __captureMap: c } = this;
4537
4556
  const hasB = b && b[type], hasC = c && c[type];
4538
4557
  return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
@@ -4752,7 +4771,7 @@ var LeaferUI = (function (exports) {
4752
4771
  };
4753
4772
 
4754
4773
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
4755
- const { toPoint, tempPoint } = AroundHelper;
4774
+ const { toPoint, tempPoint: tempPoint$1 } = AroundHelper;
4756
4775
  const LeafMatrix = {
4757
4776
  __updateWorldMatrix() {
4758
4777
  multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
@@ -4769,8 +4788,8 @@ var LeaferUI = (function (exports) {
4769
4788
  local.e = data.x;
4770
4789
  local.f = data.y;
4771
4790
  if (data.around) {
4772
- toPoint(data.around, layout.boxBounds, tempPoint);
4773
- translateInner(local, -tempPoint.x, -tempPoint.y);
4791
+ toPoint(data.around, layout.boxBounds, tempPoint$1);
4792
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y);
4774
4793
  }
4775
4794
  }
4776
4795
  this.__layout.matrixChanged = false;
@@ -6421,32 +6440,38 @@ var LeaferUI = (function (exports) {
6421
6440
  const target = options.target || this.target;
6422
6441
  this.exclude = options.exclude || null;
6423
6442
  this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius };
6424
- this.findList = options.findList || [];
6443
+ this.findList = new LeafList(options.findList);
6425
6444
  if (!options.findList)
6426
- this.eachFind(target.children, target.__onlyHitMask);
6427
- const list = this.findList;
6428
- const leaf = this.getBestMatchLeaf();
6445
+ this.hitBranch(target);
6446
+ const { list } = this.findList;
6447
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
6429
6448
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
6430
6449
  this.clear();
6431
6450
  return through ? { path, target: leaf, throughPath: list.length ? this.getThroughPath(list) : path } : { path, target: leaf };
6432
6451
  }
6433
- getBestMatchLeaf() {
6434
- const { findList: targets } = this;
6435
- if (targets.length > 1) {
6452
+ getBestMatchLeaf(list, bottomList, ignoreHittable) {
6453
+ if (list.length) {
6436
6454
  let find;
6437
- this.findList = [];
6455
+ this.findList = new LeafList();
6438
6456
  const { x, y } = this.point;
6439
6457
  const point = { x, y, radiusX: 0, radiusY: 0 };
6440
- for (let i = 0, len = targets.length; i < len; i++) {
6441
- find = targets[i];
6442
- if (LeafHelper.worldHittable(find)) {
6458
+ for (let i = 0, len = list.length; i < len; i++) {
6459
+ find = list[i];
6460
+ if (ignoreHittable || LeafHelper.worldHittable(find)) {
6443
6461
  this.hitChild(find, point);
6444
6462
  if (this.findList.length)
6445
- return this.findList[0];
6463
+ return this.findList.list[0];
6446
6464
  }
6447
6465
  }
6448
6466
  }
6449
- return targets[0];
6467
+ if (bottomList) {
6468
+ for (let i = 0, len = bottomList.length; i < len; i++) {
6469
+ this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
6470
+ if (this.findList.length)
6471
+ return this.findList.list[0];
6472
+ }
6473
+ }
6474
+ return list[0];
6450
6475
  }
6451
6476
  getPath(leaf) {
6452
6477
  const path = new LeafList();
@@ -6488,6 +6513,9 @@ var LeaferUI = (function (exports) {
6488
6513
  }
6489
6514
  return throughPath;
6490
6515
  }
6516
+ hitBranch(branch) {
6517
+ this.eachFind(branch.children, branch.__onlyHitMask);
6518
+ }
6491
6519
  eachFind(children, hitMask) {
6492
6520
  let child, hit;
6493
6521
  const { point } = this, len = children.length;
@@ -6509,11 +6537,11 @@ var LeaferUI = (function (exports) {
6509
6537
  }
6510
6538
  }
6511
6539
  }
6512
- hitChild(child, point) {
6540
+ hitChild(child, point, proxy) {
6513
6541
  if (this.exclude && this.exclude.has(child))
6514
6542
  return;
6515
6543
  if (child.__hitWorld(point))
6516
- this.findList.push(child);
6544
+ this.findList.add(proxy || child);
6517
6545
  }
6518
6546
  clear() {
6519
6547
  this.point = null;
@@ -6711,7 +6739,11 @@ var LeaferUI = (function (exports) {
6711
6739
  defineKey(target, key, {
6712
6740
  set(value) { if (this.isLeafer)
6713
6741
  this[privateKey] = value; },
6714
- get() { return this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer; }
6742
+ get() {
6743
+ return this.isApp
6744
+ ? this.tree.zoomLayer
6745
+ : (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
6746
+ }
6715
6747
  });
6716
6748
  };
6717
6749
  }
@@ -7117,6 +7149,9 @@ var LeaferUI = (function (exports) {
7117
7149
  pen.set(this.path = this.__.path || []);
7118
7150
  return pen;
7119
7151
  }
7152
+ get editConfig() { return undefined; }
7153
+ get editOuter() { return 'EditTool'; }
7154
+ get editInner() { return 'PathEditor'; }
7120
7155
  constructor(data) {
7121
7156
  super(data);
7122
7157
  }
@@ -7178,7 +7213,8 @@ var LeaferUI = (function (exports) {
7178
7213
  __drawPathByBox(drawer) {
7179
7214
  const { x, y, width, height } = this.__layout.boxBounds;
7180
7215
  if (this.__.cornerRadius) {
7181
- drawer.roundRect(x, y, width, height, this.__.cornerRadius);
7216
+ const { cornerRadius } = this.__;
7217
+ drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7182
7218
  }
7183
7219
  else {
7184
7220
  drawer.rect(x, y, width, height);
@@ -7199,6 +7235,9 @@ var LeaferUI = (function (exports) {
7199
7235
  static registerData(data) {
7200
7236
  dataProcessor(data)(this.prototype);
7201
7237
  }
7238
+ static setEditConfig(_config) { }
7239
+ static setEditOuter(_toolName) { }
7240
+ static setEditInner(_editorName) { }
7202
7241
  destroy() {
7203
7242
  this.fill = this.stroke = null;
7204
7243
  super.destroy();
@@ -7282,15 +7321,15 @@ var LeaferUI = (function (exports) {
7282
7321
  __decorate([
7283
7322
  dataType(false)
7284
7323
  ], exports.UI.prototype, "draggable", void 0);
7324
+ __decorate([
7325
+ dataType()
7326
+ ], exports.UI.prototype, "dragBounds", void 0);
7285
7327
  __decorate([
7286
7328
  dataType(false)
7287
7329
  ], exports.UI.prototype, "editable", void 0);
7288
7330
  __decorate([
7289
7331
  dataType('size')
7290
7332
  ], exports.UI.prototype, "editSize", void 0);
7291
- __decorate([
7292
- dataType()
7293
- ], exports.UI.prototype, "editorStyle", void 0);
7294
7333
  __decorate([
7295
7334
  hitType(true)
7296
7335
  ], exports.UI.prototype, "hittable", void 0);
@@ -7482,7 +7521,6 @@ var LeaferUI = (function (exports) {
7482
7521
  var Leafer_1;
7483
7522
  const debug$3 = Debug.get('Leafer');
7484
7523
  exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
7485
- static get version() { return '1.0.0-rc.20'; }
7486
7524
  get __tag() { return 'Leafer'; }
7487
7525
  get isApp() { return false; }
7488
7526
  get app() { return this.parent || this; }
@@ -7535,7 +7573,6 @@ var LeaferUI = (function (exports) {
7535
7573
  if (this.isApp)
7536
7574
  this.__setApp();
7537
7575
  this.__checkAutoLayout(config);
7538
- this.updateLazyBounds();
7539
7576
  this.view = canvas.view;
7540
7577
  if (parentApp) {
7541
7578
  this.__bindApp(parentApp);
@@ -7779,6 +7816,7 @@ var LeaferUI = (function (exports) {
7779
7816
  __listenEvents() {
7780
7817
  const runId = Run.start('FirstCreate ' + this.innerName);
7781
7818
  this.once(LeaferEvent.START, () => Run.end(runId));
7819
+ this.once(LayoutEvent.START, () => this.updateLazyBounds());
7782
7820
  this.once(LayoutEvent.END, () => this.__onReady());
7783
7821
  this.once(RenderEvent.START, () => this.__onCreated());
7784
7822
  this.once(RenderEvent.END, () => this.__onViewReady());
@@ -7849,8 +7887,8 @@ var LeaferUI = (function (exports) {
7849
7887
  registerUI()
7850
7888
  ], exports.Rect);
7851
7889
 
7852
- const rect = exports.Rect.prototype;
7853
- const group = exports.Group.prototype;
7890
+ const rect$1 = exports.Rect.prototype;
7891
+ const group$1 = exports.Group.prototype;
7854
7892
  const bounds$1 = {};
7855
7893
  const { copy: copy$3, add } = BoundsHelper;
7856
7894
  exports.Box = class Box extends exports.Group {
@@ -7929,28 +7967,28 @@ var LeaferUI = (function (exports) {
7929
7967
  affectRenderBoundsType('show')
7930
7968
  ], exports.Box.prototype, "overflow", void 0);
7931
7969
  __decorate([
7932
- rewrite(rect.__updateStrokeSpread)
7970
+ rewrite(rect$1.__updateStrokeSpread)
7933
7971
  ], exports.Box.prototype, "__updateStrokeSpread", null);
7934
7972
  __decorate([
7935
- rewrite(rect.__updateRenderSpread)
7973
+ rewrite(rect$1.__updateRenderSpread)
7936
7974
  ], exports.Box.prototype, "__updateRectRenderSpread", null);
7937
7975
  __decorate([
7938
- rewrite(rect.__updateBoxBounds)
7976
+ rewrite(rect$1.__updateBoxBounds)
7939
7977
  ], exports.Box.prototype, "__updateRectBoxBounds", null);
7940
7978
  __decorate([
7941
- rewrite(rect.__updateStrokeBounds)
7979
+ rewrite(rect$1.__updateStrokeBounds)
7942
7980
  ], exports.Box.prototype, "__updateStrokeBounds", null);
7943
7981
  __decorate([
7944
- rewrite(rect.__updateRenderBounds)
7982
+ rewrite(rect$1.__updateRenderBounds)
7945
7983
  ], exports.Box.prototype, "__updateRectRenderBounds", null);
7946
7984
  __decorate([
7947
- rewrite(rect.__updateChange)
7985
+ rewrite(rect$1.__updateChange)
7948
7986
  ], exports.Box.prototype, "__updateRectChange", null);
7949
7987
  __decorate([
7950
- rewrite(rect.__render)
7988
+ rewrite(rect$1.__render)
7951
7989
  ], exports.Box.prototype, "__renderRect", null);
7952
7990
  __decorate([
7953
- rewrite(group.__render)
7991
+ rewrite(group$1.__render)
7954
7992
  ], exports.Box.prototype, "__renderGroup", null);
7955
7993
  exports.Box = __decorate([
7956
7994
  rewriteAble(),
@@ -8297,6 +8335,7 @@ var LeaferUI = (function (exports) {
8297
8335
  const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8298
8336
  exports.Text = class Text extends exports.UI {
8299
8337
  get __tag() { return 'Text'; }
8338
+ get editInner() { return 'TextEditor'; }
8300
8339
  get textDrawData() {
8301
8340
  this.__layout.update();
8302
8341
  return this.__.__textDrawData;
@@ -8525,7 +8564,7 @@ var LeaferUI = (function (exports) {
8525
8564
  };
8526
8565
  }
8527
8566
 
8528
- const version = "1.0.0-rc.20";
8567
+ const version = "1.0.0-rc.21";
8529
8568
 
8530
8569
  exports.App = class App extends exports.Leafer {
8531
8570
  get __tag() { return 'App'; }
@@ -8619,7 +8658,8 @@ var LeaferUI = (function (exports) {
8619
8658
  this.renderer.update();
8620
8659
  }
8621
8660
  __render(canvas, options) {
8622
- canvas.setWorld(options.matrix || this.__world);
8661
+ if (options.matrix)
8662
+ canvas.setWorld(options.matrix);
8623
8663
  this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8624
8664
  }
8625
8665
  __onResize(event) {
@@ -8741,6 +8781,35 @@ var LeaferUI = (function (exports) {
8741
8781
  static setData(data) {
8742
8782
  this.data = data;
8743
8783
  }
8784
+ static getValidMove(leaf, start, total) {
8785
+ const { draggable, dragBounds, x, y } = leaf;
8786
+ const move = leaf.getLocalPoint(total, null, true);
8787
+ move.x += start.x - x;
8788
+ move.y += start.y - y;
8789
+ if (dragBounds)
8790
+ this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
8791
+ if (draggable === 'x')
8792
+ move.y = 0;
8793
+ if (draggable === 'y')
8794
+ move.x = 0;
8795
+ return move;
8796
+ }
8797
+ static getMoveInDragBounds(box, dragBounds, move, change) {
8798
+ const x = box.x + move.x, y = box.y + move.y;
8799
+ const right = x + box.width, bottom = y + box.height;
8800
+ const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8801
+ if (!change)
8802
+ move = Object.assign({}, move);
8803
+ if (x < dragBounds.x)
8804
+ move.x += dragBounds.x - x;
8805
+ else if (right > boundsRight)
8806
+ move.x += boundsRight - right;
8807
+ if (y < dragBounds.y)
8808
+ move.y += dragBounds.y - y;
8809
+ else if (bottom > boundsBottom)
8810
+ move.y += boundsBottom - bottom;
8811
+ return move;
8812
+ }
8744
8813
  getPageMove(total) {
8745
8814
  this.assignMove(total);
8746
8815
  return this.current.getPagePoint(move, null, true);
@@ -8850,9 +8919,7 @@ var LeaferUI = (function (exports) {
8850
8919
  if (leafer.isApp)
8851
8920
  return;
8852
8921
  leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => {
8853
- const { x, y } = leafer.getValidMove(e.moveX, e.moveY);
8854
- if (x || y)
8855
- leafer.zoomLayer.move(x, y);
8922
+ leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
8856
8923
  }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
8857
8924
  const { zoomLayer } = leafer;
8858
8925
  const changeScale = leafer.getValidScale(e.scale);
@@ -9121,9 +9188,14 @@ var LeaferUI = (function (exports) {
9121
9188
  if (this.dragging) {
9122
9189
  this.interaction.emit(exports.DragEvent.START, this.dragData);
9123
9190
  this.getDragableList(this.dragData.path);
9191
+ this.setDragStartPoints(this.realDragableList = this.getList());
9124
9192
  }
9125
9193
  }
9126
9194
  }
9195
+ setDragStartPoints(list) {
9196
+ this.dragStartPoints = {};
9197
+ list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9198
+ }
9127
9199
  getDragableList(path) {
9128
9200
  let leaf;
9129
9201
  for (let i = 0, len = path.length; i < len; i++) {
@@ -9153,10 +9225,10 @@ var LeaferUI = (function (exports) {
9153
9225
  }
9154
9226
  dragReal() {
9155
9227
  const { running } = this.interaction;
9156
- const list = this.getList();
9228
+ const list = this.realDragableList;
9157
9229
  if (list.length && running) {
9158
- const { moveX, moveY } = this.dragData;
9159
- list.forEach(leaf => leaf.draggable && leaf.moveWorld(moveX, moveY));
9230
+ const { totalX, totalY } = this.dragData;
9231
+ list.forEach(leaf => leaf.draggable && leaf.move(exports.DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
9160
9232
  }
9161
9233
  }
9162
9234
  dragOverOrOut(data) {
@@ -9625,7 +9697,8 @@ var LeaferUI = (function (exports) {
9625
9697
  }
9626
9698
  findPath(data, options) {
9627
9699
  const { hitRadius, through } = this.config.pointer;
9628
- const find = this.selector.getByPoint(data, hitRadius, options || { through });
9700
+ const { bottomList } = this;
9701
+ const find = this.selector.getByPoint(data, hitRadius, Object.assign({ bottomList, name: data.type }, (options || { through })));
9629
9702
  if (find.throughPath)
9630
9703
  data.throughPath = find.throughPath;
9631
9704
  data.path = find.path;
@@ -9638,7 +9711,7 @@ var LeaferUI = (function (exports) {
9638
9711
  const app = this.target.app;
9639
9712
  if (!app || !app.isApp)
9640
9713
  return false;
9641
- return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree));
9714
+ return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
9642
9715
  }
9643
9716
  checkPath(data, useDefaultPath) {
9644
9717
  if (useDefaultPath || this.canMove(data))
@@ -9704,7 +9777,7 @@ var LeaferUI = (function (exports) {
9704
9777
  const { path } = data;
9705
9778
  for (let i = 0, len = path.length; i < len; i++) {
9706
9779
  leaf = path.list[i];
9707
- cursor = leaf.cursor;
9780
+ cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
9708
9781
  if (cursor)
9709
9782
  break;
9710
9783
  }
@@ -9862,6 +9935,8 @@ var LeaferUI = (function (exports) {
9862
9935
  const inner = {};
9863
9936
  const leaf = exports.Leaf.prototype;
9864
9937
  leaf.__hitWorld = function (point) {
9938
+ if (!this.__.hitSelf)
9939
+ return false;
9865
9940
  if (this.__.hitRadius) {
9866
9941
  copy$2(inner, point), point = inner;
9867
9942
  setRadius(point, this.__.hitRadius);
@@ -9889,8 +9964,8 @@ var LeaferUI = (function (exports) {
9889
9964
  this.__drawRenderPath(canvas); };
9890
9965
 
9891
9966
  const matrix = new Matrix();
9892
- const ui$1 = exports.UI.prototype;
9893
- ui$1.__updateHitCanvas = function () {
9967
+ const ui$2 = exports.UI.prototype;
9968
+ ui$2.__updateHitCanvas = function () {
9894
9969
  const data = this.__, { hitCanvasManager } = this.leafer;
9895
9970
  const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
9896
9971
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
@@ -9917,7 +9992,7 @@ var LeaferUI = (function (exports) {
9917
9992
  this.__drawHitPath(h);
9918
9993
  h.setStrokeOptions(data);
9919
9994
  };
9920
- ui$1.__hit = function (inner) {
9995
+ ui$2.__hit = function (inner) {
9921
9996
  if (Platform.name === 'miniapp')
9922
9997
  this.__drawHitPath(this.__hitCanvas);
9923
9998
  const data = this.__;
@@ -9957,22 +10032,24 @@ var LeaferUI = (function (exports) {
9957
10032
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
9958
10033
  };
9959
10034
 
9960
- const ui = new exports.UI();
9961
- exports.Rect.prototype.__updateHitCanvas = function () {
10035
+ const ui$1 = new exports.UI();
10036
+ const rect = exports.Rect.prototype;
10037
+ rect.__updateHitCanvas = function () {
9962
10038
  if (this.stroke || this.cornerRadius)
9963
- ui.__updateHitCanvas.call(this);
10039
+ ui$1.__updateHitCanvas.call(this);
9964
10040
  };
9965
- exports.Rect.prototype.__hitFill = function (inner) {
9966
- return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10041
+ rect.__hitFill = function (inner) {
10042
+ return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
9967
10043
  };
9968
10044
 
9969
- exports.UI.prototype.find = function (condition, options) {
10045
+ const ui = exports.UI.prototype, group = exports.Group.prototype;
10046
+ ui.find = function (condition, options) {
9970
10047
  return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
9971
10048
  };
9972
- exports.UI.prototype.findOne = function (condition, options) {
10049
+ ui.findOne = function (condition, options) {
9973
10050
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
9974
10051
  };
9975
- exports.Group.prototype.pick = function (hitPoint, options) {
10052
+ group.pick = function (hitPoint, options) {
9976
10053
  this.__layout.update();
9977
10054
  if (!options)
9978
10055
  options = {};
@@ -10628,79 +10705,75 @@ var LeaferUI = (function (exports) {
10628
10705
 
10629
10706
  let origin = {};
10630
10707
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
10631
- function fillOrFitMode(data, mode, box, width, height, rotation) {
10708
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10632
10709
  const transform = get$4();
10633
- const swap = rotation && rotation !== 180;
10634
- const sw = box.width / (swap ? height : width);
10635
- const sh = box.height / (swap ? width : height);
10636
- const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10637
- const x = box.x + (box.width - width * scale) / 2;
10638
- const y = box.y + (box.height - height * scale) / 2;
10639
- translate$1(transform, x, y);
10640
- scaleHelper(transform, scale);
10710
+ translate$1(transform, box.x + x, box.y + y);
10711
+ scaleHelper(transform, scaleX, scaleY);
10641
10712
  if (rotation)
10642
10713
  rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10643
- data.scaleX = data.scaleY = scale;
10644
10714
  data.transform = transform;
10645
10715
  }
10646
10716
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10647
10717
  const transform = get$4();
10648
- translate$1(transform, box.x, box.y);
10649
- if (x || y)
10650
- translate$1(transform, x, y);
10651
- if (scaleX) {
10718
+ translate$1(transform, box.x + x, box.y + y);
10719
+ if (scaleX)
10652
10720
  scaleHelper(transform, scaleX, scaleY);
10653
- data.scaleX = transform.a;
10654
- data.scaleY = transform.d;
10655
- }
10656
10721
  if (rotation)
10657
10722
  rotate(transform, rotation);
10658
10723
  data.transform = transform;
10659
10724
  }
10660
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
10725
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
10661
10726
  const transform = get$4();
10662
10727
  if (rotation) {
10663
- rotate(transform, rotation);
10664
- switch (rotation) {
10665
- case 90:
10666
- translate$1(transform, height, 0);
10667
- break;
10668
- case 180:
10669
- translate$1(transform, width, height);
10670
- break;
10671
- case 270:
10672
- translate$1(transform, 0, width);
10673
- break;
10728
+ if (around === 'center') {
10729
+ rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
10730
+ }
10731
+ else {
10732
+ rotate(transform, rotation);
10733
+ switch (rotation) {
10734
+ case 90:
10735
+ translate$1(transform, height, 0);
10736
+ break;
10737
+ case 180:
10738
+ translate$1(transform, width, height);
10739
+ break;
10740
+ case 270:
10741
+ translate$1(transform, 0, width);
10742
+ break;
10743
+ }
10674
10744
  }
10675
10745
  }
10676
- origin.x = box.x;
10677
- origin.y = box.y;
10678
- if (x || y)
10679
- origin.x += x, origin.y += y;
10746
+ origin.x = box.x + x;
10747
+ origin.y = box.y + y;
10680
10748
  translate$1(transform, origin.x, origin.y);
10681
- if (scaleX) {
10749
+ if (scaleX)
10682
10750
  scaleOfOuter$2(transform, origin, scaleX, scaleY);
10683
- data.scaleX = scaleX;
10684
- data.scaleY = scaleY;
10685
- }
10686
10751
  data.transform = transform;
10687
10752
  }
10688
10753
 
10689
10754
  const { get: get$3, translate } = MatrixHelper;
10690
10755
  const tempBox = new Bounds();
10756
+ const tempPoint = {};
10691
10757
  function createData(leafPaint, image, paint, box) {
10692
10758
  let { width, height } = image;
10693
10759
  if (paint.padding)
10694
10760
  box = tempBox.set(box).shrink(paint.padding);
10695
- const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
10761
+ const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
10696
10762
  const sameBox = box.width === width && box.height === height;
10697
10763
  if (blendMode)
10698
10764
  leafPaint.blendMode = blendMode;
10699
10765
  const data = leafPaint.data = { mode };
10700
- let x, y, scaleX, scaleY;
10701
- if (offset)
10702
- x = offset.x, y = offset.y;
10703
- if (size) {
10766
+ const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
10767
+ const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10768
+ let x = 0, y = 0, scaleX, scaleY;
10769
+ if (!mode || mode === 'cover' || mode === 'fit') {
10770
+ if (!sameBox || rotation) {
10771
+ const sw = box.width / swapWidth, sh = box.height / swapHeight;
10772
+ scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10773
+ x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
10774
+ }
10775
+ }
10776
+ else if (size) {
10704
10777
  scaleX = (typeof size === 'number' ? size : size.width) / width;
10705
10778
  scaleY = (typeof size === 'number' ? size : size.height) / height;
10706
10779
  }
@@ -10708,26 +10781,36 @@ var LeaferUI = (function (exports) {
10708
10781
  scaleX = typeof scale === 'number' ? scale : scale.x;
10709
10782
  scaleY = typeof scale === 'number' ? scale : scale.y;
10710
10783
  }
10784
+ if (around) {
10785
+ const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10786
+ if (scaleX)
10787
+ imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10788
+ AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
10789
+ x += tempPoint.x, y += tempPoint.y;
10790
+ }
10791
+ if (offset)
10792
+ x += offset.x, y += offset.y;
10711
10793
  switch (mode) {
10712
10794
  case 'strench':
10713
10795
  if (!sameBox)
10714
10796
  width = box.width, height = box.height;
10715
10797
  break;
10798
+ case 'normal':
10716
10799
  case 'clip':
10717
- if (offset || scaleX || rotation)
10800
+ if (x || y || scaleX || rotation)
10718
10801
  clipMode(data, box, x, y, scaleX, scaleY, rotation);
10719
10802
  break;
10720
10803
  case 'repeat':
10721
10804
  if (!sameBox || scaleX || rotation)
10722
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
10805
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
10723
10806
  if (!repeat)
10724
10807
  data.repeat = 'repeat';
10725
10808
  break;
10726
10809
  case 'fit':
10727
10810
  case 'cover':
10728
10811
  default:
10729
- if (!sameBox || rotation)
10730
- fillOrFitMode(data, mode, box, width, height, rotation);
10812
+ if (scaleX)
10813
+ fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10731
10814
  }
10732
10815
  if (!data.transform) {
10733
10816
  if (box.x || box.y) {
@@ -10735,6 +10818,10 @@ var LeaferUI = (function (exports) {
10735
10818
  translate(data.transform, box.x, box.y);
10736
10819
  }
10737
10820
  }
10821
+ if (scaleX && mode !== 'strench') {
10822
+ data.scaleX = scaleX;
10823
+ data.scaleY = scaleY;
10824
+ }
10738
10825
  data.width = width;
10739
10826
  data.height = height;
10740
10827
  if (opacity)
@@ -11790,6 +11877,13 @@ var LeaferUI = (function (exports) {
11790
11877
  resolve();
11791
11878
  this.running = false;
11792
11879
  };
11880
+ if (filename === 'json') {
11881
+ return over({ data: leaf.toJSON() });
11882
+ }
11883
+ else if (FileHelper.fileType(filename) === 'json') {
11884
+ Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
11885
+ return over({ data: true });
11886
+ }
11793
11887
  const { leafer } = leaf;
11794
11888
  if (leafer) {
11795
11889
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
@@ -12095,7 +12189,7 @@ var LeaferUI = (function (exports) {
12095
12189
  exports.surfaceType = surfaceType;
12096
12190
  exports.tempBounds = tempBounds$1;
12097
12191
  exports.tempMatrix = tempMatrix;
12098
- exports.tempPoint = tempPoint$2;
12192
+ exports.tempPoint = tempPoint$3;
12099
12193
  exports.useCanvas = useCanvas;
12100
12194
  exports.useModule = useModule;
12101
12195
  exports.version = version;