@leafer-ui/miniapp 1.0.0-rc.21 → 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.
@@ -117,7 +117,7 @@ function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
117
117
 
118
118
  const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
119
119
  const { float: float$1 } = MathHelper;
120
- const tempPoint$3 = {};
120
+ const tempPoint$4 = {};
121
121
  function getWorld() {
122
122
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
123
123
  }
@@ -158,8 +158,8 @@ const MatrixHelper = {
158
158
  t.d *= scaleY;
159
159
  },
160
160
  scaleOfOuter(t, origin, scaleX, scaleY) {
161
- M$6.toInnerPoint(t, origin, tempPoint$3);
162
- M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
161
+ M$6.toInnerPoint(t, origin, tempPoint$4);
162
+ M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
163
163
  },
164
164
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
165
165
  M$6.translateInner(t, origin.x, origin.y);
@@ -177,8 +177,8 @@ const MatrixHelper = {
177
177
  t.d = c * sinR + d * cosR;
178
178
  },
179
179
  rotateOfOuter(t, origin, rotation) {
180
- M$6.toInnerPoint(t, origin, tempPoint$3);
181
- M$6.rotateOfInner(t, tempPoint$3, rotation);
180
+ M$6.toInnerPoint(t, origin, tempPoint$4);
181
+ M$6.rotateOfInner(t, tempPoint$4, rotation);
182
182
  },
183
183
  rotateOfInner(t, origin, rotation) {
184
184
  M$6.translateInner(t, origin.x, origin.y);
@@ -199,8 +199,8 @@ const MatrixHelper = {
199
199
  }
200
200
  },
201
201
  skewOfOuter(t, origin, skewX, skewY) {
202
- M$6.toInnerPoint(t, origin, tempPoint$3);
203
- M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
202
+ M$6.toInnerPoint(t, origin, tempPoint$4);
203
+ M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
204
204
  },
205
205
  skewOfInner(t, origin, skewX, skewY = 0) {
206
206
  M$6.translateInner(t, origin.x, origin.y);
@@ -594,7 +594,7 @@ class Point {
594
594
  return this;
595
595
  }
596
596
  }
597
- const tempPoint$2 = new Point();
597
+ const tempPoint$3 = new Point();
598
598
 
