@meta2d/core 1.1.15 → 1.1.18

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.15",
3
+ "version": "1.1.18",
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",
@@ -855,7 +855,12 @@ export class Canvas {
855
855
  case 'z':
856
856
  case 'Z':
857
857
  if (e.ctrlKey || e.metaKey) {
858
- this.undo();
858
+ if (e.shiftKey) {
859
+ this.redo();
860
+ }
861
+ else {
862
+ this.undo();
863
+ }
859
864
  }
860
865
  else if (e.shiftKey) {
861
866
  this.redo();
@@ -1089,7 +1094,7 @@ export class Canvas {
1089
1094
  img.onerror = (e) => {
1090
1095
  reject(e);
1091
1096
  };
1092
- img.crossOrigin = 'anonymous';
1097
+ img.crossOrigin = this.store.options.crossOrigin || 'anonymous';
1093
1098
  img.src = url;
1094
1099
  });
1095
1100
  }
@@ -4001,6 +4006,7 @@ export class Canvas {
4001
4006
  const image64 = 'data:image/svg+xml;base64,' + svg64;
4002
4007
  // set that as your image source
4003
4008
  img.src = image64;
4009
+ img.crossOrigin = pen.crossOrigin || this.store.options.crossOrigin || 'anonymous';
4004
4010
  // do your canvas work
4005
4011
  img.onload = () => {
4006
4012
  pen.calculative.img = img;
@@ -4044,7 +4050,7 @@ export class Canvas {
4044
4050
  img.crossOrigin =
4045
4051
  pen.crossOrigin === 'undefined'
4046
4052
  ? undefined
4047
- : pen.crossOrigin || 'anonymous';
4053
+ : pen.crossOrigin || this.store.options.crossOrigin || 'anonymous';
4048
4054
  img.src = pen.image;
4049
4055
  if (this.store.options.cdn &&
4050
4056
  !(pen.image.startsWith('http') ||
@@ -4080,7 +4086,7 @@ export class Canvas {
4080
4086
  }
4081
4087
  else {
4082
4088
  const img = new Image();
4083
- img.crossOrigin = 'anonymous';
4089
+ img.crossOrigin = pen.crossOrigin || this.store.options.crossOrigin || 'anonymous';
4084
4090
  img.src = pen.backgroundImage;
4085
4091
  if (this.store.options.cdn &&
4086
4092
  !(pen.backgroundImage.startsWith('http') ||
@@ -4110,7 +4116,7 @@ export class Canvas {
4110
4116
  }
4111
4117
  else {
4112
4118
  const img = new Image();
4113
- img.crossOrigin = 'anonymous';
4119
+ img.crossOrigin = pen.crossOrigin || this.store.options.crossOrigin || 'anonymous';
4114
4120
  img.src = pen.strokeImage;
4115
4121
  if (this.store.options.cdn &&
4116
4122
  !(pen.strokeImage.startsWith('http') ||
@@ -4142,7 +4148,7 @@ export class Canvas {
4142
4148
  const promise = new Promise((resolve, reject) => {
4143
4149
  if (!globalStore.htmlElements[src]) {
4144
4150
  const img = new Image();
4145
- img.crossOrigin = 'anonymous';
4151
+ img.crossOrigin = this.store.options.crossOrigin || 'anonymous';
4146
4152
  // 处理 CDN 路径
4147
4153
  if (this.store.options.cdn &&
4148
4154
  !(src.startsWith('http') ||
@@ -4354,12 +4360,20 @@ export class Canvas {
4354
4360
  return;
4355
4361
  }
4356
4362
  if (now - this.lastRender < this.store.options.interval) {
4363
+ if (this.store.options.interval > this.store.options.minFPSNumber && this.store.options.autoFPS) {
4364
+ this.store.options.interval--;
4365
+ this.store.options.animateInterval = this.store.options.interval;
4366
+ }
4357
4367
  if (this.renderTimer) {
4358
4368
  cancelAnimationFrame(this.renderTimer);
4359
4369
  }
4360
4370
  this.renderTimer = requestAnimationFrame(this.render);
4361
4371
  return;
4362
4372
  }
4373
+ else if (now - this.lastRender - this.store.options.interval > 10 && this.store.options.autoFPS && document.visibilityState === 'visible') {
4374
+ this.store.options.interval++;
4375
+ this.store.options.animateInterval = this.store.options.interval;
4376
+ }
4363
4377
  this.renderTimer = undefined;
4364
4378
  this.lastRender = now;
4365
4379
  const offscreenCtx = this.offscreen.getContext('2d');
@@ -7183,6 +7197,7 @@ export class Canvas {
7183
7197
  li.onmousedown = this.stopPropagation;
7184
7198
  li.dataset.i = index + '';
7185
7199
  li.onclick = this.selectDropdown;
7200
+ li.ontouchstart = this.selectDropdown;
7186
7201
  const pen = this.store.pens[this.inputDiv.dataset.penId];
7187
7202
  li.onmouseenter = () => {
7188
7203
  li.style.background = pen.dropdownHoverBackground || this.store.styles["activeBg"] || '#eee';
@@ -7195,6 +7210,7 @@ export class Canvas {
7195
7210
  this.dropdown.appendChild(li);
7196
7211
  }
7197
7212
  selectDropdown = (e) => {
7213
+ e.stopPropagation();
7198
7214
  const li = e.target;
7199
7215
  const pen = this.store.pens[this.inputDiv.dataset.penId];
7200
7216
  if (!li || !pen || !pen.dropdownList) {