microboard-temp 0.4.19 → 0.4.21
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/dist/cjs/browser.js +11 -27
- package/dist/cjs/index.js +11 -27
- package/dist/cjs/node.js +11 -27
- package/dist/esm/browser.js +11 -27
- package/dist/esm/index.js +11 -27
- package/dist/esm/node.js +11 -27
- package/dist/types/Items/Examples/CardGame/Dice/Dice.d.ts +1 -2
- package/dist/types/Items/Examples/CardGame/Dice/DiceOperation.d.ts +3 -7
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -46288,10 +46288,6 @@ class Dice extends BaseItem {
|
|
|
46288
46288
|
context.ctx.textAlign = "center";
|
|
46289
46289
|
context.ctx.textBaseline = "middle";
|
|
46290
46290
|
context.ctx.fillText(String(this.value), centerX, centerY);
|
|
46291
|
-
if (this.getLinkTo()) {
|
|
46292
|
-
const { top, right } = this.getMbr();
|
|
46293
|
-
this.linkTo.render(context, top, right, this.board.camera.getScale());
|
|
46294
|
-
}
|
|
46295
46291
|
context.ctx.restore();
|
|
46296
46292
|
}
|
|
46297
46293
|
updateMbr() {
|
|
@@ -46314,8 +46310,8 @@ class Dice extends BaseItem {
|
|
|
46314
46310
|
this.subject.publish(this);
|
|
46315
46311
|
return this;
|
|
46316
46312
|
}
|
|
46317
|
-
|
|
46318
|
-
return
|
|
46313
|
+
getIsRotating() {
|
|
46314
|
+
return !!this.animationFrameId;
|
|
46319
46315
|
}
|
|
46320
46316
|
applyBackgroundColor(backgroundColor) {
|
|
46321
46317
|
this.backgroundColor = backgroundColor;
|
|
@@ -46370,24 +46366,12 @@ class Dice extends BaseItem {
|
|
|
46370
46366
|
class: "Dice",
|
|
46371
46367
|
method: "changeValue",
|
|
46372
46368
|
item: [this.getId()],
|
|
46373
|
-
newData: { value },
|
|
46374
|
-
prevData: { value: this.value }
|
|
46375
|
-
});
|
|
46376
|
-
}
|
|
46377
|
-
setIsRotating(isRotating) {
|
|
46378
|
-
this.emit({
|
|
46379
|
-
class: "Dice",
|
|
46380
|
-
method: "setIsRotating",
|
|
46381
|
-
item: [this.getId()],
|
|
46382
|
-
newData: { isRotating },
|
|
46383
|
-
prevData: { isRotating: false }
|
|
46369
|
+
newData: { value, shouldRotate: true, timeStamp: Date.now() },
|
|
46370
|
+
prevData: { value: this.value, shouldRotate: false }
|
|
46384
46371
|
});
|
|
46385
46372
|
}
|
|
46386
46373
|
throwDice() {
|
|
46387
|
-
this.
|
|
46388
|
-
setTimeout(() => {
|
|
46389
|
-
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46390
|
-
}, TIMEOUT);
|
|
46374
|
+
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46391
46375
|
}
|
|
46392
46376
|
apply(op) {
|
|
46393
46377
|
super.apply(op);
|
|
@@ -46403,17 +46387,17 @@ class Dice extends BaseItem {
|
|
|
46403
46387
|
case "setBorderColor":
|
|
46404
46388
|
this.applyBorderColor(op.newData.borderColor);
|
|
46405
46389
|
break;
|
|
46406
|
-
case "
|
|
46407
|
-
if (op.newData.
|
|
46390
|
+
case "changeValue":
|
|
46391
|
+
if (op.newData.shouldRotate && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 1e4) {
|
|
46408
46392
|
this.startRotation();
|
|
46409
46393
|
setTimeout(() => {
|
|
46410
46394
|
this.stopRotation();
|
|
46395
|
+
this.value = op.newData.value;
|
|
46411
46396
|
}, TIMEOUT);
|
|
46397
|
+
} else {
|
|
46398
|
+
this.value = op.newData.value;
|
|
46412
46399
|
}
|
|
46413
46400
|
break;
|
|
46414
|
-
case "changeValue":
|
|
46415
|
-
this.value = op.newData.value;
|
|
46416
|
-
break;
|
|
46417
46401
|
case "changeValuesRange":
|
|
46418
46402
|
this.range = op.newData;
|
|
46419
46403
|
break;
|
|
@@ -46426,7 +46410,7 @@ class Dice extends BaseItem {
|
|
|
46426
46410
|
if (!this.animationFrameId) {
|
|
46427
46411
|
const animate = () => {
|
|
46428
46412
|
if (this.drawingContext) {
|
|
46429
|
-
this.
|
|
46413
|
+
this.subject.publish(this);
|
|
46430
46414
|
this.animationFrameId = requestAnimationFrame(animate);
|
|
46431
46415
|
}
|
|
46432
46416
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -46288,10 +46288,6 @@ class Dice extends BaseItem {
|
|
|
46288
46288
|
context.ctx.textAlign = "center";
|
|
46289
46289
|
context.ctx.textBaseline = "middle";
|
|
46290
46290
|
context.ctx.fillText(String(this.value), centerX, centerY);
|
|
46291
|
-
if (this.getLinkTo()) {
|
|
46292
|
-
const { top, right } = this.getMbr();
|
|
46293
|
-
this.linkTo.render(context, top, right, this.board.camera.getScale());
|
|
46294
|
-
}
|
|
46295
46291
|
context.ctx.restore();
|
|
46296
46292
|
}
|
|
46297
46293
|
updateMbr() {
|
|
@@ -46314,8 +46310,8 @@ class Dice extends BaseItem {
|
|
|
46314
46310
|
this.subject.publish(this);
|
|
46315
46311
|
return this;
|
|
46316
46312
|
}
|
|
46317
|
-
|
|
46318
|
-
return
|
|
46313
|
+
getIsRotating() {
|
|
46314
|
+
return !!this.animationFrameId;
|
|
46319
46315
|
}
|
|
46320
46316
|
applyBackgroundColor(backgroundColor) {
|
|
46321
46317
|
this.backgroundColor = backgroundColor;
|
|
@@ -46370,24 +46366,12 @@ class Dice extends BaseItem {
|
|
|
46370
46366
|
class: "Dice",
|
|
46371
46367
|
method: "changeValue",
|
|
46372
46368
|
item: [this.getId()],
|
|
46373
|
-
newData: { value },
|
|
46374
|
-
prevData: { value: this.value }
|
|
46375
|
-
});
|
|
46376
|
-
}
|
|
46377
|
-
setIsRotating(isRotating) {
|
|
46378
|
-
this.emit({
|
|
46379
|
-
class: "Dice",
|
|
46380
|
-
method: "setIsRotating",
|
|
46381
|
-
item: [this.getId()],
|
|
46382
|
-
newData: { isRotating },
|
|
46383
|
-
prevData: { isRotating: false }
|
|
46369
|
+
newData: { value, shouldRotate: true, timeStamp: Date.now() },
|
|
46370
|
+
prevData: { value: this.value, shouldRotate: false }
|
|
46384
46371
|
});
|
|
46385
46372
|
}
|
|
46386
46373
|
throwDice() {
|
|
46387
|
-
this.
|
|
46388
|
-
setTimeout(() => {
|
|
46389
|
-
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46390
|
-
}, TIMEOUT);
|
|
46374
|
+
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46391
46375
|
}
|
|
46392
46376
|
apply(op) {
|
|
46393
46377
|
super.apply(op);
|
|
@@ -46403,17 +46387,17 @@ class Dice extends BaseItem {
|
|
|
46403
46387
|
case "setBorderColor":
|
|
46404
46388
|
this.applyBorderColor(op.newData.borderColor);
|
|
46405
46389
|
break;
|
|
46406
|
-
case "
|
|
46407
|
-
if (op.newData.
|
|
46390
|
+
case "changeValue":
|
|
46391
|
+
if (op.newData.shouldRotate && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 1e4) {
|
|
46408
46392
|
this.startRotation();
|
|
46409
46393
|
setTimeout(() => {
|
|
46410
46394
|
this.stopRotation();
|
|
46395
|
+
this.value = op.newData.value;
|
|
46411
46396
|
}, TIMEOUT);
|
|
46397
|
+
} else {
|
|
46398
|
+
this.value = op.newData.value;
|
|
46412
46399
|
}
|
|
46413
46400
|
break;
|
|
46414
|
-
case "changeValue":
|
|
46415
|
-
this.value = op.newData.value;
|
|
46416
|
-
break;
|
|
46417
46401
|
case "changeValuesRange":
|
|
46418
46402
|
this.range = op.newData;
|
|
46419
46403
|
break;
|
|
@@ -46426,7 +46410,7 @@ class Dice extends BaseItem {
|
|
|
46426
46410
|
if (!this.animationFrameId) {
|
|
46427
46411
|
const animate = () => {
|
|
46428
46412
|
if (this.drawingContext) {
|
|
46429
|
-
this.
|
|
46413
|
+
this.subject.publish(this);
|
|
46430
46414
|
this.animationFrameId = requestAnimationFrame(animate);
|
|
46431
46415
|
}
|
|
46432
46416
|
};
|
package/dist/cjs/node.js
CHANGED
|
@@ -48828,10 +48828,6 @@ class Dice extends BaseItem {
|
|
|
48828
48828
|
context.ctx.textAlign = "center";
|
|
48829
48829
|
context.ctx.textBaseline = "middle";
|
|
48830
48830
|
context.ctx.fillText(String(this.value), centerX, centerY);
|
|
48831
|
-
if (this.getLinkTo()) {
|
|
48832
|
-
const { top, right } = this.getMbr();
|
|
48833
|
-
this.linkTo.render(context, top, right, this.board.camera.getScale());
|
|
48834
|
-
}
|
|
48835
48831
|
context.ctx.restore();
|
|
48836
48832
|
}
|
|
48837
48833
|
updateMbr() {
|
|
@@ -48854,8 +48850,8 @@ class Dice extends BaseItem {
|
|
|
48854
48850
|
this.subject.publish(this);
|
|
48855
48851
|
return this;
|
|
48856
48852
|
}
|
|
48857
|
-
|
|
48858
|
-
return
|
|
48853
|
+
getIsRotating() {
|
|
48854
|
+
return !!this.animationFrameId;
|
|
48859
48855
|
}
|
|
48860
48856
|
applyBackgroundColor(backgroundColor) {
|
|
48861
48857
|
this.backgroundColor = backgroundColor;
|
|
@@ -48910,24 +48906,12 @@ class Dice extends BaseItem {
|
|
|
48910
48906
|
class: "Dice",
|
|
48911
48907
|
method: "changeValue",
|
|
48912
48908
|
item: [this.getId()],
|
|
48913
|
-
newData: { value },
|
|
48914
|
-
prevData: { value: this.value }
|
|
48915
|
-
});
|
|
48916
|
-
}
|
|
48917
|
-
setIsRotating(isRotating) {
|
|
48918
|
-
this.emit({
|
|
48919
|
-
class: "Dice",
|
|
48920
|
-
method: "setIsRotating",
|
|
48921
|
-
item: [this.getId()],
|
|
48922
|
-
newData: { isRotating },
|
|
48923
|
-
prevData: { isRotating: false }
|
|
48909
|
+
newData: { value, shouldRotate: true, timeStamp: Date.now() },
|
|
48910
|
+
prevData: { value: this.value, shouldRotate: false }
|
|
48924
48911
|
});
|
|
48925
48912
|
}
|
|
48926
48913
|
throwDice() {
|
|
48927
|
-
this.
|
|
48928
|
-
setTimeout(() => {
|
|
48929
|
-
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
48930
|
-
}, TIMEOUT);
|
|
48914
|
+
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
48931
48915
|
}
|
|
48932
48916
|
apply(op) {
|
|
48933
48917
|
super.apply(op);
|
|
@@ -48943,17 +48927,17 @@ class Dice extends BaseItem {
|
|
|
48943
48927
|
case "setBorderColor":
|
|
48944
48928
|
this.applyBorderColor(op.newData.borderColor);
|
|
48945
48929
|
break;
|
|
48946
|
-
case "
|
|
48947
|
-
if (op.newData.
|
|
48930
|
+
case "changeValue":
|
|
48931
|
+
if (op.newData.shouldRotate && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 1e4) {
|
|
48948
48932
|
this.startRotation();
|
|
48949
48933
|
setTimeout(() => {
|
|
48950
48934
|
this.stopRotation();
|
|
48935
|
+
this.value = op.newData.value;
|
|
48951
48936
|
}, TIMEOUT);
|
|
48937
|
+
} else {
|
|
48938
|
+
this.value = op.newData.value;
|
|
48952
48939
|
}
|
|
48953
48940
|
break;
|
|
48954
|
-
case "changeValue":
|
|
48955
|
-
this.value = op.newData.value;
|
|
48956
|
-
break;
|
|
48957
48941
|
case "changeValuesRange":
|
|
48958
48942
|
this.range = op.newData;
|
|
48959
48943
|
break;
|
|
@@ -48966,7 +48950,7 @@ class Dice extends BaseItem {
|
|
|
48966
48950
|
if (!this.animationFrameId) {
|
|
48967
48951
|
const animate = () => {
|
|
48968
48952
|
if (this.drawingContext) {
|
|
48969
|
-
this.
|
|
48953
|
+
this.subject.publish(this);
|
|
48970
48954
|
this.animationFrameId = requestAnimationFrame(animate);
|
|
48971
48955
|
}
|
|
48972
48956
|
};
|
package/dist/esm/browser.js
CHANGED
|
@@ -46138,10 +46138,6 @@ class Dice extends BaseItem {
|
|
|
46138
46138
|
context.ctx.textAlign = "center";
|
|
46139
46139
|
context.ctx.textBaseline = "middle";
|
|
46140
46140
|
context.ctx.fillText(String(this.value), centerX, centerY);
|
|
46141
|
-
if (this.getLinkTo()) {
|
|
46142
|
-
const { top, right } = this.getMbr();
|
|
46143
|
-
this.linkTo.render(context, top, right, this.board.camera.getScale());
|
|
46144
|
-
}
|
|
46145
46141
|
context.ctx.restore();
|
|
46146
46142
|
}
|
|
46147
46143
|
updateMbr() {
|
|
@@ -46164,8 +46160,8 @@ class Dice extends BaseItem {
|
|
|
46164
46160
|
this.subject.publish(this);
|
|
46165
46161
|
return this;
|
|
46166
46162
|
}
|
|
46167
|
-
|
|
46168
|
-
return
|
|
46163
|
+
getIsRotating() {
|
|
46164
|
+
return !!this.animationFrameId;
|
|
46169
46165
|
}
|
|
46170
46166
|
applyBackgroundColor(backgroundColor) {
|
|
46171
46167
|
this.backgroundColor = backgroundColor;
|
|
@@ -46220,24 +46216,12 @@ class Dice extends BaseItem {
|
|
|
46220
46216
|
class: "Dice",
|
|
46221
46217
|
method: "changeValue",
|
|
46222
46218
|
item: [this.getId()],
|
|
46223
|
-
newData: { value },
|
|
46224
|
-
prevData: { value: this.value }
|
|
46225
|
-
});
|
|
46226
|
-
}
|
|
46227
|
-
setIsRotating(isRotating) {
|
|
46228
|
-
this.emit({
|
|
46229
|
-
class: "Dice",
|
|
46230
|
-
method: "setIsRotating",
|
|
46231
|
-
item: [this.getId()],
|
|
46232
|
-
newData: { isRotating },
|
|
46233
|
-
prevData: { isRotating: false }
|
|
46219
|
+
newData: { value, shouldRotate: true, timeStamp: Date.now() },
|
|
46220
|
+
prevData: { value: this.value, shouldRotate: false }
|
|
46234
46221
|
});
|
|
46235
46222
|
}
|
|
46236
46223
|
throwDice() {
|
|
46237
|
-
this.
|
|
46238
|
-
setTimeout(() => {
|
|
46239
|
-
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46240
|
-
}, TIMEOUT);
|
|
46224
|
+
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46241
46225
|
}
|
|
46242
46226
|
apply(op) {
|
|
46243
46227
|
super.apply(op);
|
|
@@ -46253,17 +46237,17 @@ class Dice extends BaseItem {
|
|
|
46253
46237
|
case "setBorderColor":
|
|
46254
46238
|
this.applyBorderColor(op.newData.borderColor);
|
|
46255
46239
|
break;
|
|
46256
|
-
case "
|
|
46257
|
-
if (op.newData.
|
|
46240
|
+
case "changeValue":
|
|
46241
|
+
if (op.newData.shouldRotate && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 1e4) {
|
|
46258
46242
|
this.startRotation();
|
|
46259
46243
|
setTimeout(() => {
|
|
46260
46244
|
this.stopRotation();
|
|
46245
|
+
this.value = op.newData.value;
|
|
46261
46246
|
}, TIMEOUT);
|
|
46247
|
+
} else {
|
|
46248
|
+
this.value = op.newData.value;
|
|
46262
46249
|
}
|
|
46263
46250
|
break;
|
|
46264
|
-
case "changeValue":
|
|
46265
|
-
this.value = op.newData.value;
|
|
46266
|
-
break;
|
|
46267
46251
|
case "changeValuesRange":
|
|
46268
46252
|
this.range = op.newData;
|
|
46269
46253
|
break;
|
|
@@ -46276,7 +46260,7 @@ class Dice extends BaseItem {
|
|
|
46276
46260
|
if (!this.animationFrameId) {
|
|
46277
46261
|
const animate = () => {
|
|
46278
46262
|
if (this.drawingContext) {
|
|
46279
|
-
this.
|
|
46263
|
+
this.subject.publish(this);
|
|
46280
46264
|
this.animationFrameId = requestAnimationFrame(animate);
|
|
46281
46265
|
}
|
|
46282
46266
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -46131,10 +46131,6 @@ class Dice extends BaseItem {
|
|
|
46131
46131
|
context.ctx.textAlign = "center";
|
|
46132
46132
|
context.ctx.textBaseline = "middle";
|
|
46133
46133
|
context.ctx.fillText(String(this.value), centerX, centerY);
|
|
46134
|
-
if (this.getLinkTo()) {
|
|
46135
|
-
const { top, right } = this.getMbr();
|
|
46136
|
-
this.linkTo.render(context, top, right, this.board.camera.getScale());
|
|
46137
|
-
}
|
|
46138
46134
|
context.ctx.restore();
|
|
46139
46135
|
}
|
|
46140
46136
|
updateMbr() {
|
|
@@ -46157,8 +46153,8 @@ class Dice extends BaseItem {
|
|
|
46157
46153
|
this.subject.publish(this);
|
|
46158
46154
|
return this;
|
|
46159
46155
|
}
|
|
46160
|
-
|
|
46161
|
-
return
|
|
46156
|
+
getIsRotating() {
|
|
46157
|
+
return !!this.animationFrameId;
|
|
46162
46158
|
}
|
|
46163
46159
|
applyBackgroundColor(backgroundColor) {
|
|
46164
46160
|
this.backgroundColor = backgroundColor;
|
|
@@ -46213,24 +46209,12 @@ class Dice extends BaseItem {
|
|
|
46213
46209
|
class: "Dice",
|
|
46214
46210
|
method: "changeValue",
|
|
46215
46211
|
item: [this.getId()],
|
|
46216
|
-
newData: { value },
|
|
46217
|
-
prevData: { value: this.value }
|
|
46218
|
-
});
|
|
46219
|
-
}
|
|
46220
|
-
setIsRotating(isRotating) {
|
|
46221
|
-
this.emit({
|
|
46222
|
-
class: "Dice",
|
|
46223
|
-
method: "setIsRotating",
|
|
46224
|
-
item: [this.getId()],
|
|
46225
|
-
newData: { isRotating },
|
|
46226
|
-
prevData: { isRotating: false }
|
|
46212
|
+
newData: { value, shouldRotate: true, timeStamp: Date.now() },
|
|
46213
|
+
prevData: { value: this.value, shouldRotate: false }
|
|
46227
46214
|
});
|
|
46228
46215
|
}
|
|
46229
46216
|
throwDice() {
|
|
46230
|
-
this.
|
|
46231
|
-
setTimeout(() => {
|
|
46232
|
-
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46233
|
-
}, TIMEOUT);
|
|
46217
|
+
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46234
46218
|
}
|
|
46235
46219
|
apply(op) {
|
|
46236
46220
|
super.apply(op);
|
|
@@ -46246,17 +46230,17 @@ class Dice extends BaseItem {
|
|
|
46246
46230
|
case "setBorderColor":
|
|
46247
46231
|
this.applyBorderColor(op.newData.borderColor);
|
|
46248
46232
|
break;
|
|
46249
|
-
case "
|
|
46250
|
-
if (op.newData.
|
|
46233
|
+
case "changeValue":
|
|
46234
|
+
if (op.newData.shouldRotate && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 1e4) {
|
|
46251
46235
|
this.startRotation();
|
|
46252
46236
|
setTimeout(() => {
|
|
46253
46237
|
this.stopRotation();
|
|
46238
|
+
this.value = op.newData.value;
|
|
46254
46239
|
}, TIMEOUT);
|
|
46240
|
+
} else {
|
|
46241
|
+
this.value = op.newData.value;
|
|
46255
46242
|
}
|
|
46256
46243
|
break;
|
|
46257
|
-
case "changeValue":
|
|
46258
|
-
this.value = op.newData.value;
|
|
46259
|
-
break;
|
|
46260
46244
|
case "changeValuesRange":
|
|
46261
46245
|
this.range = op.newData;
|
|
46262
46246
|
break;
|
|
@@ -46269,7 +46253,7 @@ class Dice extends BaseItem {
|
|
|
46269
46253
|
if (!this.animationFrameId) {
|
|
46270
46254
|
const animate = () => {
|
|
46271
46255
|
if (this.drawingContext) {
|
|
46272
|
-
this.
|
|
46256
|
+
this.subject.publish(this);
|
|
46273
46257
|
this.animationFrameId = requestAnimationFrame(animate);
|
|
46274
46258
|
}
|
|
46275
46259
|
};
|
package/dist/esm/node.js
CHANGED
|
@@ -48666,10 +48666,6 @@ class Dice extends BaseItem {
|
|
|
48666
48666
|
context.ctx.textAlign = "center";
|
|
48667
48667
|
context.ctx.textBaseline = "middle";
|
|
48668
48668
|
context.ctx.fillText(String(this.value), centerX, centerY);
|
|
48669
|
-
if (this.getLinkTo()) {
|
|
48670
|
-
const { top, right } = this.getMbr();
|
|
48671
|
-
this.linkTo.render(context, top, right, this.board.camera.getScale());
|
|
48672
|
-
}
|
|
48673
48669
|
context.ctx.restore();
|
|
48674
48670
|
}
|
|
48675
48671
|
updateMbr() {
|
|
@@ -48692,8 +48688,8 @@ class Dice extends BaseItem {
|
|
|
48692
48688
|
this.subject.publish(this);
|
|
48693
48689
|
return this;
|
|
48694
48690
|
}
|
|
48695
|
-
|
|
48696
|
-
return
|
|
48691
|
+
getIsRotating() {
|
|
48692
|
+
return !!this.animationFrameId;
|
|
48697
48693
|
}
|
|
48698
48694
|
applyBackgroundColor(backgroundColor) {
|
|
48699
48695
|
this.backgroundColor = backgroundColor;
|
|
@@ -48748,24 +48744,12 @@ class Dice extends BaseItem {
|
|
|
48748
48744
|
class: "Dice",
|
|
48749
48745
|
method: "changeValue",
|
|
48750
48746
|
item: [this.getId()],
|
|
48751
|
-
newData: { value },
|
|
48752
|
-
prevData: { value: this.value }
|
|
48753
|
-
});
|
|
48754
|
-
}
|
|
48755
|
-
setIsRotating(isRotating) {
|
|
48756
|
-
this.emit({
|
|
48757
|
-
class: "Dice",
|
|
48758
|
-
method: "setIsRotating",
|
|
48759
|
-
item: [this.getId()],
|
|
48760
|
-
newData: { isRotating },
|
|
48761
|
-
prevData: { isRotating: false }
|
|
48747
|
+
newData: { value, shouldRotate: true, timeStamp: Date.now() },
|
|
48748
|
+
prevData: { value: this.value, shouldRotate: false }
|
|
48762
48749
|
});
|
|
48763
48750
|
}
|
|
48764
48751
|
throwDice() {
|
|
48765
|
-
this.
|
|
48766
|
-
setTimeout(() => {
|
|
48767
|
-
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
48768
|
-
}, TIMEOUT);
|
|
48752
|
+
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
48769
48753
|
}
|
|
48770
48754
|
apply(op) {
|
|
48771
48755
|
super.apply(op);
|
|
@@ -48781,17 +48765,17 @@ class Dice extends BaseItem {
|
|
|
48781
48765
|
case "setBorderColor":
|
|
48782
48766
|
this.applyBorderColor(op.newData.borderColor);
|
|
48783
48767
|
break;
|
|
48784
|
-
case "
|
|
48785
|
-
if (op.newData.
|
|
48768
|
+
case "changeValue":
|
|
48769
|
+
if (op.newData.shouldRotate && op.newData.timeStamp && Date.now() - op.newData.timeStamp < 1e4) {
|
|
48786
48770
|
this.startRotation();
|
|
48787
48771
|
setTimeout(() => {
|
|
48788
48772
|
this.stopRotation();
|
|
48773
|
+
this.value = op.newData.value;
|
|
48789
48774
|
}, TIMEOUT);
|
|
48775
|
+
} else {
|
|
48776
|
+
this.value = op.newData.value;
|
|
48790
48777
|
}
|
|
48791
48778
|
break;
|
|
48792
|
-
case "changeValue":
|
|
48793
|
-
this.value = op.newData.value;
|
|
48794
|
-
break;
|
|
48795
48779
|
case "changeValuesRange":
|
|
48796
48780
|
this.range = op.newData;
|
|
48797
48781
|
break;
|
|
@@ -48804,7 +48788,7 @@ class Dice extends BaseItem {
|
|
|
48804
48788
|
if (!this.animationFrameId) {
|
|
48805
48789
|
const animate = () => {
|
|
48806
48790
|
if (this.drawingContext) {
|
|
48807
|
-
this.
|
|
48791
|
+
this.subject.publish(this);
|
|
48808
48792
|
this.animationFrameId = requestAnimationFrame(animate);
|
|
48809
48793
|
}
|
|
48810
48794
|
};
|
|
@@ -25,7 +25,7 @@ export declare class Dice extends BaseItem {
|
|
|
25
25
|
getPath(): Path;
|
|
26
26
|
renderHTML(documentFactory: DocumentFactory): HTMLElement;
|
|
27
27
|
deserialize(data: SerializedItemData): this;
|
|
28
|
-
|
|
28
|
+
getIsRotating(): boolean;
|
|
29
29
|
private applyBackgroundColor;
|
|
30
30
|
setBackgroundColor(backgroundColor: string): void;
|
|
31
31
|
private applyBorderWidth;
|
|
@@ -37,7 +37,6 @@ export declare class Dice extends BaseItem {
|
|
|
37
37
|
max: number;
|
|
38
38
|
}): void;
|
|
39
39
|
setValue(value: number): void;
|
|
40
|
-
setIsRotating(isRotating: boolean): void;
|
|
41
40
|
throwDice(): void;
|
|
42
41
|
apply(op: DiceOperation): void;
|
|
43
42
|
startRotation(): void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BaseOperation } from "Events/EventsOperations";
|
|
2
|
-
export type DiceOperation = ChangeValue | ChangeValuesRange |
|
|
2
|
+
export type DiceOperation = ChangeValue | ChangeValuesRange | SetBackgroundColor | SetBorderColor | SetBorderWidth;
|
|
3
3
|
interface ChangeValue extends BaseOperation<{
|
|
4
4
|
value: number;
|
|
5
|
+
shouldRotate: boolean;
|
|
6
|
+
timeStamp?: number;
|
|
5
7
|
}> {
|
|
6
8
|
class: "Dice";
|
|
7
9
|
method: "changeValue";
|
|
@@ -13,12 +15,6 @@ interface ChangeValuesRange extends BaseOperation<{
|
|
|
13
15
|
class: "Dice";
|
|
14
16
|
method: "changeValuesRange";
|
|
15
17
|
}
|
|
16
|
-
interface SetIsRotating extends BaseOperation<{
|
|
17
|
-
isRotating: boolean;
|
|
18
|
-
}> {
|
|
19
|
-
class: "Dice";
|
|
20
|
-
method: "setIsRotating";
|
|
21
|
-
}
|
|
22
18
|
interface SetBackgroundColor extends BaseOperation<{
|
|
23
19
|
backgroundColor: string;
|
|
24
20
|
}> {
|