599
599
  class Matrix {
600
600
  constructor(a, b, c, d, e, f) {
@@ -1206,11 +1206,19 @@ const AroundHelper = {
1206
1206
  directionData,
1207
1207
  tempPoint: {},
1208
1208
  get: get$5,
1209
- toPoint(around, bounds, to, onlySize) {
1209
+ toPoint(around, bounds, to, onlySize, pointBounds) {
1210
1210
  to || (to = {});
1211
1211
  const point = get$5(around);
1212
1212
  to.x = point.x * bounds.width;
1213
1213
  to.y = point.y * bounds.height;
1214
+ if (pointBounds) {
1215
+ to.x -= pointBounds.x;
1216
+ to.y -= pointBounds.y;
1217
+ if (point.x)
1218
+ to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1219
+ if (point.y)
1220
+ to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1221
+ }
1214
1222
  if (!onlySize) {
1215
1223
  to.x += bounds.x;
1216
1224
  to.y += bounds.y;
@@ -2208,7 +2216,7 @@ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI
2208
2216
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2209
2217
  const { set: set$2 } = PointHelper;
2210
2218
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2211
- const tempPoint$1 = {};
2219
+ const tempPoint$2 = {};
2212
2220
  const BezierHelper = {
2213
2221
  points(data, points, curve, close) {
2214
2222
  data.push(M$5, points[0], points[1]);
@@ -2398,8 +2406,8 @@ const BezierHelper = {
2398
2406
  addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$2(pointBounds, fromX, fromY);
2399
2407
  addPoint$2(pointBounds, toX, toY);
2400
2408
  for (let i = 0, len = tList.length; i < len; i++) {
2401
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2402
- addPoint$2(pointBounds, tempPoint$1.x, tempPoint$1.y);
2409
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2410
+ addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
2403
2411
  }
2404
2412
  },
2405
2413
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2469,7 +2477,7 @@ const EllipseHelper = {
2469
2477
  };
2470
2478
 
2471
2479
  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;
2472
- const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2480
+ const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2473
2481
  const { ellipticalArc } = EllipseHelper;
2474
2482
  const debug$c = Debug.get('PathConvert');
2475
2483
  const setEndPoint$1 = {};
@@ -2662,7 +2670,7 @@ const PathConvert = {
2662
2670
  case N$3:
2663
2671
  x = old[i + 1];
2664
2672
  y = old[i + 2];
2665
- curveMode ? rect$2(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2673
+ curveMode ? rect$3(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2666
2674
  i += 5;
2667
2675
  break;
2668
2676
  case D$3:
@@ -2819,7 +2827,7 @@ const PathCommandDataHelper = {
2819
2827
  };
2820
2828
  const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
2821
2829
 
2822
- 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;
2830
+ 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;
2823
2831
  class PathCreator {
2824
2832
  set path(value) { this.__path = value; }
2825
2833
  get path() { return this.__path; }
@@ -2861,7 +2869,7 @@ class PathCreator {
2861
2869
  return this;
2862
2870
  }
2863
2871
  rect(x, y, width, height) {
2864
- rect$1(this.__path, x, y, width, height);
2872
+ rect$2(this.__path, x, y, width, height);
2865
2873
  return this;
2866
2874
  }
2867
2875
  roundRect(x, y, width, height, cornerRadius) {
@@ -3956,15 +3964,21 @@ const LeafHelper = {
3956
3964
  }
3957
3965
  return true;
3958
3966
  },
3959
- moveWorld(t, x, y) {
3960
- const local = { x, y };
3967
+ moveWorld(t, x, y = 0) {
3968
+ const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
3961
3969
  if (t.parent)
3962
3970
  toInnerPoint$1(t.parent.worldTransform, local, local, true);
3963
3971
  L.moveLocal(t, local.x, local.y);
3964
3972
  },
3965
3973
  moveLocal(t, x, y = 0) {
3966
- t.x += x;
3967
- t.y += y;
3974
+ if (typeof x === 'object') {
3975
+ t.x += x.x;
3976
+ t.y += x.y;
3977
+ }
3978
+ else {
3979
+ t.x += x;
3980
+ t.y += y;
3981
+ }
3968
3982
  },
3969
3983
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
3970
3984
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -4526,12 +4540,15 @@ const LeafEventer = {
4526
4540
  break;
4527
4541
  }
4528
4542
  }
4543
+ this.syncEventer && this.syncEventer.emitEvent(event, capture);
4529
4544
  },
4530
4545
  emitEvent(event, capture) {
4531
4546
  event.current = this;
4532
4547
  this.emit(event.type, event, capture);
4533
4548
  },
4534
4549
  hasEvent(type, capture) {
4550
+ if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
4551
+ return true;
4535
4552
  const { __bubbleMap: b, __captureMap: c } = this;
4536
4553
  const hasB = b && b[type], hasC = c && c[type];
4537
4554
  return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
@@ -4751,7 +4768,7 @@ const LeafDataProxy = {
4751
4768
  };
4752
4769
 
4753
4770
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
4754
- const { toPoint, tempPoint } = AroundHelper;
4771
+ const { toPoint, tempPoint: tempPoint$1 } = AroundHelper;
4755
4772
  const LeafMatrix = {
4756
4773
  __updateWorldMatrix() {
4757
4774
  multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
@@ -4768,8 +4785,8 @@ const LeafMatrix = {
4768
4785
  local.e = data.x;
4769
4786
  local.f = data.y;
4770
4787
  if (data.around) {
4771
- toPoint(data.around, layout.boxBounds, tempPoint);
4772
- translateInner(local, -tempPoint.x, -tempPoint.y);
4788
+ toPoint(data.around, layout.boxBounds, tempPoint$1);
4789
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y);
4773
4790
  }
4774
4791
  }
4775
4792
  this.__layout.matrixChanged = false;
@@ -6407,32 +6424,38 @@ class Picker {
6407
6424
  const target = options.target || this.target;
6408
6425
  this.exclude = options.exclude || null;
6409
6426
  this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius };
6410
- this.findList = options.findList || [];
6427
+ this.findList = new LeafList(options.findList);
6411
6428
  if (!options.findList)
6412
- this.eachFind(target.children, target.__onlyHitMask);
6413
- const list = this.findList;
6414
- const leaf = this.getBestMatchLeaf();
6429
+ this.hitBranch(target);
6430
+ const { list } = this.findList;
6431
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
6415
6432
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
6416
6433
  this.clear();
6417
6434
  return through ? { path, target: leaf, throughPath: list.length ? this.getThroughPath(list) : path } : { path, target: leaf };
6418
6435
  }
6419
- getBestMatchLeaf() {
6420
- const { findList: targets } = this;
6421
- if (targets.length > 1) {
6436
+ getBestMatchLeaf(list, bottomList, ignoreHittable) {
6437
+ if (list.length) {
6422
6438
  let find;
6423
- this.findList = [];
6439
+ this.findList = new LeafList();
6424
6440
  const { x, y } = this.point;
6425
6441
  const point = { x, y, radiusX: 0, radiusY: 0 };
6426
- for (let i = 0, len = targets.length; i < len; i++) {
6427
- find = targets[i];
6428
- if (LeafHelper.worldHittable(find)) {
6442
+ for (let i = 0, len = list.length; i < len; i++) {
6443
+ find = list[i];
6444
+ if (ignoreHittable || LeafHelper.worldHittable(find)) {
6429
6445
  this.hitChild(find, point);
6430
6446
  if (this.findList.length)
6431
- return this.findList[0];
6447
+ return this.findList.list[0];
6432
6448
  }
6433
6449
  }
6434
6450
  }
6435
- return targets[0];
6451
+ if (bottomList) {
6452
+ for (let i = 0, len = bottomList.length; i < len; i++) {
6453
+ this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
6454
+ if (this.findList.length)
6455
+ return this.findList.list[0];
6456
+ }
6457
+ }
6458
+ return list[0];
6436
6459
  }
6437
6460
  getPath(leaf) {
6438
6461
  const path = new LeafList();
@@ -6474,6 +6497,9 @@ class Picker {
6474
6497
  }
6475
6498
  return throughPath;
6476
6499
  }
6500
+ hitBranch(branch) {
6501
+ this.eachFind(branch.children, branch.__onlyHitMask);
6502
+ }
6477
6503
  eachFind(children, hitMask) {
6478
6504
  let child, hit;
6479
6505
  const { point } = this, len = children.length;
@@ -6495,11 +6521,11 @@ class Picker {
6495
6521
  }
6496
6522
  }
6497
6523
  }
6498
- hitChild(child, point) {
6524
+ hitChild(child, point, proxy) {
6499
6525
  if (this.exclude && this.exclude.has(child))
6500
6526
  return;
6501
6527
  if (child.__hitWorld(point))
6502
- this.findList.push(child);
6528
+ this.findList.add(proxy || child);
6503
6529
  }
6504
6530
  clear() {
6505
6531
  this.point = null;
@@ -6697,7 +6723,11 @@ function zoomLayerType() {
6697
6723
  defineKey(target, key, {
6698
6724
  set(value) { if (this.isLeafer)
6699
6725
  this[privateKey] = value; },
6700
- get() { return this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer; }
6726
+ get() {
6727
+ return this.isApp
6728
+ ? this.tree.zoomLayer
6729
+ : (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
6730
+ }
6701
6731
  });
6702
6732
  };
6703
6733
  }
@@ -7103,6 +7133,9 @@ let UI = UI_1 = class UI extends Leaf {
7103
7133
  pen.set(this.path = this.__.path || []);
7104
7134
  return pen;
7105
7135
  }
7136
+ get editConfig() { return undefined; }
7137
+ get editOuter() { return 'EditTool'; }
7138
+ get editInner() { return 'PathEditor'; }
7106
7139
  constructor(data) {
7107
7140
  super(data);
7108
7141
  }
@@ -7164,7 +7197,8 @@ let UI = UI_1 = class UI extends Leaf {
7164
7197
  __drawPathByBox(drawer) {
7165
7198
  const { x, y, width, height } = this.__layout.boxBounds;
7166
7199
  if (this.__.cornerRadius) {
7167
- drawer.roundRect(x, y, width, height, this.__.cornerRadius);
7200
+ const { cornerRadius } = this.__;
7201
+ drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7168
7202
  }
7169
7203
  else {
7170
7204
  drawer.rect(x, y, width, height);
@@ -7185,6 +7219,9 @@ let UI = UI_1 = class UI extends Leaf {
7185
7219
  static registerData(data) {
7186
7220
  dataProcessor(data)(this.prototype);
7187
7221
  }
7222
+ static setEditConfig(_config) { }
7223
+ static setEditOuter(_toolName) { }
7224
+ static setEditInner(_editorName) { }
7188
7225
  destroy() {
7189
7226
  this.fill = this.stroke = null;
7190
7227
  super.destroy();
@@ -7268,15 +7305,15 @@ __decorate([
7268
7305
  __decorate([
7269
7306
  dataType(false)
7270
7307
  ], UI.prototype, "draggable", void 0);
7308
+ __decorate([
7309
+ dataType()
7310
+ ], UI.prototype, "dragBounds", void 0);
7271
7311
  __decorate([
7272
7312
  dataType(false)
7273
7313
  ], UI.prototype, "editable", void 0);
7274
7314
  __decorate([
7275
7315
  dataType('size')
7276
7316
  ], UI.prototype, "editSize", void 0);
7277
- __decorate([
7278
- dataType()
7279
- ], UI.prototype, "editorStyle", void 0);
7280
7317
  __decorate([
7281
7318
  hitType(true)
7282
7319
  ], UI.prototype, "hittable", void 0);
@@ -7468,7 +7505,6 @@ Group = __decorate([
7468
7505
  var Leafer_1;
7469
7506
  const debug$3 = Debug.get('Leafer');
7470
7507
  let Leafer = Leafer_1 = class Leafer extends Group {
7471
- static get version() { return '1.0.0-rc.21'; }
7472
7508
  get __tag() { return 'Leafer'; }
7473
7509
  get isApp() { return false; }
7474
7510
  get app() { return this.parent || this; }
@@ -7521,7 +7557,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7521
7557
  if (this.isApp)
7522
7558
  this.__setApp();
7523
7559
  this.__checkAutoLayout(config);
7524
- this.updateLazyBounds();
7525
7560
  this.view = canvas.view;
7526
7561
  if (parentApp) {
7527
7562
  this.__bindApp(parentApp);
@@ -7765,6 +7800,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7765
7800
  __listenEvents() {
7766
7801
  const runId = Run.start('FirstCreate ' + this.innerName);
7767
7802
  this.once(LeaferEvent.START, () => Run.end(runId));
7803
+ this.once(LayoutEvent.START, () => this.updateLazyBounds());
7768
7804
  this.once(LayoutEvent.END, () => this.__onReady());
7769
7805
  this.once(RenderEvent.START, () => this.__onCreated());
7770
7806
  this.once(RenderEvent.END, () => this.__onViewReady());
@@ -7835,8 +7871,8 @@ Rect = __decorate([
7835
7871
  registerUI()
7836
7872
  ], Rect);
7837
7873
 
7838
- const rect = Rect.prototype;
7839
- const group = Group.prototype;
7874
+ const rect$1 = Rect.prototype;
7875
+ const group$1 = Group.prototype;
7840
7876
  const bounds$1 = {};
7841
7877
  const { copy: copy$3, add } = BoundsHelper;
7842
7878
  let Box = class Box extends Group {
@@ -7915,28 +7951,28 @@ __decorate([
7915
7951
  affectRenderBoundsType('show')
7916
7952
  ], Box.prototype, "overflow", void 0);
7917
7953
  __decorate([
7918
- rewrite(rect.__updateStrokeSpread)
7954
+ rewrite(rect$1.__updateStrokeSpread)
7919
7955
  ], Box.prototype, "__updateStrokeSpread", null);
7920
7956
  __decorate([
7921
- rewrite(rect.__updateRenderSpread)
7957
+ rewrite(rect$1.__updateRenderSpread)
7922
7958
  ], Box.prototype, "__updateRectRenderSpread", null);
7923
7959
  __decorate([
7924
- rewrite(rect.__updateBoxBounds)
7960
+ rewrite(rect$1.__updateBoxBounds)
7925
7961
  ], Box.prototype, "__updateRectBoxBounds", null);
7926
7962
  __decorate([
7927
- rewrite(rect.__updateStrokeBounds)
7963
+ rewrite(rect$1.__updateStrokeBounds)
7928
7964
  ], Box.prototype, "__updateStrokeBounds", null);
7929
7965
  __decorate([
7930
- rewrite(rect.__updateRenderBounds)
7966
+ rewrite(rect$1.__updateRenderBounds)
7931
7967
  ], Box.prototype, "__updateRectRenderBounds", null);
7932
7968
  __decorate([
7933
- rewrite(rect.__updateChange)
7969
+ rewrite(rect$1.__updateChange)
7934
7970
  ], Box.prototype, "__updateRectChange", null);
7935
7971
  __decorate([
7936
- rewrite(rect.__render)
7972
+ rewrite(rect$1.__render)
7937
7973
  ], Box.prototype, "__renderRect", null);
7938
7974
  __decorate([
7939
- rewrite(group.__render)
7975
+ rewrite(group$1.__render)
7940
7976
  ], Box.prototype, "__renderGroup", null);
7941
7977
  Box = __decorate([
7942
7978
  rewriteAble(),
@@ -8283,6 +8319,7 @@ Canvas = __decorate([
8283
8319
  const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8284
8320
  let Text = class Text extends UI {
8285
8321
  get __tag() { return 'Text'; }
8322
+ get editInner() { return 'TextEditor'; }
8286
8323
  get textDrawData() {
8287
8324
  this.__layout.update();
8288
8325
  return this.__.__textDrawData;
@@ -8605,7 +8642,8 @@ let App = class App extends Leafer {
8605
8642
  this.renderer.update();
8606
8643
  }
8607
8644
  __render(canvas, options) {
8608
- canvas.setWorld(options.matrix || this.__world);
8645
+ if (options.matrix)
8646
+ canvas.setWorld(options.matrix);
8609
8647
  this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8610
8648
  }
8611
8649
  __onResize(event) {
@@ -8727,6 +8765,35 @@ let DragEvent = class DragEvent extends PointerEvent {
8727
8765
  static setData(data) {
8728
8766
  this.data = data;
8729
8767
  }
8768
+ static getValidMove(leaf, start, total) {
8769
+ const { draggable, dragBounds, x, y } = leaf;
8770
+ const move = leaf.getLocalPoint(total, null, true);
8771
+ move.x += start.x - x;
8772
+ move.y += start.y - y;
8773
+ if (dragBounds)
8774
+ this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
8775
+ if (draggable === 'x')
8776
+ move.y = 0;
8777
+ if (draggable === 'y')
8778
+ move.x = 0;
8779
+ return move;
8780
+ }
8781
+ static getMoveInDragBounds(box, dragBounds, move, change) {
8782
+ const x = box.x + move.x, y = box.y + move.y;
8783
+ const right = x + box.width, bottom = y + box.height;
8784
+ const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8785
+ if (!change)
8786
+ move = Object.assign({}, move);
8787
+ if (x < dragBounds.x)
8788
+ move.x += dragBounds.x - x;
8789
+ else if (right > boundsRight)
8790
+ move.x += boundsRight - right;
8791
+ if (y < dragBounds.y)
8792
+ move.y += dragBounds.y - y;
8793
+ else if (bottom > boundsBottom)
8794
+ move.y += boundsBottom - bottom;
8795
+ return move;
8796
+ }
8730
8797
  getPageMove(total) {
8731
8798
  this.assignMove(total);
8732
8799
  return this.current.getPagePoint(move, null, true);
@@ -8836,9 +8903,7 @@ function addInteractionWindow(leafer) {
8836
8903
  if (leafer.isApp)
8837
8904
  return;
8838
8905
  leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => {
8839
- const { x, y } = leafer.getValidMove(e.moveX, e.moveY);
8840
- if (x || y)
8841
- leafer.zoomLayer.move(x, y);
8906
+ leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
8842
8907
  }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
8843
8908
  const { zoomLayer } = leafer;
8844
8909
  const changeScale = leafer.getValidScale(e.scale);
@@ -9107,9 +9172,14 @@ class Dragger {
9107
9172
  if (this.dragging) {
9108
9173
  this.interaction.emit(DragEvent.START, this.dragData);
9109
9174
  this.getDragableList(this.dragData.path);
9175
+ this.setDragStartPoints(this.realDragableList = this.getList());
9110
9176
  }
9111
9177
  }
9112
9178
  }
9179
+ setDragStartPoints(list) {
9180
+ this.dragStartPoints = {};
9181
+ list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9182
+ }
9113
9183
  getDragableList(path) {
9114
9184
  let leaf;
9115
9185
  for (let i = 0, len = path.length; i < len; i++) {
@@ -9139,10 +9209,10 @@ class Dragger {
9139
9209
  }
9140
9210
  dragReal() {
9141
9211
  const { running } = this.interaction;
9142
- const list = this.getList();
9212
+ const list = this.realDragableList;
9143
9213
  if (list.length && running) {
9144
- const { moveX, moveY } = this.dragData;
9145
- list.forEach(leaf => leaf.draggable && leaf.moveWorld(moveX, moveY));
9214
+ const { totalX, totalY } = this.dragData;
9215
+ list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
9146
9216
  }
9147
9217
  }
9148
9218
  dragOverOrOut(data) {
@@ -9611,7 +9681,8 @@ class InteractionBase {
9611
9681
  }
9612
9682
  findPath(data, options) {
9613
9683
  const { hitRadius, through } = this.config.pointer;
9614
- const find = this.selector.getByPoint(data, hitRadius, options || { through });
9684
+ const { bottomList } = this;
9685
+ const find = this.selector.getByPoint(data, hitRadius, Object.assign({ bottomList, name: data.type }, (options || { through })));
9615
9686
  if (find.throughPath)
9616
9687
  data.throughPath = find.throughPath;
9617
9688
  data.path = find.path;
@@ -9624,7 +9695,7 @@ class InteractionBase {
9624
9695
  const app = this.target.app;
9625
9696
  if (!app || !app.isApp)
9626
9697
  return false;
9627
- return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree));
9698
+ return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
9628
9699
  }
9629
9700
  checkPath(data, useDefaultPath) {
9630
9701
  if (useDefaultPath || this.canMove(data))
@@ -9690,7 +9761,7 @@ class InteractionBase {
9690
9761
  const { path } = data;
9691
9762
  for (let i = 0, len = path.length; i < len; i++) {
9692
9763
  leaf = path.list[i];
9693
- cursor = leaf.cursor;
9764
+ cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
9694
9765
  if (cursor)
9695
9766
  break;
9696
9767
  }
@@ -9848,6 +9919,8 @@ const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
9848
9919
  const inner = {};
9849
9920
  const leaf = Leaf.prototype;
9850
9921
  leaf.__hitWorld = function (point) {
9922
+ if (!this.__.hitSelf)
9923
+ return false;
9851
9924
  if (this.__.hitRadius) {
9852
9925
  copy$2(inner, point), point = inner;
9853
9926
  setRadius(point, this.__.hitRadius);
@@ -9875,8 +9948,8 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
9875
9948
  this.__drawRenderPath(canvas); };
9876
9949
 
9877
9950
  const matrix = new Matrix();
9878
- const ui$1 = UI.prototype;
9879
- ui$1.__updateHitCanvas = function () {
9951
+ const ui$2 = UI.prototype;
9952
+ ui$2.__updateHitCanvas = function () {
9880
9953
  const data = this.__, { hitCanvasManager } = this.leafer;
9881
9954
  const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
9882
9955
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
@@ -9903,7 +9976,7 @@ ui$1.__updateHitCanvas = function () {
9903
9976
  this.__drawHitPath(h);
9904
9977
  h.setStrokeOptions(data);
9905
9978
  };
9906
- ui$1.__hit = function (inner) {
9979
+ ui$2.__hit = function (inner) {
9907
9980
  if (Platform.name === 'miniapp')
9908
9981
  this.__drawHitPath(this.__hitCanvas);
9909
9982
  const data = this.__;
@@ -9943,22 +10016,24 @@ ui$1.__hit = function (inner) {
9943
10016
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
9944
10017
  };
9945
10018
 
9946
- const ui = new UI();
9947
- Rect.prototype.__updateHitCanvas = function () {
10019
+ const ui$1 = new UI();
10020
+ const rect = Rect.prototype;
10021
+ rect.__updateHitCanvas = function () {
9948
10022
  if (this.stroke || this.cornerRadius)
9949
- ui.__updateHitCanvas.call(this);
10023
+ ui$1.__updateHitCanvas.call(this);
9950
10024
  };
9951
- Rect.prototype.__hitFill = function (inner) {
9952
- return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10025
+ rect.__hitFill = function (inner) {
10026
+ return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
9953
10027
  };
9954
10028
 
9955
- UI.prototype.find = function (condition, options) {
10029
+ const ui = UI.prototype, group = Group.prototype;
10030
+ ui.find = function (condition, options) {
9956
10031
  return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
9957
10032
  };
9958
- UI.prototype.findOne = function (condition, options) {
10033
+ ui.findOne = function (condition, options) {
9959
10034
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
9960
10035
  };
9961
- Group.prototype.pick = function (hitPoint, options) {
10036
+ group.pick = function (hitPoint, options) {
9962
10037
  this.__layout.update();
9963
10038
  if (!options)
9964
10039
  options = {};
@@ -10375,79 +10450,75 @@ const PaintModule = {
10375
10450
 
10376
10451
  let origin = {};
10377
10452
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
10378
- function fillOrFitMode(data, mode, box, width, height, rotation) {
10453
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10379
10454
  const transform = get$4();
10380
- const swap = rotation && rotation !== 180;
10381
- const sw = box.width / (swap ? height : width);
10382
- const sh = box.height / (swap ? width : height);
10383
- const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10384
- const x = box.x + (box.width - width * scale) / 2;
10385
- const y = box.y + (box.height - height * scale) / 2;
10386
- translate$1(transform, x, y);
10387
- scaleHelper(transform, scale);
10455
+ translate$1(transform, box.x + x, box.y + y);
10456
+ scaleHelper(transform, scaleX, scaleY);
10388
10457
  if (rotation)
10389
10458
  rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10390
- data.scaleX = data.scaleY = scale;
10391
10459
  data.transform = transform;
10392
10460
  }
10393
10461
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10394
10462
  const transform = get$4();
10395
- translate$1(transform, box.x, box.y);
10396
- if (x || y)
10397
- translate$1(transform, x, y);
10398
- if (scaleX) {
10463
+ translate$1(transform, box.x + x, box.y + y);
10464
+ if (scaleX)
10399
10465
  scaleHelper(transform, scaleX, scaleY);
10400
- data.scaleX = transform.a;
10401
- data.scaleY = transform.d;
10402
- }
10403
10466
  if (rotation)
10404
10467
  rotate(transform, rotation);
10405
10468
  data.transform = transform;
10406
10469
  }
10407
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
10470
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
10408
10471
  const transform = get$4();
10409
10472
  if (rotation) {
10410
- rotate(transform, rotation);
10411
- switch (rotation) {
10412
- case 90:
10413
- translate$1(transform, height, 0);
10414
- break;
10415
- case 180:
10416
- translate$1(transform, width, height);
10417
- break;
10418
- case 270:
10419
- translate$1(transform, 0, width);
10420
- break;
10473
+ if (around === 'center') {
10474
+ rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
10475
+ }
10476
+ else {
10477
+ rotate(transform, rotation);
10478
+ switch (rotation) {
10479
+ case 90:
10480
+ translate$1(transform, height, 0);
10481
+ break;
10482
+ case 180:
10483
+ translate$1(transform, width, height);
10484
+ break;
10485
+ case 270:
10486
+ translate$1(transform, 0, width);
10487
+ break;
10488
+ }
10421
10489
  }
10422
10490
  }
10423
- origin.x = box.x;
10424
- origin.y = box.y;
10425
- if (x || y)
10426
- origin.x += x, origin.y += y;
10491
+ origin.x = box.x + x;
10492
+ origin.y = box.y + y;
10427
10493
  translate$1(transform, origin.x, origin.y);
10428
- if (scaleX) {
10494
+ if (scaleX)
10429
10495
  scaleOfOuter$2(transform, origin, scaleX, scaleY);
10430
- data.scaleX = scaleX;
10431
- data.scaleY = scaleY;
10432
- }
10433
10496
  data.transform = transform;
10434
10497
  }
10435
10498
 
10436
10499
  const { get: get$3, translate } = MatrixHelper;
10437
10500
  const tempBox = new Bounds();
10501
+ const tempPoint = {};
10438
10502
  function createData(leafPaint, image, paint, box) {
10439
10503
  let { width, height } = image;
10440
10504
  if (paint.padding)
10441
10505
  box = tempBox.set(box).shrink(paint.padding);
10442
- const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
10506
+ const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
10443
10507
  const sameBox = box.width === width && box.height === height;
10444
10508
  if (blendMode)
10445
10509
  leafPaint.blendMode = blendMode;
10446
10510
  const data = leafPaint.data = { mode };
10447
- let x, y, scaleX, scaleY;
10448
- if (offset)
10449
- x = offset.x, y = offset.y;
10450
- if (size) {
10511
+ const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
10512
+ const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10513
+ let x = 0, y = 0, scaleX, scaleY;
10514
+ if (!mode || mode === 'cover' || mode === 'fit') {
10515
+ if (!sameBox || rotation) {
10516
+ const sw = box.width / swapWidth, sh = box.height / swapHeight;
10517
+ scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10518
+ x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
10519
+ }
10520
+ }
10521
+ else if (size) {
10451
10522
  scaleX = (typeof size === 'number' ? size : size.width) / width;
10452
10523
  scaleY = (typeof size === 'number' ? size : size.height) / height;
10453
10524
  }
@@ -10455,26 +10526,36 @@ function createData(leafPaint, image, paint, box) {
10455
10526
  scaleX = typeof scale === 'number' ? scale : scale.x;
10456
10527
  scaleY = typeof scale === 'number' ? scale : scale.y;
10457
10528
  }
10529
+ if (around) {
10530
+ const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10531
+ if (scaleX)
10532
+ imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10533
+ AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
10534
+ x += tempPoint.x, y += tempPoint.y;
10535
+ }
10536
+ if (offset)
10537
+ x += offset.x, y += offset.y;
10458
10538
  switch (mode) {
10459
10539
  case 'strench':
10460
10540
  if (!sameBox)
10461
10541
  width = box.width, height = box.height;
10462
10542
  break;
10543
+ case 'normal':
10463
10544
  case 'clip':
10464
- if (offset || scaleX || rotation)
10545
+ if (x || y || scaleX || rotation)
10465
10546
  clipMode(data, box, x, y, scaleX, scaleY, rotation);
10466
10547
  break;
10467
10548
  case 'repeat':
10468
10549
  if (!sameBox || scaleX || rotation)
10469
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
10550
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
10470
10551
  if (!repeat)
10471
10552
  data.repeat = 'repeat';
10472
10553
  break;
10473
10554
  case 'fit':
10474
10555
  case 'cover':
10475
10556
  default:
10476
- if (!sameBox || rotation)
10477
- fillOrFitMode(data, mode, box, width, height, rotation);
10557
+ if (scaleX)
10558
+ fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10478
10559
  }
10479
10560
  if (!data.transform) {
10480
10561
  if (box.x || box.y) {
@@ -10482,6 +10563,10 @@ function createData(leafPaint, image, paint, box) {
10482
10563
  translate(data.transform, box.x, box.y);
10483
10564
  }
10484
10565
  }
10566
+ if (scaleX && mode !== 'strench') {
10567
+ data.scaleX = scaleX;
10568
+ data.scaleY = scaleY;
10569
+ }
10485
10570
  data.width = width;
10486
10571
  data.height = height;
10487
10572
  if (opacity)
@@ -11537,6 +11622,13 @@ const ExportModule = {
11537
11622
  resolve();
11538
11623
  this.running = false;
11539
11624
  };
11625
+ if (filename === 'json') {
11626
+ return over({ data: leaf.toJSON() });
11627
+ }
11628
+ else if (FileHelper.fileType(filename) === 'json') {
11629
+ Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
11630
+ return over({ data: true });
11631
+ }
11540
11632
  const { leafer } = leaf;
11541
11633
  if (leafer) {
11542
11634
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
@@ -11713,4 +11805,4 @@ LeaferCanvas.prototype.updateViewSize = function () {
11713
11805
  }
11714
11806
  };
11715
11807
 
11716
- export { AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$2 as tempPoint, useCanvas, useModule, version, zoomLayerType };
11808
+ export { AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, zoomLayerType };