microboard-temp 0.5.53 → 0.5.55

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.
@@ -48141,6 +48141,8 @@ class Deck extends BaseItem {
48141
48141
  resizeEnabled = false;
48142
48142
  path = null;
48143
48143
  isPerpendicular = undefined;
48144
+ animationFrameId;
48145
+ drawingContext = null;
48144
48146
  constructor(board, id = "") {
48145
48147
  super(board, id, defaultDeckData, true);
48146
48148
  this.index.getUnderPoint = () => [];
@@ -48251,6 +48253,7 @@ class Deck extends BaseItem {
48251
48253
  const j = Math.floor(Math.random() * (i + 1));
48252
48254
  [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
48253
48255
  }
48256
+ this.emitAnimation();
48254
48257
  this.removeChildItems(this.index.list());
48255
48258
  this.addChildItems(shuffled);
48256
48259
  }
@@ -48267,6 +48270,12 @@ class Deck extends BaseItem {
48267
48270
  apply(op) {
48268
48271
  super.apply(op);
48269
48272
  if (op.class === "Deck") {
48273
+ if (op.method === "startAnimation" && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 4000) {
48274
+ this.startAnimation();
48275
+ setTimeout(() => {
48276
+ this.stopAnimation();
48277
+ }, 2000);
48278
+ }
48270
48279
  this.isCacheDirty = true;
48271
48280
  }
48272
48281
  this.subject.publish(this);
@@ -48291,6 +48300,7 @@ class Deck extends BaseItem {
48291
48300
  return this;
48292
48301
  }
48293
48302
  render(context) {
48303
+ this.drawingContext = context;
48294
48304
  if (this.transformationRenderBlock) {
48295
48305
  return;
48296
48306
  }
@@ -48302,9 +48312,42 @@ class Deck extends BaseItem {
48302
48312
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48303
48313
  ctx.save();
48304
48314
  ctx.drawImage(this.cachedCanvas, this.left, this.top);
48315
+ if (this.animationFrameId) {
48316
+ const now = Date.now();
48317
+ const progress = now % 2000 / 2000;
48318
+ const yPos = this.top + this.getHeight() * Math.abs(Math.sin(progress * Math.PI));
48319
+ ctx.fillStyle = conf.SELECTION_COLOR;
48320
+ ctx.fillRect(this.left, yPos - 2, this.getWidth(), 4);
48321
+ }
48305
48322
  ctx.restore();
48306
48323
  }
48307
48324
  }
48325
+ emitAnimation() {
48326
+ this.emit({
48327
+ class: "Deck",
48328
+ method: "startAnimation",
48329
+ item: [this.getId()],
48330
+ newData: { timeStamp: Date.now() }
48331
+ });
48332
+ }
48333
+ startAnimation() {
48334
+ if (!this.animationFrameId) {
48335
+ const animate = () => {
48336
+ if (this.drawingContext) {
48337
+ this.subject.publish(this);
48338
+ this.animationFrameId = requestAnimationFrame(animate);
48339
+ }
48340
+ };
48341
+ this.animationFrameId = requestAnimationFrame(animate);
48342
+ }
48343
+ }
48344
+ stopAnimation() {
48345
+ if (this.animationFrameId) {
48346
+ cancelAnimationFrame(this.animationFrameId);
48347
+ this.animationFrameId = undefined;
48348
+ this.drawingContext = null;
48349
+ }
48350
+ }
48308
48351
  renderHTML(documentFactory) {
48309
48352
  const div = super.renderHTML(documentFactory);
48310
48353
  const cards = this.index?.list();
package/dist/cjs/index.js CHANGED
@@ -48141,6 +48141,8 @@ class Deck extends BaseItem {
48141
48141
  resizeEnabled = false;
48142
48142
  path = null;
48143
48143
  isPerpendicular = undefined;
48144
+ animationFrameId;
48145
+ drawingContext = null;
48144
48146
  constructor(board, id = "") {
48145
48147
  super(board, id, defaultDeckData, true);
48146
48148
  this.index.getUnderPoint = () => [];
@@ -48251,6 +48253,7 @@ class Deck extends BaseItem {
48251
48253
  const j = Math.floor(Math.random() * (i + 1));
48252
48254
  [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
48253
48255
  }
48256
+ this.emitAnimation();
48254
48257
  this.removeChildItems(this.index.list());
48255
48258
  this.addChildItems(shuffled);
48256
48259
  }
@@ -48267,6 +48270,12 @@ class Deck extends BaseItem {
48267
48270
  apply(op) {
48268
48271
  super.apply(op);
48269
48272
  if (op.class === "Deck") {
48273
+ if (op.method === "startAnimation" && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 4000) {
48274
+ this.startAnimation();
48275
+ setTimeout(() => {
48276
+ this.stopAnimation();
48277
+ }, 2000);
48278
+ }
48270
48279
  this.isCacheDirty = true;
48271
48280
  }
48272
48281
  this.subject.publish(this);
@@ -48291,6 +48300,7 @@ class Deck extends BaseItem {
48291
48300
  return this;
48292
48301
  }
48293
48302
  render(context) {
48303
+ this.drawingContext = context;
48294
48304
  if (this.transformationRenderBlock) {
48295
48305
  return;
48296
48306
  }
@@ -48302,9 +48312,42 @@ class Deck extends BaseItem {
48302
48312
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48303
48313
  ctx.save();
48304
48314
  ctx.drawImage(this.cachedCanvas, this.left, this.top);
48315
+ if (this.animationFrameId) {
48316
+ const now = Date.now();
48317
+ const progress = now % 2000 / 2000;
48318
+ const yPos = this.top + this.getHeight() * Math.abs(Math.sin(progress * Math.PI));
48319
+ ctx.fillStyle = conf.SELECTION_COLOR;
48320
+ ctx.fillRect(this.left, yPos - 2, this.getWidth(), 4);
48321
+ }
48305
48322
  ctx.restore();
48306
48323
  }
48307
48324
  }
48325
+ emitAnimation() {
48326
+ this.emit({
48327
+ class: "Deck",
48328
+ method: "startAnimation",
48329
+ item: [this.getId()],
48330
+ newData: { timeStamp: Date.now() }
48331
+ });
48332
+ }
48333
+ startAnimation() {
48334
+ if (!this.animationFrameId) {
48335
+ const animate = () => {
48336
+ if (this.drawingContext) {
48337
+ this.subject.publish(this);
48338
+ this.animationFrameId = requestAnimationFrame(animate);
48339
+ }
48340
+ };
48341
+ this.animationFrameId = requestAnimationFrame(animate);
48342
+ }
48343
+ }
48344
+ stopAnimation() {
48345
+ if (this.animationFrameId) {
48346
+ cancelAnimationFrame(this.animationFrameId);
48347
+ this.animationFrameId = undefined;
48348
+ this.drawingContext = null;
48349
+ }
48350
+ }
48308
48351
  renderHTML(documentFactory) {
48309
48352
  const div = super.renderHTML(documentFactory);
48310
48353
  const cards = this.index?.list();
package/dist/cjs/node.js CHANGED
@@ -50614,6 +50614,8 @@ class Deck extends BaseItem {
50614
50614
  resizeEnabled = false;
50615
50615
  path = null;
50616
50616
  isPerpendicular = undefined;
50617
+ animationFrameId;
50618
+ drawingContext = null;
50617
50619
  constructor(board, id = "") {
50618
50620
  super(board, id, defaultDeckData, true);
50619
50621
  this.index.getUnderPoint = () => [];
@@ -50724,6 +50726,7 @@ class Deck extends BaseItem {
50724
50726
  const j = Math.floor(Math.random() * (i + 1));
50725
50727
  [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
50726
50728
  }
50729
+ this.emitAnimation();
50727
50730
  this.removeChildItems(this.index.list());
50728
50731
  this.addChildItems(shuffled);
50729
50732
  }
@@ -50740,6 +50743,12 @@ class Deck extends BaseItem {
50740
50743
  apply(op) {
50741
50744
  super.apply(op);
50742
50745
  if (op.class === "Deck") {
50746
+ if (op.method === "startAnimation" && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 4000) {
50747
+ this.startAnimation();
50748
+ setTimeout(() => {
50749
+ this.stopAnimation();
50750
+ }, 2000);
50751
+ }
50743
50752
  this.isCacheDirty = true;
50744
50753
  }
50745
50754
  this.subject.publish(this);
@@ -50764,6 +50773,7 @@ class Deck extends BaseItem {
50764
50773
  return this;
50765
50774
  }
50766
50775
  render(context) {
50776
+ this.drawingContext = context;
50767
50777
  if (this.transformationRenderBlock) {
50768
50778
  return;
50769
50779
  }
@@ -50775,9 +50785,42 @@ class Deck extends BaseItem {
50775
50785
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
50776
50786
  ctx.save();
50777
50787
  ctx.drawImage(this.cachedCanvas, this.left, this.top);
50788
+ if (this.animationFrameId) {
50789
+ const now = Date.now();
50790
+ const progress = now % 2000 / 2000;
50791
+ const yPos = this.top + this.getHeight() * Math.abs(Math.sin(progress * Math.PI));
50792
+ ctx.fillStyle = conf.SELECTION_COLOR;
50793
+ ctx.fillRect(this.left, yPos - 2, this.getWidth(), 4);
50794
+ }
50778
50795
  ctx.restore();
50779
50796
  }
50780
50797
  }
50798
+ emitAnimation() {
50799
+ this.emit({
50800
+ class: "Deck",
50801
+ method: "startAnimation",
50802
+ item: [this.getId()],
50803
+ newData: { timeStamp: Date.now() }
50804
+ });
50805
+ }
50806
+ startAnimation() {
50807
+ if (!this.animationFrameId) {
50808
+ const animate = () => {
50809
+ if (this.drawingContext) {
50810
+ this.subject.publish(this);
50811
+ this.animationFrameId = requestAnimationFrame(animate);
50812
+ }
50813
+ };
50814
+ this.animationFrameId = requestAnimationFrame(animate);
50815
+ }
50816
+ }
50817
+ stopAnimation() {
50818
+ if (this.animationFrameId) {
50819
+ cancelAnimationFrame(this.animationFrameId);
50820
+ this.animationFrameId = undefined;
50821
+ this.drawingContext = null;
50822
+ }
50823
+ }
50781
50824
  renderHTML(documentFactory) {
50782
50825
  const div = super.renderHTML(documentFactory);
50783
50826
  const cards = this.index?.list();
@@ -47987,6 +47987,8 @@ class Deck extends BaseItem {
47987
47987
  resizeEnabled = false;
47988
47988
  path = null;
47989
47989
  isPerpendicular = undefined;
47990
+ animationFrameId;
47991
+ drawingContext = null;
47990
47992
  constructor(board, id = "") {
47991
47993
  super(board, id, defaultDeckData, true);
47992
47994
  this.index.getUnderPoint = () => [];
@@ -48097,6 +48099,7 @@ class Deck extends BaseItem {
48097
48099
  const j = Math.floor(Math.random() * (i + 1));
48098
48100
  [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
48099
48101
  }
48102
+ this.emitAnimation();
48100
48103
  this.removeChildItems(this.index.list());
48101
48104
  this.addChildItems(shuffled);
48102
48105
  }
@@ -48113,6 +48116,12 @@ class Deck extends BaseItem {
48113
48116
  apply(op) {
48114
48117
  super.apply(op);
48115
48118
  if (op.class === "Deck") {
48119
+ if (op.method === "startAnimation" && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 4000) {
48120
+ this.startAnimation();
48121
+ setTimeout(() => {
48122
+ this.stopAnimation();
48123
+ }, 2000);
48124
+ }
48116
48125
  this.isCacheDirty = true;
48117
48126
  }
48118
48127
  this.subject.publish(this);
@@ -48137,6 +48146,7 @@ class Deck extends BaseItem {
48137
48146
  return this;
48138
48147
  }
48139
48148
  render(context) {
48149
+ this.drawingContext = context;
48140
48150
  if (this.transformationRenderBlock) {
48141
48151
  return;
48142
48152
  }
@@ -48148,9 +48158,42 @@ class Deck extends BaseItem {
48148
48158
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48149
48159
  ctx.save();
48150
48160
  ctx.drawImage(this.cachedCanvas, this.left, this.top);
48161
+ if (this.animationFrameId) {
48162
+ const now = Date.now();
48163
+ const progress = now % 2000 / 2000;
48164
+ const yPos = this.top + this.getHeight() * Math.abs(Math.sin(progress * Math.PI));
48165
+ ctx.fillStyle = conf.SELECTION_COLOR;
48166
+ ctx.fillRect(this.left, yPos - 2, this.getWidth(), 4);
48167
+ }
48151
48168
  ctx.restore();
48152
48169
  }
48153
48170
  }
48171
+ emitAnimation() {
48172
+ this.emit({
48173
+ class: "Deck",
48174
+ method: "startAnimation",
48175
+ item: [this.getId()],
48176
+ newData: { timeStamp: Date.now() }
48177
+ });
48178
+ }
48179
+ startAnimation() {
48180
+ if (!this.animationFrameId) {
48181
+ const animate = () => {
48182
+ if (this.drawingContext) {
48183
+ this.subject.publish(this);
48184
+ this.animationFrameId = requestAnimationFrame(animate);
48185
+ }
48186
+ };
48187
+ this.animationFrameId = requestAnimationFrame(animate);
48188
+ }
48189
+ }
48190
+ stopAnimation() {
48191
+ if (this.animationFrameId) {
48192
+ cancelAnimationFrame(this.animationFrameId);
48193
+ this.animationFrameId = undefined;
48194
+ this.drawingContext = null;
48195
+ }
48196
+ }
48154
48197
  renderHTML(documentFactory) {
48155
48198
  const div = super.renderHTML(documentFactory);
48156
48199
  const cards = this.index?.list();
package/dist/esm/index.js CHANGED
@@ -47980,6 +47980,8 @@ class Deck extends BaseItem {
47980
47980
  resizeEnabled = false;
47981
47981
  path = null;
47982
47982
  isPerpendicular = undefined;
47983
+ animationFrameId;
47984
+ drawingContext = null;
47983
47985
  constructor(board, id = "") {
47984
47986
  super(board, id, defaultDeckData, true);
47985
47987
  this.index.getUnderPoint = () => [];
@@ -48090,6 +48092,7 @@ class Deck extends BaseItem {
48090
48092
  const j = Math.floor(Math.random() * (i + 1));
48091
48093
  [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
48092
48094
  }
48095
+ this.emitAnimation();
48093
48096
  this.removeChildItems(this.index.list());
48094
48097
  this.addChildItems(shuffled);
48095
48098
  }
@@ -48106,6 +48109,12 @@ class Deck extends BaseItem {
48106
48109
  apply(op) {
48107
48110
  super.apply(op);
48108
48111
  if (op.class === "Deck") {
48112
+ if (op.method === "startAnimation" && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 4000) {
48113
+ this.startAnimation();
48114
+ setTimeout(() => {
48115
+ this.stopAnimation();
48116
+ }, 2000);
48117
+ }
48109
48118
  this.isCacheDirty = true;
48110
48119
  }
48111
48120
  this.subject.publish(this);
@@ -48130,6 +48139,7 @@ class Deck extends BaseItem {
48130
48139
  return this;
48131
48140
  }
48132
48141
  render(context) {
48142
+ this.drawingContext = context;
48133
48143
  if (this.transformationRenderBlock) {
48134
48144
  return;
48135
48145
  }
@@ -48141,9 +48151,42 @@ class Deck extends BaseItem {
48141
48151
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48142
48152
  ctx.save();
48143
48153
  ctx.drawImage(this.cachedCanvas, this.left, this.top);
48154
+ if (this.animationFrameId) {
48155
+ const now = Date.now();
48156
+ const progress = now % 2000 / 2000;
48157
+ const yPos = this.top + this.getHeight() * Math.abs(Math.sin(progress * Math.PI));
48158
+ ctx.fillStyle = conf.SELECTION_COLOR;
48159
+ ctx.fillRect(this.left, yPos - 2, this.getWidth(), 4);
48160
+ }
48144
48161
  ctx.restore();
48145
48162
  }
48146
48163
  }
48164
+ emitAnimation() {
48165
+ this.emit({
48166
+ class: "Deck",
48167
+ method: "startAnimation",
48168
+ item: [this.getId()],
48169
+ newData: { timeStamp: Date.now() }
48170
+ });
48171
+ }
48172
+ startAnimation() {
48173
+ if (!this.animationFrameId) {
48174
+ const animate = () => {
48175
+ if (this.drawingContext) {
48176
+ this.subject.publish(this);
48177
+ this.animationFrameId = requestAnimationFrame(animate);
48178
+ }
48179
+ };
48180
+ this.animationFrameId = requestAnimationFrame(animate);
48181
+ }
48182
+ }
48183
+ stopAnimation() {
48184
+ if (this.animationFrameId) {
48185
+ cancelAnimationFrame(this.animationFrameId);
48186
+ this.animationFrameId = undefined;
48187
+ this.drawingContext = null;
48188
+ }
48189
+ }
48147
48190
  renderHTML(documentFactory) {
48148
48191
  const div = super.renderHTML(documentFactory);
48149
48192
  const cards = this.index?.list();
package/dist/esm/node.js CHANGED
@@ -50448,6 +50448,8 @@ class Deck extends BaseItem {
50448
50448
  resizeEnabled = false;
50449
50449
  path = null;
50450
50450
  isPerpendicular = undefined;
50451
+ animationFrameId;
50452
+ drawingContext = null;
50451
50453
  constructor(board, id = "") {
50452
50454
  super(board, id, defaultDeckData, true);
50453
50455
  this.index.getUnderPoint = () => [];
@@ -50558,6 +50560,7 @@ class Deck extends BaseItem {
50558
50560
  const j = Math.floor(Math.random() * (i + 1));
50559
50561
  [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
50560
50562
  }
50563
+ this.emitAnimation();
50561
50564
  this.removeChildItems(this.index.list());
50562
50565
  this.addChildItems(shuffled);
50563
50566
  }
@@ -50574,6 +50577,12 @@ class Deck extends BaseItem {
50574
50577
  apply(op) {
50575
50578
  super.apply(op);
50576
50579
  if (op.class === "Deck") {
50580
+ if (op.method === "startAnimation" && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 4000) {
50581
+ this.startAnimation();
50582
+ setTimeout(() => {
50583
+ this.stopAnimation();
50584
+ }, 2000);
50585
+ }
50577
50586
  this.isCacheDirty = true;
50578
50587
  }
50579
50588
  this.subject.publish(this);
@@ -50598,6 +50607,7 @@ class Deck extends BaseItem {
50598
50607
  return this;
50599
50608
  }
50600
50609
  render(context) {
50610
+ this.drawingContext = context;
50601
50611
  if (this.transformationRenderBlock) {
50602
50612
  return;
50603
50613
  }
@@ -50609,9 +50619,42 @@ class Deck extends BaseItem {
50609
50619
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
50610
50620
  ctx.save();
50611
50621
  ctx.drawImage(this.cachedCanvas, this.left, this.top);
50622
+ if (this.animationFrameId) {
50623
+ const now = Date.now();
50624
+ const progress = now % 2000 / 2000;
50625
+ const yPos = this.top + this.getHeight() * Math.abs(Math.sin(progress * Math.PI));
50626
+ ctx.fillStyle = conf.SELECTION_COLOR;
50627
+ ctx.fillRect(this.left, yPos - 2, this.getWidth(), 4);
50628
+ }
50612
50629
  ctx.restore();
50613
50630
  }
50614
50631
  }
50632
+ emitAnimation() {
50633
+ this.emit({
50634
+ class: "Deck",
50635
+ method: "startAnimation",
50636
+ item: [this.getId()],
50637
+ newData: { timeStamp: Date.now() }
50638
+ });
50639
+ }
50640
+ startAnimation() {
50641
+ if (!this.animationFrameId) {
50642
+ const animate = () => {
50643
+ if (this.drawingContext) {
50644
+ this.subject.publish(this);
50645
+ this.animationFrameId = requestAnimationFrame(animate);
50646
+ }
50647
+ };
50648
+ this.animationFrameId = requestAnimationFrame(animate);
50649
+ }
50650
+ }
50651
+ stopAnimation() {
50652
+ if (this.animationFrameId) {
50653
+ cancelAnimationFrame(this.animationFrameId);
50654
+ this.animationFrameId = undefined;
50655
+ this.drawingContext = null;
50656
+ }
50657
+ }
50615
50658
  renderHTML(documentFactory) {
50616
50659
  const div = super.renderHTML(documentFactory);
50617
50660
  const cards = this.index?.list();
@@ -15,6 +15,8 @@ export declare class Deck extends BaseItem {
15
15
  resizeEnabled: boolean;
16
16
  path: Path | null;
17
17
  private isPerpendicular;
18
+ private animationFrameId?;
19
+ drawingContext: DrawingContext | null;
18
20
  constructor(board: Board, id?: string);
19
21
  getIsPerpendicular(): boolean | undefined;
20
22
  applyAddChildren(childIds: string[]): void;
@@ -29,6 +31,9 @@ export declare class Deck extends BaseItem {
29
31
  updateMbr(): void;
30
32
  deserialize(data: SerializedItemData): this;
31
33
  render(context: DrawingContext): void;
34
+ emitAnimation(): void;
35
+ startAnimation(): void;
36
+ stopAnimation(): void;
32
37
  renderHTML(documentFactory: DocumentFactory): HTMLElement;
33
38
  private updateCache;
34
39
  getFirstCard(): Card | undefined;
@@ -1,15 +1,8 @@
1
1
  import { BaseOperation } from "../../../../Events/EventsOperations";
2
- export type DeckOperation = AddCards | RemoveCards;
3
- export interface AddCards extends BaseOperation<{
4
- cardIds: string[];
5
- shouldReplaceExistingCards: boolean;
2
+ export type DeckOperation = StartAnimation;
3
+ export interface StartAnimation extends BaseOperation<{
4
+ timeStamp?: number;
6
5
  }> {
7
6
  class: "Deck";
8
- method: "addCards";
9
- }
10
- export interface RemoveCards extends BaseOperation<{
11
- cardIds: string[];
12
- }> {
13
- class: "Deck";
14
- method: "removeCards";
7
+ method: "startAnimation";
15
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.53",
3
+ "version": "0.5.55",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",