microboard-temp 0.4.96 → 0.4.97

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.
@@ -7064,7 +7064,9 @@ var conf = {
7064
7064
  FORCE_HOTKEYS: "auto",
7065
7065
  debug: false,
7066
7066
  FALLBACK_LNG: "en",
7067
- cursorsMap
7067
+ cursorsMap,
7068
+ DECK_HORIZONTAL_OFFSET: 2,
7069
+ DECK_VERTICAL_OFFSET: 0
7068
7070
  };
7069
7071
  initDefaultI18N();
7070
7072
 
@@ -47863,6 +47865,9 @@ class Card extends BaseItem {
47863
47865
  this.imageToRender = this.face;
47864
47866
  }
47865
47867
  }
47868
+ getImage() {
47869
+ return this.imageToRender;
47870
+ }
47866
47871
  render(context, left, top) {
47867
47872
  if (this.transformationRenderBlock) {
47868
47873
  return;
@@ -47952,8 +47957,8 @@ class Deck extends BaseItem {
47952
47957
  class: "Transformation",
47953
47958
  method: "translateTo",
47954
47959
  item: [this.id],
47955
- x: this.left + (this.index?.list().length || 0) * 2,
47956
- y: this.top
47960
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
47961
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
47957
47962
  });
47958
47963
  this.board.items.index.remove(foundItem);
47959
47964
  foundItem.parent = this.getId();
@@ -48055,7 +48060,6 @@ class Deck extends BaseItem {
48055
48060
  const ctx = context.ctx;
48056
48061
  if (this.isCacheDirty || !this.cachedCanvas) {
48057
48062
  this.updateCache(context);
48058
- this.isCacheDirty = false;
48059
48063
  }
48060
48064
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48061
48065
  ctx.save();
@@ -48064,9 +48068,12 @@ class Deck extends BaseItem {
48064
48068
  }
48065
48069
  }
48066
48070
  updateCache(context) {
48071
+ const cards = this.index?.list();
48072
+ const topCard = cards[cards.length - 1];
48073
+ const topCardImage = topCard?.getImage();
48067
48074
  const width2 = this.getWidth();
48068
48075
  const height3 = this.getHeight();
48069
- if (!width2 || !height3) {
48076
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
48070
48077
  return;
48071
48078
  }
48072
48079
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -48076,10 +48083,11 @@ class Deck extends BaseItem {
48076
48083
  if (!tempCtx)
48077
48084
  return;
48078
48085
  const tempContext = { ...context, ctx: tempCtx };
48079
- this.index?.list().forEach((item, index2) => {
48080
- item.render(tempContext, index2 * 2, 0);
48086
+ cards.forEach((_, index2) => {
48087
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
48081
48088
  });
48082
48089
  this.cachedCanvas = tempCanvas;
48090
+ this.isCacheDirty = false;
48083
48091
  }
48084
48092
  }
48085
48093
  registerItem({
package/dist/cjs/index.js CHANGED
@@ -7064,7 +7064,9 @@ var conf = {
7064
7064
  FORCE_HOTKEYS: "auto",
7065
7065
  debug: false,
7066
7066
  FALLBACK_LNG: "en",
7067
- cursorsMap
7067
+ cursorsMap,
7068
+ DECK_HORIZONTAL_OFFSET: 2,
7069
+ DECK_VERTICAL_OFFSET: 0
7068
7070
  };
7069
7071
  initDefaultI18N();
7070
7072
 
@@ -47863,6 +47865,9 @@ class Card extends BaseItem {
47863
47865
  this.imageToRender = this.face;
47864
47866
  }
47865
47867
  }
47868
+ getImage() {
47869
+ return this.imageToRender;
47870
+ }
47866
47871
  render(context, left, top) {
47867
47872
  if (this.transformationRenderBlock) {
47868
47873
  return;
@@ -47952,8 +47957,8 @@ class Deck extends BaseItem {
47952
47957
  class: "Transformation",
47953
47958
  method: "translateTo",
47954
47959
  item: [this.id],
47955
- x: this.left + (this.index?.list().length || 0) * 2,
47956
- y: this.top
47960
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
47961
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
47957
47962
  });
47958
47963
  this.board.items.index.remove(foundItem);
47959
47964
  foundItem.parent = this.getId();
@@ -48055,7 +48060,6 @@ class Deck extends BaseItem {
48055
48060
  const ctx = context.ctx;
48056
48061
  if (this.isCacheDirty || !this.cachedCanvas) {
48057
48062
  this.updateCache(context);
48058
- this.isCacheDirty = false;
48059
48063
  }
48060
48064
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48061
48065
  ctx.save();
@@ -48064,9 +48068,12 @@ class Deck extends BaseItem {
48064
48068
  }
48065
48069
  }
48066
48070
  updateCache(context) {
48071
+ const cards = this.index?.list();
48072
+ const topCard = cards[cards.length - 1];
48073
+ const topCardImage = topCard?.getImage();
48067
48074
  const width2 = this.getWidth();
48068
48075
  const height3 = this.getHeight();
48069
- if (!width2 || !height3) {
48076
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
48070
48077
  return;
48071
48078
  }
48072
48079
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -48076,10 +48083,11 @@ class Deck extends BaseItem {
48076
48083
  if (!tempCtx)
48077
48084
  return;
48078
48085
  const tempContext = { ...context, ctx: tempCtx };
48079
- this.index?.list().forEach((item, index2) => {
48080
- item.render(tempContext, index2 * 2, 0);
48086
+ cards.forEach((_, index2) => {
48087
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
48081
48088
  });
48082
48089
  this.cachedCanvas = tempCanvas;
48090
+ this.isCacheDirty = false;
48083
48091
  }
48084
48092
  }
48085
48093
  registerItem({
package/dist/cjs/node.js CHANGED
@@ -8101,7 +8101,9 @@ var conf = {
8101
8101
  FORCE_HOTKEYS: "auto",
8102
8102
  debug: false,
8103
8103
  FALLBACK_LNG: "en",
8104
- cursorsMap
8104
+ cursorsMap,
8105
+ DECK_HORIZONTAL_OFFSET: 2,
8106
+ DECK_VERTICAL_OFFSET: 0
8105
8107
  };
8106
8108
  initDefaultI18N();
8107
8109
 
@@ -50336,6 +50338,9 @@ class Card extends BaseItem {
50336
50338
  this.imageToRender = this.face;
50337
50339
  }
50338
50340
  }
50341
+ getImage() {
50342
+ return this.imageToRender;
50343
+ }
50339
50344
  render(context, left, top) {
50340
50345
  if (this.transformationRenderBlock) {
50341
50346
  return;
@@ -50425,8 +50430,8 @@ class Deck extends BaseItem {
50425
50430
  class: "Transformation",
50426
50431
  method: "translateTo",
50427
50432
  item: [this.id],
50428
- x: this.left + (this.index?.list().length || 0) * 2,
50429
- y: this.top
50433
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
50434
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
50430
50435
  });
50431
50436
  this.board.items.index.remove(foundItem);
50432
50437
  foundItem.parent = this.getId();
@@ -50528,7 +50533,6 @@ class Deck extends BaseItem {
50528
50533
  const ctx = context.ctx;
50529
50534
  if (this.isCacheDirty || !this.cachedCanvas) {
50530
50535
  this.updateCache(context);
50531
- this.isCacheDirty = false;
50532
50536
  }
50533
50537
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
50534
50538
  ctx.save();
@@ -50537,9 +50541,12 @@ class Deck extends BaseItem {
50537
50541
  }
50538
50542
  }
50539
50543
  updateCache(context) {
50544
+ const cards = this.index?.list();
50545
+ const topCard = cards[cards.length - 1];
50546
+ const topCardImage = topCard?.getImage();
50540
50547
  const width2 = this.getWidth();
50541
50548
  const height3 = this.getHeight();
50542
- if (!width2 || !height3) {
50549
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
50543
50550
  return;
50544
50551
  }
50545
50552
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -50549,10 +50556,11 @@ class Deck extends BaseItem {
50549
50556
  if (!tempCtx)
50550
50557
  return;
50551
50558
  const tempContext = { ...context, ctx: tempCtx };
50552
- this.index?.list().forEach((item, index2) => {
50553
- item.render(tempContext, index2 * 2, 0);
50559
+ cards.forEach((_, index2) => {
50560
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
50554
50561
  });
50555
50562
  this.cachedCanvas = tempCanvas;
50563
+ this.isCacheDirty = false;
50556
50564
  }
50557
50565
  }
50558
50566
  registerItem({
@@ -6904,7 +6904,9 @@ var conf = {
6904
6904
  FORCE_HOTKEYS: "auto",
6905
6905
  debug: false,
6906
6906
  FALLBACK_LNG: "en",
6907
- cursorsMap
6907
+ cursorsMap,
6908
+ DECK_HORIZONTAL_OFFSET: 2,
6909
+ DECK_VERTICAL_OFFSET: 0
6908
6910
  };
6909
6911
  initDefaultI18N();
6910
6912
 
@@ -47712,6 +47714,9 @@ class Card extends BaseItem {
47712
47714
  this.imageToRender = this.face;
47713
47715
  }
47714
47716
  }
47717
+ getImage() {
47718
+ return this.imageToRender;
47719
+ }
47715
47720
  render(context, left, top) {
47716
47721
  if (this.transformationRenderBlock) {
47717
47722
  return;
@@ -47801,8 +47806,8 @@ class Deck extends BaseItem {
47801
47806
  class: "Transformation",
47802
47807
  method: "translateTo",
47803
47808
  item: [this.id],
47804
- x: this.left + (this.index?.list().length || 0) * 2,
47805
- y: this.top
47809
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
47810
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
47806
47811
  });
47807
47812
  this.board.items.index.remove(foundItem);
47808
47813
  foundItem.parent = this.getId();
@@ -47904,7 +47909,6 @@ class Deck extends BaseItem {
47904
47909
  const ctx = context.ctx;
47905
47910
  if (this.isCacheDirty || !this.cachedCanvas) {
47906
47911
  this.updateCache(context);
47907
- this.isCacheDirty = false;
47908
47912
  }
47909
47913
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
47910
47914
  ctx.save();
@@ -47913,9 +47917,12 @@ class Deck extends BaseItem {
47913
47917
  }
47914
47918
  }
47915
47919
  updateCache(context) {
47920
+ const cards = this.index?.list();
47921
+ const topCard = cards[cards.length - 1];
47922
+ const topCardImage = topCard?.getImage();
47916
47923
  const width2 = this.getWidth();
47917
47924
  const height3 = this.getHeight();
47918
- if (!width2 || !height3) {
47925
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
47919
47926
  return;
47920
47927
  }
47921
47928
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -47925,10 +47932,11 @@ class Deck extends BaseItem {
47925
47932
  if (!tempCtx)
47926
47933
  return;
47927
47934
  const tempContext = { ...context, ctx: tempCtx };
47928
- this.index?.list().forEach((item, index2) => {
47929
- item.render(tempContext, index2 * 2, 0);
47935
+ cards.forEach((_, index2) => {
47936
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
47930
47937
  });
47931
47938
  this.cachedCanvas = tempCanvas;
47939
+ this.isCacheDirty = false;
47932
47940
  }
47933
47941
  }
47934
47942
  registerItem({
package/dist/esm/index.js CHANGED
@@ -6897,7 +6897,9 @@ var conf = {
6897
6897
  FORCE_HOTKEYS: "auto",
6898
6898
  debug: false,
6899
6899
  FALLBACK_LNG: "en",
6900
- cursorsMap
6900
+ cursorsMap,
6901
+ DECK_HORIZONTAL_OFFSET: 2,
6902
+ DECK_VERTICAL_OFFSET: 0
6901
6903
  };
6902
6904
  initDefaultI18N();
6903
6905
 
@@ -47705,6 +47707,9 @@ class Card extends BaseItem {
47705
47707
  this.imageToRender = this.face;
47706
47708
  }
47707
47709
  }
47710
+ getImage() {
47711
+ return this.imageToRender;
47712
+ }
47708
47713
  render(context, left, top) {
47709
47714
  if (this.transformationRenderBlock) {
47710
47715
  return;
@@ -47794,8 +47799,8 @@ class Deck extends BaseItem {
47794
47799
  class: "Transformation",
47795
47800
  method: "translateTo",
47796
47801
  item: [this.id],
47797
- x: this.left + (this.index?.list().length || 0) * 2,
47798
- y: this.top
47802
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
47803
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
47799
47804
  });
47800
47805
  this.board.items.index.remove(foundItem);
47801
47806
  foundItem.parent = this.getId();
@@ -47897,7 +47902,6 @@ class Deck extends BaseItem {
47897
47902
  const ctx = context.ctx;
47898
47903
  if (this.isCacheDirty || !this.cachedCanvas) {
47899
47904
  this.updateCache(context);
47900
- this.isCacheDirty = false;
47901
47905
  }
47902
47906
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
47903
47907
  ctx.save();
@@ -47906,9 +47910,12 @@ class Deck extends BaseItem {
47906
47910
  }
47907
47911
  }
47908
47912
  updateCache(context) {
47913
+ const cards = this.index?.list();
47914
+ const topCard = cards[cards.length - 1];
47915
+ const topCardImage = topCard?.getImage();
47909
47916
  const width2 = this.getWidth();
47910
47917
  const height3 = this.getHeight();
47911
- if (!width2 || !height3) {
47918
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
47912
47919
  return;
47913
47920
  }
47914
47921
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -47918,10 +47925,11 @@ class Deck extends BaseItem {
47918
47925
  if (!tempCtx)
47919
47926
  return;
47920
47927
  const tempContext = { ...context, ctx: tempCtx };
47921
- this.index?.list().forEach((item, index2) => {
47922
- item.render(tempContext, index2 * 2, 0);
47928
+ cards.forEach((_, index2) => {
47929
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
47923
47930
  });
47924
47931
  this.cachedCanvas = tempCanvas;
47932
+ this.isCacheDirty = false;
47925
47933
  }
47926
47934
  }
47927
47935
  registerItem({
package/dist/esm/node.js CHANGED
@@ -7681,7 +7681,9 @@ var conf = {
7681
7681
  FORCE_HOTKEYS: "auto",
7682
7682
  debug: false,
7683
7683
  FALLBACK_LNG: "en",
7684
- cursorsMap
7684
+ cursorsMap,
7685
+ DECK_HORIZONTAL_OFFSET: 2,
7686
+ DECK_VERTICAL_OFFSET: 0
7685
7687
  };
7686
7688
  initDefaultI18N();
7687
7689
 
@@ -50173,6 +50175,9 @@ class Card extends BaseItem {
50173
50175
  this.imageToRender = this.face;
50174
50176
  }
50175
50177
  }
50178
+ getImage() {
50179
+ return this.imageToRender;
50180
+ }
50176
50181
  render(context, left, top) {
50177
50182
  if (this.transformationRenderBlock) {
50178
50183
  return;
@@ -50262,8 +50267,8 @@ class Deck extends BaseItem {
50262
50267
  class: "Transformation",
50263
50268
  method: "translateTo",
50264
50269
  item: [this.id],
50265
- x: this.left + (this.index?.list().length || 0) * 2,
50266
- y: this.top
50270
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
50271
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
50267
50272
  });
50268
50273
  this.board.items.index.remove(foundItem);
50269
50274
  foundItem.parent = this.getId();
@@ -50365,7 +50370,6 @@ class Deck extends BaseItem {
50365
50370
  const ctx = context.ctx;
50366
50371
  if (this.isCacheDirty || !this.cachedCanvas) {
50367
50372
  this.updateCache(context);
50368
- this.isCacheDirty = false;
50369
50373
  }
50370
50374
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
50371
50375
  ctx.save();
@@ -50374,9 +50378,12 @@ class Deck extends BaseItem {
50374
50378
  }
50375
50379
  }
50376
50380
  updateCache(context) {
50381
+ const cards = this.index?.list();
50382
+ const topCard = cards[cards.length - 1];
50383
+ const topCardImage = topCard?.getImage();
50377
50384
  const width2 = this.getWidth();
50378
50385
  const height3 = this.getHeight();
50379
- if (!width2 || !height3) {
50386
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
50380
50387
  return;
50381
50388
  }
50382
50389
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -50386,10 +50393,11 @@ class Deck extends BaseItem {
50386
50393
  if (!tempCtx)
50387
50394
  return;
50388
50395
  const tempContext = { ...context, ctx: tempCtx };
50389
- this.index?.list().forEach((item, index2) => {
50390
- item.render(tempContext, index2 * 2, 0);
50396
+ cards.forEach((_, index2) => {
50397
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
50391
50398
  });
50392
50399
  this.cachedCanvas = tempCanvas;
50400
+ this.isCacheDirty = false;
50393
50401
  }
50394
50402
  }
50395
50403
  registerItem({
@@ -26,6 +26,7 @@ export declare class Card extends BaseItem {
26
26
  });
27
27
  createImages(): void;
28
28
  updateImageToRender(): void;
29
+ getImage(): HTMLImageElement | null;
29
30
  render(context: DrawingContext, left?: number, top?: number): void;
30
31
  updateMbr(): void;
31
32
  getPath(): Path | Paths;
@@ -230,6 +230,8 @@ export declare const conf: {
230
230
  debug: boolean;
231
231
  FALLBACK_LNG: string;
232
232
  cursorsMap: Partial<Record<import("./Pointer/Cursor").CursorName, string>>;
233
+ DECK_HORIZONTAL_OFFSET: number;
234
+ DECK_VERTICAL_OFFSET: number;
233
235
  };
234
236
  export type Settings = typeof conf;
235
237
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.4.96",
3
+ "version": "0.4.97",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",