leafer-ui 2.1.4 → 2.1.6

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
@@ -240,7 +240,7 @@ var LeaferUI = function(exports) {
240
240
  RUNTIME: "runtime",
241
241
  LEAF: "leaf",
242
242
  TASK: "task",
243
- CNAVAS: "canvas",
243
+ CANVAS: "canvas",
244
244
  IMAGE: "image",
245
245
  types: {},
246
246
  create(typeName) {
@@ -869,7 +869,7 @@ var LeaferUI = function(exports) {
869
869
  return quick ? t.x === point.x && t.y === point.y : float$2(t.x) === float$2(point.x) && float$2(t.y) === float$2(point.y);
870
870
  },
871
871
  reset(t) {
872
- P$5.reset(t);
872
+ t.x = t.y = 0;
873
873
  }
874
874
  };
875
875
  const P$5 = PointHelper;
@@ -1073,6 +1073,7 @@ var LeaferUI = function(exports) {
1073
1073
  }
1074
1074
  reset() {
1075
1075
  MatrixHelper.reset(this);
1076
+ return this;
1076
1077
  }
1077
1078
  }
1078
1079
  const tempMatrix$2 = new Matrix;
@@ -2177,7 +2178,7 @@ var LeaferUI = function(exports) {
2177
2178
  this.worldTransform = {};
2178
2179
  if (!config) config = minSize;
2179
2180
  this.manager = manager;
2180
- this.innerId = IncrementId.create(IncrementId.CNAVAS);
2181
+ this.innerId = IncrementId.create(IncrementId.CANVAS);
2181
2182
  const {width: width, height: height, pixelRatio: pixelRatio} = config;
2182
2183
  this.autoLayout = !width || !height;
2183
2184
  this.size.pixelRatio = pixelRatio || Platform.devicePixelRatio;
@@ -2327,6 +2328,7 @@ var LeaferUI = function(exports) {
2327
2328
  }
2328
2329
  useGrayscaleAlpha(bounds) {
2329
2330
  this.setTempPixelBounds(bounds, true, true);
2331
+ if (!tempPixelBounds.width || !tempPixelBounds.height) return;
2330
2332
  let alpha, pixel;
2331
2333
  const {context: context} = this, imageData = context.getImageData(tempPixelBounds.x, tempPixelBounds.y, tempPixelBounds.width, tempPixelBounds.height), {data: data} = imageData;
2332
2334
  for (let i = 0, len = data.length; i < len; i += 4) {
@@ -3497,7 +3499,7 @@ var LeaferUI = function(exports) {
3497
3499
  const {arcTo: arcTo} = PathCommandDataHelper;
3498
3500
  const PathCorner = {
3499
3501
  smooth(data, cornerRadius, _cornerSmoothing) {
3500
- let command, lastCommand, commandLen;
3502
+ let command, lastCommand, commandLen, startXIndex, startYIndex, smoothLen;
3501
3503
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3502
3504
  if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
3503
3505
  const len = data.length, three = len === 9;
@@ -3506,6 +3508,11 @@ var LeaferUI = function(exports) {
3506
3508
  command = data[i];
3507
3509
  switch (command) {
3508
3510
  case M:
3511
+ smoothLen = smooth.length;
3512
+ if (smoothLen && lastCommand !== Z) {
3513
+ smooth[startXIndex] = startX;
3514
+ smooth[startYIndex] = startY;
3515
+ }
3509
3516
  startX = lastX = data[i + 1];
3510
3517
  startY = lastY = data[i + 2];
3511
3518
  i += 3;
@@ -3516,6 +3523,8 @@ var LeaferUI = function(exports) {
3516
3523
  } else {
3517
3524
  smooth.push(M, startX, startY);
3518
3525
  }
3526
+ startXIndex = smoothLen + 1;
3527
+ startYIndex = smoothLen + 2;
3519
3528
  break;
3520
3529
 
3521
3530
  case L$1:
@@ -3554,8 +3563,8 @@ var LeaferUI = function(exports) {
3554
3563
  lastCommand = command;
3555
3564
  }
3556
3565
  if (command !== Z) {
3557
- smooth[1] = startX;
3558
- smooth[2] = startY;
3566
+ smooth[startXIndex] = startX;
3567
+ smooth[startYIndex] = startY;
3559
3568
  }
3560
3569
  return smooth;
3561
3570
  }
@@ -5207,6 +5216,7 @@ var LeaferUI = function(exports) {
5207
5216
  this.renderChanged = true;
5208
5217
  this.renderSpread || (this.renderSpread = 1);
5209
5218
  this.boundsChanged = true;
5219
+ this.hitCanvasChanged = true;
5210
5220
  }
5211
5221
  scaleChange() {
5212
5222
  this.scaleChanged = true;
@@ -6053,10 +6063,6 @@ var LeaferUI = function(exports) {
6053
6063
  }
6054
6064
  }
6055
6065
  }
6056
- set(_data, _isTemp) {}
6057
- get(_name) {
6058
- return undefined;
6059
- }
6060
6066
  setAttr(name, value) {
6061
6067
  this[name] = value;
6062
6068
  }
@@ -6073,37 +6079,10 @@ var LeaferUI = function(exports) {
6073
6079
  toString(options) {
6074
6080
  return JSON.stringify(this.toJSON(options));
6075
6081
  }
6076
- toSVG() {
6077
- return undefined;
6078
- }
6079
- __SVG(_data) {}
6080
- toHTML() {
6081
- return undefined;
6082
- }
6083
- __setAttr(_attrName, _newValue) {
6084
- return true;
6085
- }
6086
- __getAttr(_attrName) {
6087
- return undefined;
6088
- }
6089
- setProxyAttr(_attrName, _newValue) {}
6090
- getProxyAttr(_attrName) {
6091
- return undefined;
6092
- }
6093
- find(_condition, _options) {
6094
- return undefined;
6095
- }
6096
- findTag(_tag) {
6097
- return undefined;
6098
- }
6099
- findOne(_condition, _options) {
6100
- return undefined;
6101
- }
6102
- findId(_id) {
6103
- return undefined;
6082
+ scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6083
+ this.scaleX *= scaleX;
6084
+ this.scaleY *= scaleY;
6104
6085
  }
6105
- focus(_value) {}
6106
- updateState() {}
6107
6086
  updateLayout() {
6108
6087
  this.__layout.update();
6109
6088
  }
@@ -6119,27 +6098,6 @@ var LeaferUI = function(exports) {
6119
6098
  __extraUpdate() {
6120
6099
  if (this.leaferIsReady) this.leafer.layouter.addExtra(this);
6121
6100
  }
6122
- __updateWorldMatrix() {}
6123
- __updateLocalMatrix() {}
6124
- __updateWorldBounds() {}
6125
- __updateLocalBounds() {}
6126
- __updateLocalBoxBounds() {}
6127
- __updateLocalStrokeBounds() {}
6128
- __updateLocalRenderBounds() {}
6129
- __updateBoxBounds(_secondLayout, _bounds) {}
6130
- __updateContentBounds() {}
6131
- __updateStrokeBounds(_bounds) {}
6132
- __updateRenderBounds(_bounds) {}
6133
- __updateAutoLayout() {}
6134
- __updateFlowLayout() {}
6135
- __updateNaturalSize() {}
6136
- __updateStrokeSpread() {
6137
- return 0;
6138
- }
6139
- __updateRenderSpread() {
6140
- return 0;
6141
- }
6142
- __onUpdateSize() {}
6143
6101
  __updateEraser(value) {
6144
6102
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
6145
6103
  }
@@ -6153,7 +6111,6 @@ var LeaferUI = function(exports) {
6153
6111
  __updateMask(_value) {
6154
6112
  this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6155
6113
  }
6156
- __renderMask(_canvas, _options) {}
6157
6114
  __getNowWorld(options) {
6158
6115
  if (options.matrix) {
6159
6116
  if (!this.__cameraWorld) this.__cameraWorld = {};
@@ -6309,76 +6266,12 @@ var LeaferUI = function(exports) {
6309
6266
  flip(axis, transition) {
6310
6267
  transform(this, getFlipTransform(this, axis), false, transition);
6311
6268
  }
6312
- scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6313
- this.scaleX *= scaleX;
6314
- this.scaleY *= scaleY;
6315
- }
6316
- __scaleResize(_scaleX, _scaleY) {}
6317
- resizeWidth(_width) {}
6318
- resizeHeight(_height) {}
6319
- hit(_world, _hitRadius) {
6320
- return true;
6321
- }
6322
- __hitWorld(_point, _forceHitFill) {
6323
- return true;
6324
- }
6325
- __hit(_local, _forceHitFill) {
6326
- return true;
6327
- }
6328
- __hitFill(_inner) {
6329
- return true;
6330
- }
6331
- __hitStroke(_inner, _strokeWidth) {
6332
- return true;
6333
- }
6334
- __hitPixel(_inner) {
6335
- return true;
6336
- }
6337
- __drawHitPath(_canvas) {}
6338
- __updateHitCanvas() {}
6339
- __render(_canvas, _options) {}
6340
- __drawFast(_canvas, _options) {}
6341
- __draw(_canvas, _options, _originCanvas) {}
6342
- __clip(_canvas, _options) {}
6343
- __renderShape(_canvas, _options) {}
6344
- __drawShape(_canvas, _options) {}
6345
- __updateWorldOpacity() {}
6346
- __updateChange() {}
6347
- __drawPath(_canvas) {}
6348
- __drawRenderPath(_canvas) {}
6349
- __updatePath() {}
6350
- __updateRenderPath(_updateCache) {}
6351
- getMotionPathData() {
6352
- return Plugin.need("path");
6353
- }
6354
- getMotionPoint(_motionDistance) {
6355
- return Plugin.need("path");
6356
- }
6357
- getMotionTotal() {
6358
- return 0;
6359
- }
6360
- __updateMotionPath() {}
6361
- __runAnimation(_type, _complete) {}
6362
- __updateSortChildren() {}
6363
- add(_child, _index) {}
6364
6269
  remove(_child, destroy) {
6365
6270
  if (this.parent) this.parent.remove(this, destroy);
6366
6271
  }
6367
6272
  dropTo(parent, index, resize) {
6368
6273
  drop(this, parent, index, resize);
6369
6274
  }
6370
- on(_type, _listener, _options) {}
6371
- off(_type, _listener, _options) {}
6372
- on_(_type, _listener, _bind, _options) {
6373
- return undefined;
6374
- }
6375
- off_(_id) {}
6376
- once(_type, _listener, _captureOrBind, _capture) {}
6377
- emit(_type, _event, _capture) {}
6378
- emitEvent(_event, _capture) {}
6379
- hasEvent(_type, _capture) {
6380
- return false;
6381
- }
6382
6275
  static changeAttr(attrName, defaultValue, fn) {
6383
6276
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
6384
6277
  }
@@ -6674,7 +6567,7 @@ var LeaferUI = function(exports) {
6674
6567
  this.levelMap = null;
6675
6568
  }
6676
6569
  }
6677
- const version = "2.1.4";
6570
+ const version = "2.1.6";
6678
6571
  const debug$5 = Debug.get("LeaferCanvas");
6679
6572
  class LeaferCanvas extends LeaferCanvasBase {
6680
6573
  set zIndex(zIndex) {
@@ -8274,17 +8167,12 @@ var LeaferUI = function(exports) {
8274
8167
  if (!path) this.__drawPathByBox(pen);
8275
8168
  return pen;
8276
8169
  }
8277
- reset(_data) {}
8278
8170
  set(data, _transition) {
8279
8171
  if (data) Object.assign(this, data);
8280
8172
  }
8281
8173
  get(name) {
8282
8174
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
8283
8175
  }
8284
- createProxyData() {
8285
- return undefined;
8286
- }
8287
- clearProxyData() {}
8288
8176
  find(_condition, _options) {
8289
8177
  return Plugin.need("find");
8290
8178
  }
@@ -8322,6 +8210,7 @@ var LeaferUI = function(exports) {
8322
8210
  data.lazy && !this.__inLazyBounds && !Export.running ? data.__needComputePaint = true : data.__computePaint();
8323
8211
  }
8324
8212
  }
8213
+ __updatePath() {}
8325
8214
  __updateRenderPath(updateCache) {
8326
8215
  const data = this.__;
8327
8216
  if (data.path) {
@@ -8357,7 +8246,6 @@ var LeaferUI = function(exports) {
8357
8246
  this.set(keyframe);
8358
8247
  return Plugin.need("animate");
8359
8248
  }
8360
- killAnimate(_type, _nextStyle) {}
8361
8249
  export(_filename, _options) {
8362
8250
  return Plugin.need("export");
8363
8251
  }
@@ -8460,7 +8348,6 @@ var LeaferUI = function(exports) {
8460
8348
  __decorate([ surfaceType() ], exports.UI.prototype, "placeholderColor", void 0);
8461
8349
  __decorate([ dataType(100) ], exports.UI.prototype, "placeholderDelay", void 0);
8462
8350
  __decorate([ dataType({}) ], exports.UI.prototype, "data", void 0);
8463
- __decorate([ rewrite(exports.Leaf.prototype.reset) ], exports.UI.prototype, "reset", null);
8464
8351
  exports.UI = UI_1 = __decorate([ useModule(UIBounds), useModule(UIRender), rewriteAble() ], exports.UI);
8465
8352
  exports.Group = class Group extends exports.UI {
8466
8353
  get __tag() {
@@ -8496,9 +8383,6 @@ var LeaferUI = function(exports) {
8496
8383
  }
8497
8384
  return data;
8498
8385
  }
8499
- pick(_hitPoint, _options) {
8500
- return undefined;
8501
- }
8502
8386
  addAt(child, index) {
8503
8387
  this.add(child, index);
8504
8388
  }
@@ -8508,11 +8392,6 @@ var LeaferUI = function(exports) {
8508
8392
  addBefore(child, before) {
8509
8393
  this.add(child, this.children.indexOf(before));
8510
8394
  }
8511
- add(_child, _index) {}
8512
- addMany(..._children) {}
8513
- remove(_child, _destroy) {}
8514
- removeAll(_destroy) {}
8515
- clear() {}
8516
8395
  };
8517
8396
  __decorate([ dataProcessor(GroupData) ], exports.Group.prototype, "__", void 0);
8518
8397
  __decorate([ boundsType(0) ], exports.Group.prototype, "width", void 0);
@@ -9366,51 +9245,6 @@ var LeaferUI = function(exports) {
9366
9245
  this.add(path);
9367
9246
  return this;
9368
9247
  }
9369
- beginPath() {
9370
- return this;
9371
- }
9372
- moveTo(_x, _y) {
9373
- return this;
9374
- }
9375
- lineTo(_x, _y) {
9376
- return this;
9377
- }
9378
- bezierCurveTo(_x1, _y1, _x2, _y2, _x, _y) {
9379
- return this;
9380
- }
9381
- quadraticCurveTo(_x1, _y1, _x, _y) {
9382
- return this;
9383
- }
9384
- closePath() {
9385
- return this;
9386
- }
9387
- rect(_x, _y, _width, _height) {
9388
- return this;
9389
- }
9390
- roundRect(_x, _y, _width, _height, _cornerRadius) {
9391
- return this;
9392
- }
9393
- ellipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) {
9394
- return this;
9395
- }
9396
- arc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) {
9397
- return this;
9398
- }
9399
- arcTo(_x1, _y1, _x2, _y2, _radius) {
9400
- return this;
9401
- }
9402
- drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) {
9403
- return this;
9404
- }
9405
- drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) {
9406
- return this;
9407
- }
9408
- drawPoints(_points, _curve, _close) {
9409
- return this;
9410
- }
9411
- clearPath() {
9412
- return this;
9413
- }
9414
9248
  paint() {
9415
9249
  const {pathElement: pathElement} = this;
9416
9250
  if (!pathElement.__layout.boxChanged) pathElement.forceUpdate("path");
@@ -11565,7 +11399,7 @@ var LeaferUI = function(exports) {
11565
11399
  needUpdate = false;
11566
11400
  }
11567
11401
  }
11568
- if (paint.mode === "brush") PaintImage.brush(leafPaint, ui);
11402
+ if (paint.mode === "brush") PaintImage.brush(leafPaint, ui, attrName);
11569
11403
  if (!leafPaint.data) {
11570
11404
  PaintImage.createData(leafPaint, image, paint, boxBounds);
11571
11405
  const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
@@ -11649,8 +11483,9 @@ var LeaferUI = function(exports) {
11649
11483
  break;
11650
11484
 
11651
11485
  case "repeat":
11652
- case "brush":
11653
11486
  if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
11487
+
11488
+ case "brush":
11654
11489
  if (!repeat) data.repeat = "repeat";
11655
11490
  const count = isObject(repeat);
11656
11491
  if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
@@ -11661,7 +11496,7 @@ var LeaferUI = function(exports) {
11661
11496
  default:
11662
11497
  if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11663
11498
  }
11664
- if (!data.transform) {
11499
+ if (!data.transform && mode !== "brush") {
11665
11500
  if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
11666
11501
  }
11667
11502
  if (scaleX) {
@@ -11777,8 +11612,9 @@ var LeaferUI = function(exports) {
11777
11612
  let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
11778
11613
  if (paint.patternId !== id && !ui.destroyed) {
11779
11614
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
11780
- const {image: image, brush: brush, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11781
- let imageMatrix, xGap, yGap, {width: width, height: height} = image;
11615
+ const {image: image, brush: brush, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11616
+ let imageMatrix, xGap, yGap, {width: width, height: height} = image, {opacity: opacity} = paint.originPaint;
11617
+ if (brush || opacity === 1) opacity = undefined;
11782
11618
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
11783
11619
  width *= scaleX;
11784
11620
  height *= scaleY;