@meta2d/core 1.1.3 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meta2d/core",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
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",
@@ -1122,7 +1122,7 @@ export class Canvas {
1122
1122
  if (obj[0] && obj[0].draggable !== false) {
1123
1123
  const pt = { x: event.offsetX, y: event.offsetY };
1124
1124
  this.calibrateMouse(pt);
1125
- this.dropPens(obj, pt);
1125
+ await this.dropPens(obj, pt);
1126
1126
  this.addCaches = [];
1127
1127
  // 拖拽新增图元判断是否是在容器上
1128
1128
  this.getContainerHover(pt);
@@ -1328,6 +1328,13 @@ export class Canvas {
1328
1328
  return [];
1329
1329
  }
1330
1330
  const list = [];
1331
+ for (const pen of pens) {
1332
+ if (!pen.id) {
1333
+ pen.id = s8();
1334
+ }
1335
+ !pen.calculative && (pen.calculative = { canvas: this });
1336
+ this.store.pens[pen.id] = pen;
1337
+ }
1331
1338
  for (const pen of pens) {
1332
1339
  if (this.beforeAddPen && this.beforeAddPen(pen) != true) {
1333
1340
  continue;
@@ -1383,6 +1390,7 @@ export class Canvas {
1383
1390
  buttons: 1,
1384
1391
  });
1385
1392
  if (e.touches.length === 2) {
1393
+ this.mouseDown = undefined;
1386
1394
  this.initTouchDis = Math.hypot(e.touches[0].pageX - e.touches[1].pageX, e.touches[0].pageY - e.touches[1].pageY);
1387
1395
  this.initScale = this.store.data.scale;
1388
1396
  this.startTouches = e.touches;
@@ -1450,16 +1458,17 @@ export class Canvas {
1450
1458
  });
1451
1459
  }
1452
1460
  else if (len === 2 && this.startTouches?.length === 2) {
1461
+ this.mouseDown = undefined;
1453
1462
  if (!this.touchMoving && !this.touchScaling) {
1454
1463
  const x1 = this.startTouches[0].pageX - touches[0].pageX;
1455
1464
  const x2 = this.startTouches[1].pageX - touches[1].pageX;
1456
1465
  const y1 = this.startTouches[0].pageY - touches[0].pageY;
1457
1466
  const y2 = this.startTouches[1].pageY - touches[1].pageY;
1458
- if (((x1 >= 0 && x2 < 0) || (x1 <= 0 && x2 > 0)) &&
1459
- ((y1 >= 0 && y2 < 0) || (y1 <= 0 && y2 > 0))) {
1467
+ if ((((x1 >= 0 && x2 < 0) || (x1 <= 0 && x2 > 0)) &&
1468
+ ((y1 >= 0 && y2 < 0) || (y1 <= 0 && y2 > 0))) || (x2 == 0 && y2 == 0) || (x1 == 0 && y1 == 0)) {
1460
1469
  this.touchScaling = true;
1461
1470
  }
1462
- else {
1471
+ else if (y1 * y2 > 0 && x1 * x2 > 0) {
1463
1472
  this.touchMoving = true;
1464
1473
  }
1465
1474
  }
@@ -2812,7 +2821,7 @@ export class Canvas {
2812
2821
  if (this.dragRect) {
2813
2822
  return;
2814
2823
  }
2815
- this.store.hoverContainer = undefined;
2824
+ // this.store.hoverContainer = undefined;
2816
2825
  const containerPens = this.store.data.pens.filter((pen) => pen.container || this.store.options.containerShapes?.includes(pen.name));
2817
2826
  if (containerPens.length) {
2818
2827
  for (let i = containerPens.length - 1; i >= 0; --i) {
@@ -2974,6 +2983,9 @@ export class Canvas {
2974
2983
  pen.locked === LockState.Disable) {
2975
2984
  continue;
2976
2985
  }
2986
+ if (this.store.data.locked && pen.name === 'sceneContainer') {
2987
+ continue;
2988
+ }
2977
2989
  const r = getLineR(pen);
2978
2990
  if (!pen.calculative.active &&
2979
2991
  !pointInSimpleRect(pt, pen.calculative.worldRect, r) &&
@@ -6023,10 +6035,25 @@ export class Canvas {
6023
6035
  this.store.clipboard = undefined;
6024
6036
  localStorage.removeItem(this.clipboardName);
6025
6037
  sessionStorage.setItem('page', page);
6026
- let copyPens = this.getAllByPens(deepClone(pens || this.store.active, true));
6038
+ let precCopyPens = deepClone(pens, true);
6039
+ if (!precCopyPens) {
6040
+ precCopyPens = deepClone(this.store.active, true);
6041
+ if (precCopyPens.length === 1 && precCopyPens[0].parentId) {
6042
+ //复制子图元
6043
+ precCopyPens[0].parentId = undefined;
6044
+ precCopyPens[0].x = precCopyPens[0].calculative.worldRect.x;
6045
+ precCopyPens[0].y = precCopyPens[0].calculative.worldRect.y;
6046
+ precCopyPens[0].width = precCopyPens[0].calculative.worldRect.width;
6047
+ precCopyPens[0].height = precCopyPens[0].calculative.worldRect.height;
6048
+ }
6049
+ }
6050
+ let copyPens = this.getAllByPens(precCopyPens);
6027
6051
  //根据pens顺序复制
6028
6052
  copyPens.forEach((activePen) => {
6029
6053
  activePen.copyIndex = this.store.data.pens.findIndex((pen) => pen.id === activePen.id);
6054
+ if (activePen.followers?.length) {
6055
+ activePen.followers = undefined;
6056
+ }
6030
6057
  if (activePen.pathId) {
6031
6058
  //复制svgpath
6032
6059
  activePen.path = this.store.data.paths[activePen.pathId];