@meta2d/core 1.0.29 → 1.0.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meta2d/core",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -273,6 +273,13 @@ var Canvas = /** @class */ (function () {
273
273
  _this.translate(-e.deltaX, -e.deltaY);
274
274
  return;
275
275
  }
276
+ if (Math.abs(e.wheelDelta) > 100) {
277
+ //鼠标滚轮滚动 scroll模式下是上下滚动而不是缩放
278
+ if (_this.store.options.scroll && _this.scroll) {
279
+ _this.scroll.wheel(e.deltaY < 0);
280
+ return;
281
+ }
282
+ }
276
283
  //禁止触摸屏双指缩放操作
277
284
  if (_this.store.options.disableTouchPadScale) {
278
285
  return;
@@ -638,9 +645,11 @@ var Canvas = /** @class */ (function () {
638
645
  }
639
646
  }
640
647
  catch (e) { }
641
- if (!(!obj && !(this.addCaches && this.addCaches.length))) return [3 /*break*/, 3];
648
+ if (!!obj) return [3 /*break*/, 3];
642
649
  files = event.dataTransfer.files;
643
- if (!(files.length && files[0].type.match('image.*'))) return [3 /*break*/, 2];
650
+ if (!(files.length &&
651
+ files[0].type.match('image.*') &&
652
+ !(this.addCaches && this.addCaches.length))) return [3 /*break*/, 2];
644
653
  isGif = files[0].type === 'image/gif';
645
654
  return [4 /*yield*/, this.fileToPen(files[0], isGif)];
646
655
  case 1:
@@ -1441,8 +1450,8 @@ var Canvas = /** @class */ (function () {
1441
1450
  // 只存在一个缓存图元
1442
1451
  if (_this.addCaches.length === 1) {
1443
1452
  var target = _this.addCaches[0];
1444
- target.width = _this.dragRect.width;
1445
- target.height = _this.dragRect.height;
1453
+ target.width = _this.dragRect.width / _this.store.data.scale;
1454
+ target.height = _this.dragRect.height / _this.store.data.scale;
1446
1455
  e.x = (_this.dragRect.x + _this.dragRect.ex) / 2;
1447
1456
  e.y = (_this.dragRect.y + _this.dragRect.ey) / 2;
1448
1457
  }
@@ -1745,6 +1754,7 @@ var Canvas = /** @class */ (function () {
1745
1754
  _this.store.hover = pen;
1746
1755
  _this.store.pointAt = pos.point;
1747
1756
  _this.store.pointAtIndex = pos.i;
1757
+ _this.initTemplateCanvas([_this.store.hover]);
1748
1758
  hoverType = HoverType.Line;
1749
1759
  return "break";
1750
1760
  }
@@ -1780,6 +1790,7 @@ var Canvas = /** @class */ (function () {
1780
1790
  _this.externalElements.style.cursor = _this.store.options.hoverCursor;
1781
1791
  }
1782
1792
  _this.store.hover = pen;
1793
+ _this.initTemplateCanvas([_this.store.hover]);
1783
1794
  hoverType = HoverType.Node;
1784
1795
  _this.store.pointAt = pt;
1785
1796
  // 锚点贴边吸附
@@ -2775,7 +2786,9 @@ var Canvas = /** @class */ (function () {
2775
2786
  _this.store.hover = undefined;
2776
2787
  }
2777
2788
  _this.render();
2778
- if (e.toElement !== _this.tooltip.box) {
2789
+ if (e.toElement !== _this.tooltip.box &&
2790
+ e.toElement !== _this.tooltip.arrowUp &&
2791
+ e.toElement !== _this.tooltip.arrowDown) {
2779
2792
  _this.tooltip.hide();
2780
2793
  _this.store.lastHover = undefined;
2781
2794
  }
@@ -2999,6 +3012,7 @@ var Canvas = /** @class */ (function () {
2999
3012
  { x: pen.x + pen.width, y: pen.y },
3000
3013
  { x: pen.x, y: pen.y + pen.height },
3001
3014
  { x: pen.x + pen.width, y: pen.y + pen.height },
3015
+ { x: pen.x + pen.width / 2, y: pen.y + pen.height / 2 },
3002
3016
  ];
3003
3017
  if ((pen.x === rect_1.x &&
3004
3018
  pen.y === rect_1.y &&
@@ -3357,6 +3371,7 @@ var Canvas = /** @class */ (function () {
3357
3371
  if (!this.store.active.length) {
3358
3372
  return;
3359
3373
  }
3374
+ this.initTemplateCanvas(this.store.active);
3360
3375
  this.store.active.forEach(function (pen) {
3361
3376
  pen.calculative.active = undefined;
3362
3377
  pen.calculative.activeAnchor = undefined;
@@ -3399,6 +3414,7 @@ var Canvas = /** @class */ (function () {
3399
3414
  (_b = this.store.active).push.apply(_b, __spreadArray([], __read(pens), false));
3400
3415
  this.activeRect = undefined;
3401
3416
  this.calcActiveRect();
3417
+ this.initTemplateCanvas(pens);
3402
3418
  this.patchFlags = true;
3403
3419
  emit && this.store.emitter.emit('active', this.store.active);
3404
3420
  };
@@ -5198,6 +5214,9 @@ var Canvas = /** @class */ (function () {
5198
5214
  var from = getFromAnchor(line);
5199
5215
  var to = getToAnchor(line);
5200
5216
  var newAnchor = nearestAnchor(pen, lineAnchor === from ? to : from);
5217
+ if (!newAnchor) {
5218
+ return;
5219
+ }
5201
5220
  lineAnchor.x = newAnchor.x;
5202
5221
  lineAnchor.y = newAnchor.y;
5203
5222
  lineAnchor.prev = undefined;