leafer-ui 1.0.0-rc.4 → 1.0.0-rc.5

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
@@ -650,14 +650,14 @@ var LeaferUI = (function (exports) {
650
650
  },
651
651
  getFitMatrix(t, put) {
652
652
  const scale = Math.min(1, Math.min(t.width / put.width, t.height / put.height));
653
- return new Matrix(scale, 0, 0, scale, -Math.ceil(put.x * scale), -Math.ceil(put.y * scale));
653
+ return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
654
654
  },
655
655
  getSpread(t, spreadX, spreadY) {
656
656
  const n = {};
657
657
  B.copyAndSpread(n, t, spreadX, spreadY);
658
658
  return n;
659
659
  },
660
- spread(t, spreadX, spreadY) {
660
+ spread(t, spreadX, spreadY = spreadX) {
661
661
  B.copyAndSpread(t, t, spreadX, spreadY);
662
662
  },
663
663
  ceil(t) {
@@ -798,8 +798,8 @@ var LeaferUI = (function (exports) {
798
798
  getFitMatrix(put) {
799
799
  return BoundsHelper.getFitMatrix(this, put);
800
800
  }
801
- spread(size) {
802
- BoundsHelper.spread(this, size);
801
+ spread(spreadX, spreadY) {
802
+ BoundsHelper.spread(this, spreadX, spreadY);
803
803
  return this;
804
804
  }
805
805
  ceil() {
@@ -1381,6 +1381,8 @@ var LeaferUI = (function (exports) {
1381
1381
  }
1382
1382
 
1383
1383
  const FileHelper = {
1384
+ opacityTypes: ['png', 'webp', 'svg'],
1385
+ upperCaseTypeMap: {},
1384
1386
  mineType(type) {
1385
1387
  if (!type || type.startsWith('image'))
1386
1388
  return type;
@@ -1393,6 +1395,7 @@ var LeaferUI = (function (exports) {
1393
1395
  return l[l.length - 1];
1394
1396
  }
1395
1397
  };
1398
+ FileHelper.opacityTypes.forEach(type => FileHelper.upperCaseTypeMap[type] = type.toUpperCase());
1396
1399
 
1397
1400
  /******************************************************************************
1398
1401
  Copyright (c) Microsoft Corporation.
@@ -2333,7 +2336,7 @@ var LeaferUI = (function (exports) {
2333
2336
  const centerX = fromX + halfX + rotationCos * cx - rotationSin * cy;
2334
2337
  const centerY = fromY + halfY + rotationSin * cx + rotationCos * cy;
2335
2338
  const anticlockwise = totalRadian < 0 ? 1 : 0;
2336
- if (curveMode) {
2339
+ if (curveMode || Platform.name === 'node') {
2337
2340
  ellipse$5(data, centerX, centerY, radiusX, radiusY, rotation, startRadian / OneRadian, endRadian / OneRadian, anticlockwise);
2338
2341
  }
2339
2342
  else {
@@ -3260,6 +3263,23 @@ var LeaferUI = (function (exports) {
3260
3263
  list.length = 0;
3261
3264
  }
3262
3265
  },
3266
+ isPixel(config) {
3267
+ return FileHelper.opacityTypes.some(item => I$1.isFormat(item, config));
3268
+ },
3269
+ isFormat(format, config) {
3270
+ if (config.format === format)
3271
+ return true;
3272
+ const { url } = config;
3273
+ if (url.startsWith('data:')) {
3274
+ if (url.startsWith('data:' + FileHelper.mineType(format)))
3275
+ return true;
3276
+ }
3277
+ else {
3278
+ if (url.includes('.' + format) || url.includes('.' + FileHelper.upperCaseTypeMap[format]))
3279
+ return true;
3280
+ }
3281
+ return false;
3282
+ },
3263
3283
  destroy() {
3264
3284
  I$1.map = {};
3265
3285
  }
@@ -3275,17 +3295,7 @@ var LeaferUI = (function (exports) {
3275
3295
  this.waitComplete = [];
3276
3296
  this.innerId = create$1(IMAGE);
3277
3297
  this.config = config || { url: '' };
3278
- const { url } = config;
3279
- if (url.startsWith('data:')) {
3280
- if (url.startsWith('data:image/svg'))
3281
- this.isSVG = true;
3282
- }
3283
- else {
3284
- if (url.includes('.svg'))
3285
- this.isSVG = true;
3286
- }
3287
- if (this.config.format === 'svg')
3288
- this.isSVG = true;
3298
+ this.isSVG = ImageManager.isFormat('svg', config);
3289
3299
  }
3290
3300
  load(onSuccess, onError) {
3291
3301
  if (!this.loading) {
@@ -3358,13 +3368,19 @@ var LeaferUI = (function (exports) {
3358
3368
  }
3359
3369
  stopDefault() {
3360
3370
  this.isStopDefault = true;
3371
+ if (this.origin)
3372
+ Platform.event.stopDefault(this.origin);
3361
3373
  }
3362
3374
  stopNow() {
3363
3375
  this.isStopNow = true;
3364
3376
  this.isStop = true;
3377
+ if (this.origin)
3378
+ Platform.event.stopNow(this.origin);
3365
3379
  }
3366
3380
  stop() {
3367
3381
  this.isStop = true;
3382
+ if (this.origin)
3383
+ Platform.event.stop(this.origin);
3368
3384
  }
3369
3385
  }
3370
3386
 
@@ -3426,20 +3442,6 @@ var LeaferUI = (function (exports) {
3426
3442
  }
3427
3443
  ResizeEvent.RESIZE = 'resize';
3428
3444
 
3429
- class TransformEvent extends Event {
3430
- constructor(type, params) {
3431
- super(type);
3432
- if (params)
3433
- Object.assign(this, params);
3434
- }
3435
- }
3436
- TransformEvent.START = 'transform.start';
3437
- TransformEvent.CHANGE = 'transform.change';
3438
- TransformEvent.END = 'transform.end';
3439
- TransformEvent.BEFORE_START = 'transform.before_start';
3440
- TransformEvent.BEFORE_CHANGE = 'transform.before_change';
3441
- TransformEvent.BEFORE_END = 'transform.before_end';
3442
-
3443
3445
  class WatchEvent extends Event {
3444
3446
  constructor(type, data) {
3445
3447
  super(type);
@@ -3540,15 +3542,15 @@ var LeaferUI = (function (exports) {
3540
3542
  this.bubbles = true;
3541
3543
  Object.assign(this, params);
3542
3544
  }
3543
- getInner(target) {
3544
- if (!target)
3545
- target = this.current;
3546
- return target.getInnerPoint(this);
3545
+ getInner(relative) {
3546
+ if (!relative)
3547
+ relative = this.current;
3548
+ return relative.getInnerPoint(this);
3547
3549
  }
3548
- getLocal(target) {
3549
- if (!target)
3550
- target = this.current;
3551
- return target.getLocalPoint(this);
3550
+ getLocal(relative) {
3551
+ if (!relative)
3552
+ relative = this.current;
3553
+ return relative.getLocalPoint(this);
3552
3554
  }
3553
3555
  static changeName(oldName, newName) {
3554
3556
  EventCreator.changeName(oldName, newName);
@@ -3595,7 +3597,7 @@ var LeaferUI = (function (exports) {
3595
3597
  defineLeafAttr(target, key, defaultValue, {
3596
3598
  set(value) {
3597
3599
  this.__setAttr(key, value);
3598
- this.__layout.positionChanged || this.__layout.positionChange();
3600
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3599
3601
  }
3600
3602
  });
3601
3603
  };
@@ -3627,7 +3629,7 @@ var LeaferUI = (function (exports) {
3627
3629
  this.__setAttr(key, value);
3628
3630
  this.__layout.boxChanged || this.__layout.boxChange();
3629
3631
  if (this.__.around)
3630
- this.__layout.positionChanged || this.__layout.positionChange();
3632
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3631
3633
  }
3632
3634
  });
3633
3635
  };
@@ -3863,29 +3865,36 @@ var LeaferUI = (function (exports) {
3863
3865
  exports.PointerEvent.DOUBLE_CLICK = 'double_click';
3864
3866
  exports.PointerEvent.LONG_PRESS = 'long_press';
3865
3867
  exports.PointerEvent.LONG_TAP = 'long_tap';
3868
+ exports.PointerEvent.MENU = 'pointer.menu';
3866
3869
  exports.PointerEvent = __decorate([
3867
3870
  registerUIEvent()
3868
3871
  ], exports.PointerEvent);
3869
3872
 
3870
3873
  const move = {};
3871
3874
  exports.DragEvent = class DragEvent extends exports.PointerEvent {
3872
- getInnerMove(target, total) {
3873
- if (!target)
3874
- target = this.current;
3875
+ static setList(data) {
3876
+ this.list = data instanceof LeafList ? data : new LeafList(data);
3877
+ }
3878
+ static setData(data) {
3879
+ this.data = data;
3880
+ }
3881
+ getInnerMove(relative, total) {
3882
+ if (!relative)
3883
+ relative = this.current;
3875
3884
  this.assignMove(total);
3876
- return target.getInnerPoint(move, null, true);
3885
+ return relative.getInnerPoint(move, null, true);
3877
3886
  }
3878
- getLocalMove(target, total) {
3879
- if (!target)
3880
- target = this.current;
3887
+ getLocalMove(relative, total) {
3888
+ if (!relative)
3889
+ relative = this.current;
3881
3890
  this.assignMove(total);
3882
- return target.getLocalPoint(move, null, true);
3891
+ return relative.getLocalPoint(move, null, true);
3883
3892
  }
3884
- getInnerTotal(target) {
3885
- return this.getInnerMove(target, true);
3893
+ getInnerTotal(relative) {
3894
+ return this.getInnerMove(relative, true);
3886
3895
  }
3887
- getLocalTotal(target) {
3888
- return this.getLocalMove(target, true);
3896
+ getLocalTotal(relative) {
3897
+ return this.getLocalMove(relative, true);
3889
3898
  }
3890
3899
  assignMove(total) {
3891
3900
  move.x = total ? this.totalX : this.moveX;
@@ -3904,17 +3913,16 @@ var LeaferUI = (function (exports) {
3904
3913
  registerUIEvent()
3905
3914
  ], exports.DragEvent);
3906
3915
 
3907
- var DropEvent_1;
3908
- exports.DropEvent = DropEvent_1 = class DropEvent extends exports.PointerEvent {
3916
+ exports.DropEvent = class DropEvent extends exports.PointerEvent {
3909
3917
  static setList(data) {
3910
- DropEvent_1.dragList = data instanceof LeafList ? data : new LeafList(data);
3918
+ exports.DragEvent.setList(data);
3911
3919
  }
3912
3920
  static setData(data) {
3913
- this.dragData = data;
3921
+ exports.DragEvent.setData(data);
3914
3922
  }
3915
3923
  };
3916
3924
  exports.DropEvent.DROP = 'drop';
3917
- exports.DropEvent = DropEvent_1 = __decorate([
3925
+ exports.DropEvent = __decorate([
3918
3926
  registerUIEvent()
3919
3927
  ], exports.DropEvent);
3920
3928
 
@@ -4021,7 +4029,6 @@ var LeaferUI = (function (exports) {
4021
4029
  this.moveEnd();
4022
4030
  this.zoomEnd();
4023
4031
  this.rotateEnd();
4024
- this.transformMode = null;
4025
4032
  }
4026
4033
  moveEnd() {
4027
4034
  if (this.moveData) {
@@ -4046,7 +4053,7 @@ var LeaferUI = (function (exports) {
4046
4053
  }
4047
4054
  }
4048
4055
 
4049
- const { copy: copy$5, translate: translate$2, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter } = MatrixHelper;
4056
+ const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter } = MatrixHelper;
4050
4057
  const matrix = {};
4051
4058
  const LeafHelper = {
4052
4059
  updateAllWorldMatrix(leaf) {
@@ -4089,63 +4096,41 @@ var LeaferUI = (function (exports) {
4089
4096
  return true;
4090
4097
  },
4091
4098
  moveWorld(t, x, y) {
4092
- t.__layout.checkUpdate();
4093
4099
  const local = { x, y };
4094
4100
  if (t.parent)
4095
- toInnerPoint$1(t.parent.__world, local, local, true);
4101
+ toInnerPoint$1(t.parent.worldTransform, local, local, true);
4096
4102
  L.moveLocal(t, local.x, local.y);
4097
4103
  },
4098
4104
  moveLocal(t, x, y = 0) {
4099
4105
  t.x += x;
4100
4106
  t.y += y;
4101
4107
  },
4102
- zoomOfWorld(t, origin, scaleX, scaleY, moveLayer) {
4103
- t.__layout.checkUpdate();
4104
- const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin;
4105
- this.zoomOfLocal(t, local, scaleX, scaleY, moveLayer);
4108
+ zoomOfWorld(t, origin, scaleX, scaleY) {
4109
+ this.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY);
4106
4110
  },
4107
- zoomOfLocal(t, origin, scaleX, scaleY = scaleX, moveLayer) {
4111
+ zoomOfLocal(t, origin, scaleX, scaleY = scaleX) {
4108
4112
  copy$5(matrix, t.__local);
4109
- if (moveLayer)
4110
- translate$2(matrix, moveLayer.x, moveLayer.y);
4111
4113
  scaleOfOuter$3(matrix, origin, scaleX, scaleY);
4112
- if (!moveLayer)
4113
- moveLayer = t;
4114
- moveLayer.x += matrix.e - t.__local.e;
4115
- moveLayer.y += matrix.f - t.__local.f;
4114
+ moveByMatrix(t, matrix);
4116
4115
  t.scaleX *= scaleX;
4117
4116
  t.scaleY *= scaleY;
4118
4117
  },
4119
- rotateOfWorld(t, origin, angle, moveLayer) {
4120
- t.__layout.checkUpdate();
4121
- const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin;
4122
- this.rotateOfLocal(t, local, angle, moveLayer);
4118
+ rotateOfWorld(t, origin, angle) {
4119
+ this.rotateOfLocal(t, getTempLocal(t, origin), angle);
4123
4120
  },
4124
- rotateOfLocal(t, origin, angle, moveLayer) {
4121
+ rotateOfLocal(t, origin, angle) {
4125
4122
  copy$5(matrix, t.__local);
4126
- if (moveLayer)
4127
- translate$2(matrix, moveLayer.x, moveLayer.y);
4128
4123
  rotateOfOuter$3(matrix, origin, angle);
4129
- if (!moveLayer)
4130
- moveLayer = t;
4131
- moveLayer.x += matrix.e - t.__local.e;
4132
- moveLayer.y += matrix.f - t.__local.f;
4124
+ moveByMatrix(t, matrix);
4133
4125
  t.rotation = MathHelper.formatRotation(t.rotation + angle);
4134
4126
  },
4135
- skewOfWorld(t, origin, skewX, skewY, moveLayer) {
4136
- t.__layout.checkUpdate();
4137
- const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin;
4138
- this.skewOfLocal(t, local, skewX, skewY, moveLayer);
4127
+ skewOfWorld(t, origin, skewX, skewY) {
4128
+ this.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY);
4139
4129
  },
4140
- skewOfLocal(t, origin, skewX, skewY, moveLayer) {
4130
+ skewOfLocal(t, origin, skewX, skewY) {
4141
4131
  copy$5(matrix, t.__local);
4142
- if (moveLayer)
4143
- translate$2(matrix, moveLayer.x, moveLayer.y);
4144
4132
  skewOfOuter(matrix, origin, skewX, skewY);
4145
- if (!moveLayer)
4146
- moveLayer = t;
4147
- moveLayer.x = matrix.e - t.__local.e;
4148
- moveLayer.y = matrix.f - t.__local.f;
4133
+ moveByMatrix(t, matrix);
4149
4134
  t.skewX = MathHelper.formatSkew(t.skewX + skewX);
4150
4135
  t.skewY = MathHelper.formatSkew(t.skewY + skewY);
4151
4136
  },
@@ -4159,6 +4144,14 @@ var LeaferUI = (function (exports) {
4159
4144
  };
4160
4145
  const L = LeafHelper;
4161
4146
  const { updateAllWorldMatrix: updateAllWorldMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4147
+ function moveByMatrix(t, matrix) {
4148
+ t.x += matrix.e - t.__local.e;
4149
+ t.y += matrix.f - t.__local.f;
4150
+ }
4151
+ function getTempLocal(t, world) {
4152
+ t.__layout.checkUpdate();
4153
+ return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
4154
+ }
4162
4155
 
4163
4156
  const LeafBoundsHelper = {
4164
4157
  worldBounds(target) {
@@ -4320,7 +4313,8 @@ var LeaferUI = (function (exports) {
4320
4313
  };
4321
4314
  const I = InteractionHelper;
4322
4315
 
4323
- const { getDragEventData, getDropEventData, getSwipeEventData, filterPathByEventType } = InteractionHelper;
4316
+ const emptyList = new LeafList();
4317
+ const { getDragEventData, getDropEventData, getSwipeEventData } = InteractionHelper;
4324
4318
  class Dragger {
4325
4319
  constructor(interaction) {
4326
4320
  this.interaction = interaction;
@@ -4328,8 +4322,8 @@ var LeaferUI = (function (exports) {
4328
4322
  setDragData(data) {
4329
4323
  this.dragData = getDragEventData(data, data, data);
4330
4324
  }
4331
- getDragList() {
4332
- return this.dragging ? exports.DropEvent.dragList || this.dragList : null;
4325
+ getList() {
4326
+ return this.dragging ? (exports.DragEvent.list || this.interaction.selector.list || this.dragableList || emptyList) : emptyList;
4333
4327
  }
4334
4328
  checkDrag(data, canDrag) {
4335
4329
  const { interaction } = this;
@@ -4358,7 +4352,7 @@ var LeaferUI = (function (exports) {
4358
4352
  interaction.emit(exports.MoveEvent.MOVE, this.dragData);
4359
4353
  }
4360
4354
  else if (this.dragging) {
4361
- this.dragDragableList();
4355
+ this.realDrag();
4362
4356
  interaction.emit(exports.DragEvent.BEFORE_DRAG, this.dragData);
4363
4357
  interaction.emit(exports.DragEvent.DRAG, this.dragData);
4364
4358
  }
@@ -4369,9 +4363,6 @@ var LeaferUI = (function (exports) {
4369
4363
  if (this.dragging) {
4370
4364
  this.interaction.emit(exports.DragEvent.START, this.dragData);
4371
4365
  this.getDragableList(this.dragData.path);
4372
- this.dragList = filterPathByEventType(this.dragData.path, exports.DragEvent.DRAG);
4373
- if (!this.dragList.length && this.dragableList)
4374
- this.dragList.pushList(this.dragableList);
4375
4366
  }
4376
4367
  }
4377
4368
  }
@@ -4380,16 +4371,17 @@ var LeaferUI = (function (exports) {
4380
4371
  for (let i = 0, len = path.length; i < len; i++) {
4381
4372
  leaf = path.list[i];
4382
4373
  if (leaf.__.draggable && leaf.__.hitSelf) {
4383
- this.dragableList = [leaf];
4374
+ this.dragableList = new LeafList(leaf);
4384
4375
  break;
4385
4376
  }
4386
4377
  }
4387
4378
  }
4388
- dragDragableList() {
4379
+ realDrag() {
4389
4380
  const { running } = this.interaction;
4390
- if (this.dragableList && running) {
4381
+ const list = this.getList();
4382
+ if (list.length && running) {
4391
4383
  const { moveX, moveY } = this.dragData;
4392
- this.dragableList.forEach(leaf => {
4384
+ list.forEach(leaf => {
4393
4385
  LeafHelper.moveWorld(leaf, moveX, moveY);
4394
4386
  });
4395
4387
  }
@@ -4446,20 +4438,14 @@ var LeaferUI = (function (exports) {
4446
4438
  }
4447
4439
  }
4448
4440
  drop(data) {
4449
- const dropData = getDropEventData(data, this.getDragList(), exports.DropEvent.dragData);
4441
+ const dropData = getDropEventData(data, this.getList(), exports.DragEvent.data);
4450
4442
  dropData.path = this.dragEnterPath;
4451
4443
  this.interaction.emit(exports.DropEvent.DROP, dropData);
4452
4444
  this.interaction.emit(exports.DragEvent.LEAVE, data, this.dragEnterPath);
4453
4445
  }
4454
4446
  dragReset() {
4455
- exports.DropEvent.dragList = null;
4456
- this.dragList = null;
4457
- this.dragableList = null;
4458
- this.dragData = null;
4459
- this.dragOverPath = null;
4460
- this.dragEnterPath = null;
4461
- this.dragging = null;
4462
- this.moving = null;
4447
+ exports.DragEvent.list = exports.DragEvent.data = this.dragableList = this.dragData = this.dragOverPath = this.dragEnterPath = null;
4448
+ this.dragging = this.moving = false;
4463
4449
  }
4464
4450
  checkDragOut(data) {
4465
4451
  const { interaction } = this;
@@ -4695,6 +4681,10 @@ var LeaferUI = (function (exports) {
4695
4681
  this.zoom(getZoomEventData$1(center, scale, data));
4696
4682
  this.move(getMoveEventData$1(center, move, data));
4697
4683
  }
4684
+ menu(data) {
4685
+ this.findPath(data);
4686
+ this.emit(exports.PointerEvent.MENU, data);
4687
+ }
4698
4688
  move(data) {
4699
4689
  this.transformer.move(data);
4700
4690
  }
@@ -4804,6 +4794,9 @@ var LeaferUI = (function (exports) {
4804
4794
  data.path = find.path;
4805
4795
  return find.path;
4806
4796
  }
4797
+ isDrag(leaf) {
4798
+ return this.dragger.getList().has(leaf);
4799
+ }
4807
4800
  updateDownData(data) {
4808
4801
  if (!data)
4809
4802
  data = this.downData;
@@ -4817,7 +4810,7 @@ var LeaferUI = (function (exports) {
4817
4810
  data = this.hoverData;
4818
4811
  if (!data)
4819
4812
  return;
4820
- this.findPath(data, { exclude: this.dragger.getDragList(), name: exports.PointerEvent.MOVE });
4813
+ this.findPath(data, { exclude: this.dragger.getList(), name: exports.PointerEvent.MOVE });
4821
4814
  this.hoverData = data;
4822
4815
  }
4823
4816
  updateCursor(data) {
@@ -4937,7 +4930,7 @@ var LeaferUI = (function (exports) {
4937
4930
  this.renderBounds = this.strokeBounds = this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
4938
4931
  this.localRenderBounds = this.localStrokeBounds = leaf.__local;
4939
4932
  this.boxChange();
4940
- this.positionChange();
4933
+ this.matrixChange();
4941
4934
  }
4942
4935
  checkUpdate(force) {
4943
4936
  const { leafer } = this.leaf;
@@ -5064,11 +5057,6 @@ var LeaferUI = (function (exports) {
5064
5057
  this.renderSpread || (this.renderSpread = 1);
5065
5058
  this.boundsChanged = true;
5066
5059
  }
5067
- positionChange() {
5068
- this.positionChanged = true;
5069
- this.matrixChanged = true;
5070
- this.localBoxChanged || this.localBoxChange();
5071
- }
5072
5060
  scaleChange() {
5073
5061
  this.scaleChanged = true;
5074
5062
  this._scaleOrRotationChange();
@@ -5080,6 +5068,9 @@ var LeaferUI = (function (exports) {
5080
5068
  }
5081
5069
  _scaleOrRotationChange() {
5082
5070
  this.affectScaleOrRotation = true;
5071
+ this.matrixChange();
5072
+ }
5073
+ matrixChange() {
5083
5074
  this.matrixChanged = true;
5084
5075
  this.localBoxChanged || this.localBoxChange();
5085
5076
  }
@@ -5222,10 +5213,11 @@ var LeaferUI = (function (exports) {
5222
5213
  const LeafDataProxy = {
5223
5214
  __setAttr(name, newValue) {
5224
5215
  if (this.leafer && this.leafer.created) {
5225
- if (typeof newValue === 'object' || this.__.__getInput(name) !== newValue) {
5216
+ const oldValue = this.__.__getInput(name);
5217
+ if (typeof newValue === 'object' || oldValue !== newValue) {
5226
5218
  this.__[name] = newValue;
5227
5219
  const { CHANGE } = PropertyEvent;
5228
- const event = new PropertyEvent(CHANGE, this, name, this.__.__get(name), newValue);
5220
+ const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
5229
5221
  if (this.hasEvent(CHANGE) && !this.isLeafer)
5230
5222
  this.emitEvent(event);
5231
5223
  this.leafer.emitEvent(event);
@@ -5316,17 +5308,17 @@ var LeaferUI = (function (exports) {
5316
5308
  }
5317
5309
  }
5318
5310
  }
5319
- if (layout.positionChanged) {
5320
- r.e = this.__.x;
5321
- r.f = this.__.y;
5322
- const { width, height, around } = this.__;
5323
- if (around && width && height) {
5311
+ const { x, y, around } = this.__;
5312
+ r.e = x;
5313
+ r.f = y;
5314
+ if (around) {
5315
+ const { width, height } = this.__;
5316
+ if (width && height) {
5324
5317
  const origin = (around === 'center') ? defaultCenter : around;
5325
5318
  const offsetX = width * origin.x, offsetY = height * origin.y;
5326
5319
  r.e -= offsetX * r.a + offsetY * r.c;
5327
5320
  r.f -= offsetX * r.b + offsetY * r.d;
5328
5321
  }
5329
- layout.positionChanged = false;
5330
5322
  }
5331
5323
  this.__layout.matrixChanged = false;
5332
5324
  }
@@ -5421,7 +5413,7 @@ var LeaferUI = (function (exports) {
5421
5413
  data.__naturalWidth = layout.boxBounds.width;
5422
5414
  data.__naturalHeight = layout.boxBounds.height;
5423
5415
  if (this.around) {
5424
- layout.positionChanged = layout.matrixChanged = true;
5416
+ layout.matrixChanged = true;
5425
5417
  this.__updateWorldMatrix();
5426
5418
  }
5427
5419
  },
@@ -5609,11 +5601,16 @@ var LeaferUI = (function (exports) {
5609
5601
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5610
5602
  constructor(data) {
5611
5603
  this.innerId = create(LEAF);
5604
+ this.reset(data);
5605
+ }
5606
+ reset(data) {
5612
5607
  this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 };
5613
5608
  this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
5614
5609
  this.__worldOpacity = 1;
5615
5610
  this.__ = new this.__DataProcessor(this);
5616
5611
  this.__layout = new this.__LayoutProcessor(this);
5612
+ if (this.__level)
5613
+ this.resetCustom();
5617
5614
  if (data) {
5618
5615
  if (data.children) {
5619
5616
  this.set(data);
@@ -5623,6 +5620,10 @@ var LeaferUI = (function (exports) {
5623
5620
  }
5624
5621
  }
5625
5622
  }
5623
+ resetCustom() {
5624
+ this.__hasMask = this.__hasEraser = null;
5625
+ this.forceUpdate();
5626
+ }
5626
5627
  waitParent(item) {
5627
5628
  this.parent ? item() : (this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item]);
5628
5629
  }
@@ -5637,8 +5638,11 @@ var LeaferUI = (function (exports) {
5637
5638
  if (leafer !== null)
5638
5639
  leafer = this;
5639
5640
  }
5641
+ if (this.leafer && !leafer)
5642
+ this.leafer.leafs--;
5640
5643
  this.leafer = leafer;
5641
5644
  if (leafer) {
5645
+ leafer.leafs++;
5642
5646
  this.__level = this.parent ? this.parent.__level + 1 : 1;
5643
5647
  if (this.__leaferWait)
5644
5648
  WaitHelper.run(this.__leaferWait);
@@ -5661,7 +5665,7 @@ var LeaferUI = (function (exports) {
5661
5665
  __getAttr(_attrName) { return undefined; }
5662
5666
  forceUpdate(attrName) {
5663
5667
  if (attrName === undefined)
5664
- attrName = 'scaleX';
5668
+ attrName = 'width';
5665
5669
  else if (attrName === 'surface')
5666
5670
  attrName = 'blendMode';
5667
5671
  const value = this.__.__getInput(attrName);
@@ -5868,7 +5872,7 @@ var LeaferUI = (function (exports) {
5868
5872
  index === undefined ? this.children.push(child) : this.children.splice(index, 0, child);
5869
5873
  if (child.isBranch)
5870
5874
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5871
- child.__layout.boundsChanged || child.__layout.positionChange();
5875
+ child.__layout.boundsChanged || child.__layout.matrixChange();
5872
5876
  if (child.__parentWait)
5873
5877
  WaitHelper.run(child.__parentWait);
5874
5878
  if (this.leafer) {
@@ -6087,7 +6091,7 @@ var LeaferUI = (function (exports) {
6087
6091
  let layout;
6088
6092
  updateList.list.forEach(leaf => {
6089
6093
  layout = leaf.__layout;
6090
- if (levelList.without(leaf) && !layout.useZoomProxy) {
6094
+ if (levelList.without(leaf) && !layout.proxyZoom) {
6091
6095
  if (layout.matrixChanged) {
6092
6096
  updateAllWorldMatrix$1(leaf);
6093
6097
  levelList.push(leaf);
@@ -6406,8 +6410,7 @@ var LeaferUI = (function (exports) {
6406
6410
  const { canvas, updateBlocks: list } = this;
6407
6411
  if (!list)
6408
6412
  return debug$4.warn('PartRender: need update attr');
6409
- if (list.some(block => block.includes(this.target.__world)))
6410
- this.mergeBlocks();
6413
+ this.mergeBlocks();
6411
6414
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6412
6415
  this.clipRender(block); });
6413
6416
  }
@@ -6426,7 +6429,7 @@ var LeaferUI = (function (exports) {
6426
6429
  canvas.clearWorld(bounds, true);
6427
6430
  canvas.clipWorld(bounds, true);
6428
6431
  }
6429
- this.__render(bounds, realBounds);
6432
+ this.__render(bounds, includes, realBounds);
6430
6433
  canvas.restore();
6431
6434
  Run.end(t);
6432
6435
  }
@@ -6435,12 +6438,12 @@ var LeaferUI = (function (exports) {
6435
6438
  const { canvas } = this;
6436
6439
  canvas.save();
6437
6440
  canvas.clear();
6438
- this.__render(canvas.bounds);
6441
+ this.__render(canvas.bounds, true);
6439
6442
  canvas.restore();
6440
6443
  Run.end(t);
6441
6444
  }
6442
- __render(bounds, realBounds) {
6443
- const options = (bounds === null || bounds === void 0 ? void 0 : bounds.includes(this.target.__world)) ? {} : { bounds };
6445
+ __render(bounds, includes, realBounds) {
6446
+ const options = bounds.includes(this.target.__world) ? { includes } : { bounds, includes };
6444
6447
  if (this.needFill)
6445
6448
  this.canvas.fillWorld(bounds, this.config.fill);
6446
6449
  if (Debug.showRepaint)
@@ -7044,6 +7047,7 @@ var LeaferUI = (function (exports) {
7044
7047
  'pointerdown': this.onPointerDown,
7045
7048
  'mousedown': this.onMouseDown,
7046
7049
  'touchstart': this.onTouchStart,
7050
+ 'contextmenu': this.onContextMenu,
7047
7051
  'wheel': this.onWheel,
7048
7052
  'gesturestart': this.onGesturestart,
7049
7053
  'gesturechange': this.onGesturechange,
@@ -7116,6 +7120,9 @@ var LeaferUI = (function (exports) {
7116
7120
  onKeyUp(e) {
7117
7121
  this.keyUp(KeyEventHelper.convert(e));
7118
7122
  }
7123
+ onContextMenu(e) {
7124
+ this.menu(PointerEventHelper.convert(e, this.getLocal(e)));
7125
+ }
7119
7126
  onScroll() {
7120
7127
  this.canvas.updateClientBounds();
7121
7128
  }
@@ -7320,6 +7327,11 @@ var LeaferUI = (function (exports) {
7320
7327
  });
7321
7328
  }
7322
7329
  };
7330
+ Platform.event = {
7331
+ stopDefault(origin) { origin.preventDefault(); },
7332
+ stopNow(origin) { origin.stopImmediatePropagation(); },
7333
+ stop(origin) { origin.stopPropagation(); }
7334
+ };
7323
7335
  Platform.canvas = Creator.canvas();
7324
7336
  Platform.conicGradientSupport = !!Platform.canvas.context.createConicGradient;
7325
7337
  }
@@ -7356,7 +7368,7 @@ var LeaferUI = (function (exports) {
7356
7368
  function design(leafer) {
7357
7369
  if (leafer.isApp)
7358
7370
  return;
7359
- leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => { LeafHelper.moveWorld(leafer.moveLayer, e.moveX, e.moveY); }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
7371
+ leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => { LeafHelper.moveWorld(leafer.zoomLayer, e.moveX, e.moveY); }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
7360
7372
  const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.config.zoom;
7361
7373
  let { scale } = e;
7362
7374
  if (scale * Math.abs(scaleX) < min)
@@ -7437,6 +7449,8 @@ var LeaferUI = (function (exports) {
7437
7449
  this.__removeInput('fill');
7438
7450
  Paint.recycleImage('fill', this);
7439
7451
  this.__isFills = false;
7452
+ if (this.__pixelFill)
7453
+ this.__pixelFill = false;
7440
7454
  }
7441
7455
  this._fill = value;
7442
7456
  }
@@ -7453,6 +7467,8 @@ var LeaferUI = (function (exports) {
7453
7467
  this.__removeInput('stroke');
7454
7468
  Paint.recycleImage('stroke', this);
7455
7469
  this.__isStrokes = false;
7470
+ if (this.__pixelStroke)
7471
+ this.__pixelStroke = false;
7456
7472
  }
7457
7473
  this._stroke = value;
7458
7474
  }
@@ -7750,9 +7766,9 @@ var LeaferUI = (function (exports) {
7750
7766
  const { fill, stroke } = this.__;
7751
7767
  this.__drawRenderPath(canvas);
7752
7768
  if (fill)
7753
- Paint.fill('#000000', this, canvas);
7769
+ this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7754
7770
  if (stroke)
7755
- Paint.stroke('#000000', this, canvas, renderOptions);
7771
+ this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas, renderOptions) : Paint.stroke('#000000', this, canvas, renderOptions);
7756
7772
  }
7757
7773
  };
7758
7774
 
@@ -7799,9 +7815,7 @@ var LeaferUI = (function (exports) {
7799
7815
  const { scaleX, scaleY } = this;
7800
7816
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
7801
7817
  }
7802
- constructor(data) {
7803
- super(data);
7804
- }
7818
+ reset(_data) { }
7805
7819
  set(data) {
7806
7820
  Object.assign(this, data);
7807
7821
  }
@@ -7990,6 +8004,9 @@ var LeaferUI = (function (exports) {
7990
8004
  __decorate([
7991
8005
  effectType()
7992
8006
  ], exports.UI.prototype, "grayscale", void 0);
8007
+ __decorate([
8008
+ rewrite(exports.Leaf.prototype.reset)
8009
+ ], exports.UI.prototype, "reset", null);
7993
8010
  __decorate([
7994
8011
  rewrite(PathDrawer.drawPathByData)
7995
8012
  ], exports.UI.prototype, "__drawPathByData", null);
@@ -8027,8 +8044,12 @@ var LeaferUI = (function (exports) {
8027
8044
  if (data.children) {
8028
8045
  const { children } = data;
8029
8046
  delete data.children;
8030
- if (!this.children)
8047
+ if (!this.children) {
8031
8048
  this.__setBranch();
8049
+ }
8050
+ else {
8051
+ this.removeAll(true);
8052
+ }
8032
8053
  super.set(data);
8033
8054
  let child;
8034
8055
  children.forEach(childData => {
@@ -8229,8 +8250,10 @@ var LeaferUI = (function (exports) {
8229
8250
  ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
8230
8251
  moveTo$3(path, width, ry);
8231
8252
  }
8232
- ellipse(path, rx, ry, rx, ry, 0, 0, 360, true);
8253
+ ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
8233
8254
  }
8255
+ if (Platform.name === 'node')
8256
+ this.__.path = PathConvert.toCanvasData(path, true);
8234
8257
  }
8235
8258
  else {
8236
8259
  if (startAngle || endAngle) {
@@ -8751,10 +8774,10 @@ var LeaferUI = (function (exports) {
8751
8774
  get __tag() { return 'Leafer'; }
8752
8775
  get isApp() { return false; }
8753
8776
  get app() { return this.parent || this; }
8777
+ get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
8754
8778
  constructor(userConfig, data) {
8755
8779
  super(data);
8756
8780
  this.zoomLayer = this;
8757
- this.moveLayer = this;
8758
8781
  this.config = {
8759
8782
  type: 'design',
8760
8783
  start: true,
@@ -8770,6 +8793,7 @@ var LeaferUI = (function (exports) {
8770
8793
  autoDistance: 2
8771
8794
  }
8772
8795
  };
8796
+ this.leafs = 0;
8773
8797
  this.__eventIds = [];
8774
8798
  this.__controllers = [];
8775
8799
  this.__readyWait = [];
@@ -8883,9 +8907,8 @@ var LeaferUI = (function (exports) {
8883
8907
  this.isLeafer = !!leafer;
8884
8908
  this.__level = 1;
8885
8909
  }
8886
- setZoomLayer(zoomLayer, moveLayer) {
8910
+ setZoomLayer(zoomLayer) {
8887
8911
  this.zoomLayer = zoomLayer;
8888
- this.moveLayer = moveLayer || zoomLayer;
8889
8912
  }
8890
8913
  __checkAutoLayout(config) {
8891
8914
  if (!config.width || !config.height) {
@@ -9393,10 +9416,13 @@ var LeaferUI = (function (exports) {
9393
9416
  createPattern(ui, paint, canvas.pixelRatio);
9394
9417
  }
9395
9418
  else {
9396
- ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
9397
- if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
9398
- ui.forceUpdate('surface');
9399
- }), 300);
9419
+ if (!paint.patternTask) {
9420
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
9421
+ paint.patternTask = null;
9422
+ if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
9423
+ ui.forceUpdate('surface');
9424
+ }), 300);
9425
+ }
9400
9426
  }
9401
9427
  return false;
9402
9428
  }
@@ -9760,17 +9786,30 @@ var LeaferUI = (function (exports) {
9760
9786
  let recycleMap;
9761
9787
  function compute(attrName, ui) {
9762
9788
  const value = [];
9789
+ const data = ui.__;
9763
9790
  let item;
9764
- let paints = ui.__.__input[attrName];
9791
+ let paints = data.__input[attrName];
9765
9792
  if (!(paints instanceof Array))
9766
9793
  paints = [paints];
9767
- recycleMap = recycleImage(attrName, ui.__);
9794
+ recycleMap = recycleImage(attrName, data);
9768
9795
  for (let i = 0, len = paints.length; i < len; i++) {
9769
9796
  item = getLeafPaint(attrName, paints[i], ui);
9770
9797
  if (item)
9771
9798
  value.push(item);
9772
9799
  }
9773
- ui.__['_' + attrName] = value.length ? value : undefined;
9800
+ data['_' + attrName] = value.length ? value : undefined;
9801
+ let isPixel;
9802
+ if (paints.length === 1) {
9803
+ const paint = paints[0];
9804
+ if (paint.type === 'image')
9805
+ isPixel = ImageManager.isPixel(paint);
9806
+ }
9807
+ if (attrName === 'fill') {
9808
+ data.__pixelFill = isPixel;
9809
+ }
9810
+ else {
9811
+ data.__pixelStroke = isPixel;
9812
+ }
9774
9813
  }
9775
9814
  function getLeafPaint(attrName, paint, ui) {
9776
9815
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
@@ -10511,7 +10550,6 @@ var LeaferUI = (function (exports) {
10511
10550
  exports.TaskItem = TaskItem;
10512
10551
  exports.TaskProcessor = TaskProcessor;
10513
10552
  exports.TextConvert = TextConvert$1;
10514
- exports.TransformEvent = TransformEvent;
10515
10553
  exports.TwoPointBounds = TwoPointBounds;
10516
10554
  exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
10517
10555
  exports.UIBounds = UIBounds;