@meta2d/core 1.0.76 → 1.0.78

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.76",
3
+ "version": "1.0.78",
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",
@@ -1115,6 +1115,8 @@ export class Canvas {
1115
1115
  !pen.parentId && this.randomCombineId(pen, pens);
1116
1116
  }
1117
1117
  if (Object.keys(this.randomIdObj).length !== 0) {
1118
+ const keys = Object.keys(this.randomIdObj).join('|');
1119
+ const regex = new RegExp(`(${keys})`, "g");
1118
1120
  for (const pen of pens) {
1119
1121
  if (pen.type) {
1120
1122
  pen.anchors[0].connectTo = this.randomIdObj[pen.anchors[0].connectTo];
@@ -1127,6 +1129,19 @@ export class Canvas {
1127
1129
  item.lineId = this.randomIdObj[item.lineId];
1128
1130
  });
1129
1131
  }
1132
+ //动画、事件和状态
1133
+ if (pen.animations?.length) {
1134
+ const str = JSON.stringify(pen.animations).replace(regex, match => this.randomIdObj[match]);
1135
+ pen.animations = JSON.parse(str);
1136
+ }
1137
+ if (pen.triggers?.length) {
1138
+ const str = JSON.stringify(pen.triggers).replace(regex, match => this.randomIdObj[match]);
1139
+ pen.triggers = JSON.parse(str);
1140
+ }
1141
+ if (pen.events?.length) {
1142
+ const str = JSON.stringify(pen.events).replace(regex, match => this.randomIdObj[match]);
1143
+ pen.events = JSON.parse(str);
1144
+ }
1130
1145
  }
1131
1146
  }
1132
1147
  for (const pen of pens) {
@@ -1237,12 +1252,14 @@ export class Canvas {
1237
1252
  }
1238
1253
  }
1239
1254
  else {
1240
- if (pen.connectedLines && pen.connectedLines.length) {
1255
+ if (pens.length > 1) {
1256
+ // if (pen.connectedLines && pen.connectedLines.length) {
1241
1257
  beforeIds = [pen.id];
1242
1258
  }
1243
1259
  }
1244
1260
  randomId(pen);
1245
- if (beforeIds) {
1261
+ if (pens.length > 1) {
1262
+ // if (beforeIds) {
1246
1263
  if (beforeIds.length === 1) {
1247
1264
  this.randomIdObj[beforeIds[0]] = pen.id;
1248
1265
  }
@@ -5819,8 +5836,14 @@ export class Canvas {
5819
5836
  const curPage = sessionStorage.getItem('page');
5820
5837
  const scale = this.store.data.scale;
5821
5838
  if (this.store.clipboard.mousePos && (Math.abs(this.store.clipboard.mousePos.x - this.mousePos.x) > 100 * scale || Math.abs(this.store.clipboard.mousePos.y - this.mousePos.y) > 100 * scale)) {
5822
- const offsetX = (scale - this.store.clipboard.scale) * this.store.clipboard.initRect.width / 2;
5823
- const offsetY = (scale - this.store.clipboard.scale) * this.store.clipboard.initRect.height / 2;
5839
+ let _x = -this.store.clipboard.initRect.width / this.store.clipboard.scale / 10 / (scale);
5840
+ let _y = -this.store.clipboard.initRect.height / this.store.clipboard.scale / 10 / (scale);
5841
+ let offsetX = (scale - this.store.clipboard.scale) * this.store.clipboard.initRect.width / 2 + _x;
5842
+ let offsetY = (scale - this.store.clipboard.scale) * this.store.clipboard.initRect.height / 2 + _y;
5843
+ if (this.store.clipboard.pens.length > 1) {
5844
+ offsetX = (scale - 1) * this.store.clipboard.initRect.width / this.store.clipboard.scale / 2;
5845
+ offsetY = (scale - 1) * this.store.clipboard.initRect.height / this.store.clipboard.scale / 2;
5846
+ }
5824
5847
  this.store.clipboard.pos = { x: this.mousePos.x - offsetX, y: this.mousePos.y - offsetY };
5825
5848
  this.store.clipboard.offset = 0;
5826
5849
  }
@@ -6893,7 +6916,7 @@ export class Canvas {
6893
6916
  if (needCalcIconRectProps.includes(k)) {
6894
6917
  willCalcIconRect = true;
6895
6918
  }
6896
- if (pen.image && pen.name !== 'gif' && ['globalAlpha', 'flipY', 'flipX', 'x', 'y', 'width', 'height', 'iconWidth', 'iconHeight', 'imageRatio', 'iconLeft', 'iconTop', 'iconAlign', 'rotate'].includes(k)) {
6919
+ if (pen.image && pen.name !== 'gif' && ['globalAlpha', 'flipY', 'flipX', 'x', 'y', 'width', 'height', 'iconWidth', 'iconHeight', 'imageRatio', 'iconLeft', 'iconTop', 'iconAlign', 'rotate', 'visible'].includes(k)) {
6897
6920
  willRenderImage = true;
6898
6921
  }
6899
6922
  }