microboard-temp 0.4.17 → 0.4.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/dist/cjs/browser.js +34 -16
- package/dist/cjs/index.js +34 -16
- package/dist/cjs/node.js +34 -16
- package/dist/esm/browser.js +34 -16
- package/dist/esm/index.js +34 -16
- package/dist/esm/node.js +34 -16
- package/dist/types/Items/Examples/CardGame/Dice/Dice.d.ts +5 -2
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -46233,7 +46233,7 @@ class AddDice extends ShapeTool {
|
|
|
46233
46233
|
var TIMEOUT = 3000;
|
|
46234
46234
|
var defaultDiceData = {
|
|
46235
46235
|
itemType: "Dice",
|
|
46236
|
-
backgroundColor: "#
|
|
46236
|
+
backgroundColor: "#FFFFFF",
|
|
46237
46237
|
backgroundOpacity: 1,
|
|
46238
46238
|
borderColor: "#000207",
|
|
46239
46239
|
borderOpacity: 1,
|
|
@@ -46248,9 +46248,10 @@ class Dice extends BaseItem {
|
|
|
46248
46248
|
path;
|
|
46249
46249
|
subject = new Subject;
|
|
46250
46250
|
borderWidth = 1;
|
|
46251
|
-
isRotating = false;
|
|
46252
46251
|
value = 1;
|
|
46253
46252
|
range = { min: 1, max: 6 };
|
|
46253
|
+
animationFrameId;
|
|
46254
|
+
drawingContext = null;
|
|
46254
46255
|
constructor(board, id = "") {
|
|
46255
46256
|
super(board, id, defaultDiceData);
|
|
46256
46257
|
this.transformPath();
|
|
@@ -46269,11 +46270,12 @@ class Dice extends BaseItem {
|
|
|
46269
46270
|
this.path.setBorderWidth(this.borderWidth);
|
|
46270
46271
|
}
|
|
46271
46272
|
render(context) {
|
|
46273
|
+
this.drawingContext = context;
|
|
46272
46274
|
if (this.transformationRenderBlock) {
|
|
46273
46275
|
return;
|
|
46274
46276
|
}
|
|
46275
46277
|
context.ctx.save();
|
|
46276
|
-
if (this.
|
|
46278
|
+
if (this.animationFrameId) {
|
|
46277
46279
|
const now = Date.now();
|
|
46278
46280
|
const angle = now % 1000 / 1000 * 2 * Math.PI;
|
|
46279
46281
|
const mbr2 = this.getMbr();
|
|
@@ -46360,15 +46362,6 @@ class Dice extends BaseItem {
|
|
|
46360
46362
|
prevData: { borderColor: this.borderColor }
|
|
46361
46363
|
});
|
|
46362
46364
|
}
|
|
46363
|
-
setIsRotating(isRotating) {
|
|
46364
|
-
this.emit({
|
|
46365
|
-
class: "Dice",
|
|
46366
|
-
method: "setIsRotating",
|
|
46367
|
-
item: [this.getId()],
|
|
46368
|
-
newData: { isRotating },
|
|
46369
|
-
prevData: { isRotating: false }
|
|
46370
|
-
});
|
|
46371
|
-
}
|
|
46372
46365
|
setValuesRange(range) {
|
|
46373
46366
|
this.emit({
|
|
46374
46367
|
class: "Dice",
|
|
@@ -46387,11 +46380,19 @@ class Dice extends BaseItem {
|
|
|
46387
46380
|
prevData: { value: this.value }
|
|
46388
46381
|
});
|
|
46389
46382
|
}
|
|
46383
|
+
setIsRotating(isRotating) {
|
|
46384
|
+
this.emit({
|
|
46385
|
+
class: "Dice",
|
|
46386
|
+
method: "setIsRotating",
|
|
46387
|
+
item: [this.getId()],
|
|
46388
|
+
newData: { isRotating },
|
|
46389
|
+
prevData: { isRotating: false }
|
|
46390
|
+
});
|
|
46391
|
+
}
|
|
46390
46392
|
throwDice() {
|
|
46391
46393
|
this.setIsRotating(true);
|
|
46392
46394
|
setTimeout(() => {
|
|
46393
46395
|
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46394
|
-
this.isRotating = false;
|
|
46395
46396
|
}, TIMEOUT);
|
|
46396
46397
|
}
|
|
46397
46398
|
apply(op) {
|
|
@@ -46409,16 +46410,15 @@ class Dice extends BaseItem {
|
|
|
46409
46410
|
this.applyBorderColor(op.newData.borderColor);
|
|
46410
46411
|
break;
|
|
46411
46412
|
case "setIsRotating":
|
|
46412
|
-
this.isRotating = op.newData.isRotating;
|
|
46413
46413
|
if (op.newData.isRotating) {
|
|
46414
|
+
this.startRotation();
|
|
46414
46415
|
setTimeout(() => {
|
|
46415
|
-
this.
|
|
46416
|
+
this.stopRotation();
|
|
46416
46417
|
}, TIMEOUT);
|
|
46417
46418
|
}
|
|
46418
46419
|
break;
|
|
46419
46420
|
case "changeValue":
|
|
46420
46421
|
this.value = op.newData.value;
|
|
46421
|
-
this.isRotating = false;
|
|
46422
46422
|
break;
|
|
46423
46423
|
case "changeValuesRange":
|
|
46424
46424
|
this.range = op.newData;
|
|
@@ -46428,6 +46428,24 @@ class Dice extends BaseItem {
|
|
|
46428
46428
|
}
|
|
46429
46429
|
this.subject.publish(this);
|
|
46430
46430
|
}
|
|
46431
|
+
startRotation() {
|
|
46432
|
+
if (!this.animationFrameId) {
|
|
46433
|
+
const animate = () => {
|
|
46434
|
+
if (this.drawingContext) {
|
|
46435
|
+
this.render(this.drawingContext);
|
|
46436
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
46437
|
+
}
|
|
46438
|
+
};
|
|
46439
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
46440
|
+
}
|
|
46441
|
+
}
|
|
46442
|
+
stopRotation() {
|
|
46443
|
+
if (this.animationFrameId) {
|
|
46444
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
46445
|
+
this.animationFrameId = undefined;
|
|
46446
|
+
this.drawingContext = null;
|
|
46447
|
+
}
|
|
46448
|
+
}
|
|
46431
46449
|
}
|
|
46432
46450
|
registerItem({
|
|
46433
46451
|
item: Dice,
|
package/dist/cjs/index.js
CHANGED
|
@@ -46233,7 +46233,7 @@ class AddDice extends ShapeTool {
|
|
|
46233
46233
|
var TIMEOUT = 3000;
|
|
46234
46234
|
var defaultDiceData = {
|
|
46235
46235
|
itemType: "Dice",
|
|
46236
|
-
backgroundColor: "#
|
|
46236
|
+
backgroundColor: "#FFFFFF",
|
|
46237
46237
|
backgroundOpacity: 1,
|
|
46238
46238
|
borderColor: "#000207",
|
|
46239
46239
|
borderOpacity: 1,
|
|
@@ -46248,9 +46248,10 @@ class Dice extends BaseItem {
|
|
|
46248
46248
|
path;
|
|
46249
46249
|
subject = new Subject;
|
|
46250
46250
|
borderWidth = 1;
|
|
46251
|
-
isRotating = false;
|
|
46252
46251
|
value = 1;
|
|
46253
46252
|
range = { min: 1, max: 6 };
|
|
46253
|
+
animationFrameId;
|
|
46254
|
+
drawingContext = null;
|
|
46254
46255
|
constructor(board, id = "") {
|
|
46255
46256
|
super(board, id, defaultDiceData);
|
|
46256
46257
|
this.transformPath();
|
|
@@ -46269,11 +46270,12 @@ class Dice extends BaseItem {
|
|
|
46269
46270
|
this.path.setBorderWidth(this.borderWidth);
|
|
46270
46271
|
}
|
|
46271
46272
|
render(context) {
|
|
46273
|
+
this.drawingContext = context;
|
|
46272
46274
|
if (this.transformationRenderBlock) {
|
|
46273
46275
|
return;
|
|
46274
46276
|
}
|
|
46275
46277
|
context.ctx.save();
|
|
46276
|
-
if (this.
|
|
46278
|
+
if (this.animationFrameId) {
|
|
46277
46279
|
const now = Date.now();
|
|
46278
46280
|
const angle = now % 1000 / 1000 * 2 * Math.PI;
|
|
46279
46281
|
const mbr2 = this.getMbr();
|
|
@@ -46360,15 +46362,6 @@ class Dice extends BaseItem {
|
|
|
46360
46362
|
prevData: { borderColor: this.borderColor }
|
|
46361
46363
|
});
|
|
46362
46364
|
}
|
|
46363
|
-
setIsRotating(isRotating) {
|
|
46364
|
-
this.emit({
|
|
46365
|
-
class: "Dice",
|
|
46366
|
-
method: "setIsRotating",
|
|
46367
|
-
item: [this.getId()],
|
|
46368
|
-
newData: { isRotating },
|
|
46369
|
-
prevData: { isRotating: false }
|
|
46370
|
-
});
|
|
46371
|
-
}
|
|
46372
46365
|
setValuesRange(range) {
|
|
46373
46366
|
this.emit({
|
|
46374
46367
|
class: "Dice",
|
|
@@ -46387,11 +46380,19 @@ class Dice extends BaseItem {
|
|
|
46387
46380
|
prevData: { value: this.value }
|
|
46388
46381
|
});
|
|
46389
46382
|
}
|
|
46383
|
+
setIsRotating(isRotating) {
|
|
46384
|
+
this.emit({
|
|
46385
|
+
class: "Dice",
|
|
46386
|
+
method: "setIsRotating",
|
|
46387
|
+
item: [this.getId()],
|
|
46388
|
+
newData: { isRotating },
|
|
46389
|
+
prevData: { isRotating: false }
|
|
46390
|
+
});
|
|
46391
|
+
}
|
|
46390
46392
|
throwDice() {
|
|
46391
46393
|
this.setIsRotating(true);
|
|
46392
46394
|
setTimeout(() => {
|
|
46393
46395
|
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46394
|
-
this.isRotating = false;
|
|
46395
46396
|
}, TIMEOUT);
|
|
46396
46397
|
}
|
|
46397
46398
|
apply(op) {
|
|
@@ -46409,16 +46410,15 @@ class Dice extends BaseItem {
|
|
|
46409
46410
|
this.applyBorderColor(op.newData.borderColor);
|
|
46410
46411
|
break;
|
|
46411
46412
|
case "setIsRotating":
|
|
46412
|
-
this.isRotating = op.newData.isRotating;
|
|
46413
46413
|
if (op.newData.isRotating) {
|
|
46414
|
+
this.startRotation();
|
|
46414
46415
|
setTimeout(() => {
|
|
46415
|
-
this.
|
|
46416
|
+
this.stopRotation();
|
|
46416
46417
|
}, TIMEOUT);
|
|
46417
46418
|
}
|
|
46418
46419
|
break;
|
|
46419
46420
|
case "changeValue":
|
|
46420
46421
|
this.value = op.newData.value;
|
|
46421
|
-
this.isRotating = false;
|
|
46422
46422
|
break;
|
|
46423
46423
|
case "changeValuesRange":
|
|
46424
46424
|
this.range = op.newData;
|
|
@@ -46428,6 +46428,24 @@ class Dice extends BaseItem {
|
|
|
46428
46428
|
}
|
|
46429
46429
|
this.subject.publish(this);
|
|
46430
46430
|
}
|
|
46431
|
+
startRotation() {
|
|
46432
|
+
if (!this.animationFrameId) {
|
|
46433
|
+
const animate = () => {
|
|
46434
|
+
if (this.drawingContext) {
|
|
46435
|
+
this.render(this.drawingContext);
|
|
46436
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
46437
|
+
}
|
|
46438
|
+
};
|
|
46439
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
46440
|
+
}
|
|
46441
|
+
}
|
|
46442
|
+
stopRotation() {
|
|
46443
|
+
if (this.animationFrameId) {
|
|
46444
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
46445
|
+
this.animationFrameId = undefined;
|
|
46446
|
+
this.drawingContext = null;
|
|
46447
|
+
}
|
|
46448
|
+
}
|
|
46431
46449
|
}
|
|
46432
46450
|
registerItem({
|
|
46433
46451
|
item: Dice,
|
package/dist/cjs/node.js
CHANGED
|
@@ -48773,7 +48773,7 @@ class AddDice extends ShapeTool {
|
|
|
48773
48773
|
var TIMEOUT = 3000;
|
|
48774
48774
|
var defaultDiceData = {
|
|
48775
48775
|
itemType: "Dice",
|
|
48776
|
-
backgroundColor: "#
|
|
48776
|
+
backgroundColor: "#FFFFFF",
|
|
48777
48777
|
backgroundOpacity: 1,
|
|
48778
48778
|
borderColor: "#000207",
|
|
48779
48779
|
borderOpacity: 1,
|
|
@@ -48788,9 +48788,10 @@ class Dice extends BaseItem {
|
|
|
48788
48788
|
path;
|
|
48789
48789
|
subject = new Subject;
|
|
48790
48790
|
borderWidth = 1;
|
|
48791
|
-
isRotating = false;
|
|
48792
48791
|
value = 1;
|
|
48793
48792
|
range = { min: 1, max: 6 };
|
|
48793
|
+
animationFrameId;
|
|
48794
|
+
drawingContext = null;
|
|
48794
48795
|
constructor(board, id = "") {
|
|
48795
48796
|
super(board, id, defaultDiceData);
|
|
48796
48797
|
this.transformPath();
|
|
@@ -48809,11 +48810,12 @@ class Dice extends BaseItem {
|
|
|
48809
48810
|
this.path.setBorderWidth(this.borderWidth);
|
|
48810
48811
|
}
|
|
48811
48812
|
render(context) {
|
|
48813
|
+
this.drawingContext = context;
|
|
48812
48814
|
if (this.transformationRenderBlock) {
|
|
48813
48815
|
return;
|
|
48814
48816
|
}
|
|
48815
48817
|
context.ctx.save();
|
|
48816
|
-
if (this.
|
|
48818
|
+
if (this.animationFrameId) {
|
|
48817
48819
|
const now = Date.now();
|
|
48818
48820
|
const angle = now % 1000 / 1000 * 2 * Math.PI;
|
|
48819
48821
|
const mbr2 = this.getMbr();
|
|
@@ -48900,15 +48902,6 @@ class Dice extends BaseItem {
|
|
|
48900
48902
|
prevData: { borderColor: this.borderColor }
|
|
48901
48903
|
});
|
|
48902
48904
|
}
|
|
48903
|
-
setIsRotating(isRotating) {
|
|
48904
|
-
this.emit({
|
|
48905
|
-
class: "Dice",
|
|
48906
|
-
method: "setIsRotating",
|
|
48907
|
-
item: [this.getId()],
|
|
48908
|
-
newData: { isRotating },
|
|
48909
|
-
prevData: { isRotating: false }
|
|
48910
|
-
});
|
|
48911
|
-
}
|
|
48912
48905
|
setValuesRange(range) {
|
|
48913
48906
|
this.emit({
|
|
48914
48907
|
class: "Dice",
|
|
@@ -48927,11 +48920,19 @@ class Dice extends BaseItem {
|
|
|
48927
48920
|
prevData: { value: this.value }
|
|
48928
48921
|
});
|
|
48929
48922
|
}
|
|
48923
|
+
setIsRotating(isRotating) {
|
|
48924
|
+
this.emit({
|
|
48925
|
+
class: "Dice",
|
|
48926
|
+
method: "setIsRotating",
|
|
48927
|
+
item: [this.getId()],
|
|
48928
|
+
newData: { isRotating },
|
|
48929
|
+
prevData: { isRotating: false }
|
|
48930
|
+
});
|
|
48931
|
+
}
|
|
48930
48932
|
throwDice() {
|
|
48931
48933
|
this.setIsRotating(true);
|
|
48932
48934
|
setTimeout(() => {
|
|
48933
48935
|
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
48934
|
-
this.isRotating = false;
|
|
48935
48936
|
}, TIMEOUT);
|
|
48936
48937
|
}
|
|
48937
48938
|
apply(op) {
|
|
@@ -48949,16 +48950,15 @@ class Dice extends BaseItem {
|
|
|
48949
48950
|
this.applyBorderColor(op.newData.borderColor);
|
|
48950
48951
|
break;
|
|
48951
48952
|
case "setIsRotating":
|
|
48952
|
-
this.isRotating = op.newData.isRotating;
|
|
48953
48953
|
if (op.newData.isRotating) {
|
|
48954
|
+
this.startRotation();
|
|
48954
48955
|
setTimeout(() => {
|
|
48955
|
-
this.
|
|
48956
|
+
this.stopRotation();
|
|
48956
48957
|
}, TIMEOUT);
|
|
48957
48958
|
}
|
|
48958
48959
|
break;
|
|
48959
48960
|
case "changeValue":
|
|
48960
48961
|
this.value = op.newData.value;
|
|
48961
|
-
this.isRotating = false;
|
|
48962
48962
|
break;
|
|
48963
48963
|
case "changeValuesRange":
|
|
48964
48964
|
this.range = op.newData;
|
|
@@ -48968,6 +48968,24 @@ class Dice extends BaseItem {
|
|
|
48968
48968
|
}
|
|
48969
48969
|
this.subject.publish(this);
|
|
48970
48970
|
}
|
|
48971
|
+
startRotation() {
|
|
48972
|
+
if (!this.animationFrameId) {
|
|
48973
|
+
const animate = () => {
|
|
48974
|
+
if (this.drawingContext) {
|
|
48975
|
+
this.render(this.drawingContext);
|
|
48976
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
48977
|
+
}
|
|
48978
|
+
};
|
|
48979
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
48980
|
+
}
|
|
48981
|
+
}
|
|
48982
|
+
stopRotation() {
|
|
48983
|
+
if (this.animationFrameId) {
|
|
48984
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
48985
|
+
this.animationFrameId = undefined;
|
|
48986
|
+
this.drawingContext = null;
|
|
48987
|
+
}
|
|
48988
|
+
}
|
|
48971
48989
|
}
|
|
48972
48990
|
registerItem({
|
|
48973
48991
|
item: Dice,
|
package/dist/esm/browser.js
CHANGED
|
@@ -46083,7 +46083,7 @@ class AddDice extends ShapeTool {
|
|
|
46083
46083
|
var TIMEOUT = 3000;
|
|
46084
46084
|
var defaultDiceData = {
|
|
46085
46085
|
itemType: "Dice",
|
|
46086
|
-
backgroundColor: "#
|
|
46086
|
+
backgroundColor: "#FFFFFF",
|
|
46087
46087
|
backgroundOpacity: 1,
|
|
46088
46088
|
borderColor: "#000207",
|
|
46089
46089
|
borderOpacity: 1,
|
|
@@ -46098,9 +46098,10 @@ class Dice extends BaseItem {
|
|
|
46098
46098
|
path;
|
|
46099
46099
|
subject = new Subject;
|
|
46100
46100
|
borderWidth = 1;
|
|
46101
|
-
isRotating = false;
|
|
46102
46101
|
value = 1;
|
|
46103
46102
|
range = { min: 1, max: 6 };
|
|
46103
|
+
animationFrameId;
|
|
46104
|
+
drawingContext = null;
|
|
46104
46105
|
constructor(board, id = "") {
|
|
46105
46106
|
super(board, id, defaultDiceData);
|
|
46106
46107
|
this.transformPath();
|
|
@@ -46119,11 +46120,12 @@ class Dice extends BaseItem {
|
|
|
46119
46120
|
this.path.setBorderWidth(this.borderWidth);
|
|
46120
46121
|
}
|
|
46121
46122
|
render(context) {
|
|
46123
|
+
this.drawingContext = context;
|
|
46122
46124
|
if (this.transformationRenderBlock) {
|
|
46123
46125
|
return;
|
|
46124
46126
|
}
|
|
46125
46127
|
context.ctx.save();
|
|
46126
|
-
if (this.
|
|
46128
|
+
if (this.animationFrameId) {
|
|
46127
46129
|
const now = Date.now();
|
|
46128
46130
|
const angle = now % 1000 / 1000 * 2 * Math.PI;
|
|
46129
46131
|
const mbr2 = this.getMbr();
|
|
@@ -46210,15 +46212,6 @@ class Dice extends BaseItem {
|
|
|
46210
46212
|
prevData: { borderColor: this.borderColor }
|
|
46211
46213
|
});
|
|
46212
46214
|
}
|
|
46213
|
-
setIsRotating(isRotating) {
|
|
46214
|
-
this.emit({
|
|
46215
|
-
class: "Dice",
|
|
46216
|
-
method: "setIsRotating",
|
|
46217
|
-
item: [this.getId()],
|
|
46218
|
-
newData: { isRotating },
|
|
46219
|
-
prevData: { isRotating: false }
|
|
46220
|
-
});
|
|
46221
|
-
}
|
|
46222
46215
|
setValuesRange(range) {
|
|
46223
46216
|
this.emit({
|
|
46224
46217
|
class: "Dice",
|
|
@@ -46237,11 +46230,19 @@ class Dice extends BaseItem {
|
|
|
46237
46230
|
prevData: { value: this.value }
|
|
46238
46231
|
});
|
|
46239
46232
|
}
|
|
46233
|
+
setIsRotating(isRotating) {
|
|
46234
|
+
this.emit({
|
|
46235
|
+
class: "Dice",
|
|
46236
|
+
method: "setIsRotating",
|
|
46237
|
+
item: [this.getId()],
|
|
46238
|
+
newData: { isRotating },
|
|
46239
|
+
prevData: { isRotating: false }
|
|
46240
|
+
});
|
|
46241
|
+
}
|
|
46240
46242
|
throwDice() {
|
|
46241
46243
|
this.setIsRotating(true);
|
|
46242
46244
|
setTimeout(() => {
|
|
46243
46245
|
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46244
|
-
this.isRotating = false;
|
|
46245
46246
|
}, TIMEOUT);
|
|
46246
46247
|
}
|
|
46247
46248
|
apply(op) {
|
|
@@ -46259,16 +46260,15 @@ class Dice extends BaseItem {
|
|
|
46259
46260
|
this.applyBorderColor(op.newData.borderColor);
|
|
46260
46261
|
break;
|
|
46261
46262
|
case "setIsRotating":
|
|
46262
|
-
this.isRotating = op.newData.isRotating;
|
|
46263
46263
|
if (op.newData.isRotating) {
|
|
46264
|
+
this.startRotation();
|
|
46264
46265
|
setTimeout(() => {
|
|
46265
|
-
this.
|
|
46266
|
+
this.stopRotation();
|
|
46266
46267
|
}, TIMEOUT);
|
|
46267
46268
|
}
|
|
46268
46269
|
break;
|
|
46269
46270
|
case "changeValue":
|
|
46270
46271
|
this.value = op.newData.value;
|
|
46271
|
-
this.isRotating = false;
|
|
46272
46272
|
break;
|
|
46273
46273
|
case "changeValuesRange":
|
|
46274
46274
|
this.range = op.newData;
|
|
@@ -46278,6 +46278,24 @@ class Dice extends BaseItem {
|
|
|
46278
46278
|
}
|
|
46279
46279
|
this.subject.publish(this);
|
|
46280
46280
|
}
|
|
46281
|
+
startRotation() {
|
|
46282
|
+
if (!this.animationFrameId) {
|
|
46283
|
+
const animate = () => {
|
|
46284
|
+
if (this.drawingContext) {
|
|
46285
|
+
this.render(this.drawingContext);
|
|
46286
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
46287
|
+
}
|
|
46288
|
+
};
|
|
46289
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
46290
|
+
}
|
|
46291
|
+
}
|
|
46292
|
+
stopRotation() {
|
|
46293
|
+
if (this.animationFrameId) {
|
|
46294
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
46295
|
+
this.animationFrameId = undefined;
|
|
46296
|
+
this.drawingContext = null;
|
|
46297
|
+
}
|
|
46298
|
+
}
|
|
46281
46299
|
}
|
|
46282
46300
|
registerItem({
|
|
46283
46301
|
item: Dice,
|
package/dist/esm/index.js
CHANGED
|
@@ -46076,7 +46076,7 @@ class AddDice extends ShapeTool {
|
|
|
46076
46076
|
var TIMEOUT = 3000;
|
|
46077
46077
|
var defaultDiceData = {
|
|
46078
46078
|
itemType: "Dice",
|
|
46079
|
-
backgroundColor: "#
|
|
46079
|
+
backgroundColor: "#FFFFFF",
|
|
46080
46080
|
backgroundOpacity: 1,
|
|
46081
46081
|
borderColor: "#000207",
|
|
46082
46082
|
borderOpacity: 1,
|
|
@@ -46091,9 +46091,10 @@ class Dice extends BaseItem {
|
|
|
46091
46091
|
path;
|
|
46092
46092
|
subject = new Subject;
|
|
46093
46093
|
borderWidth = 1;
|
|
46094
|
-
isRotating = false;
|
|
46095
46094
|
value = 1;
|
|
46096
46095
|
range = { min: 1, max: 6 };
|
|
46096
|
+
animationFrameId;
|
|
46097
|
+
drawingContext = null;
|
|
46097
46098
|
constructor(board, id = "") {
|
|
46098
46099
|
super(board, id, defaultDiceData);
|
|
46099
46100
|
this.transformPath();
|
|
@@ -46112,11 +46113,12 @@ class Dice extends BaseItem {
|
|
|
46112
46113
|
this.path.setBorderWidth(this.borderWidth);
|
|
46113
46114
|
}
|
|
46114
46115
|
render(context) {
|
|
46116
|
+
this.drawingContext = context;
|
|
46115
46117
|
if (this.transformationRenderBlock) {
|
|
46116
46118
|
return;
|
|
46117
46119
|
}
|
|
46118
46120
|
context.ctx.save();
|
|
46119
|
-
if (this.
|
|
46121
|
+
if (this.animationFrameId) {
|
|
46120
46122
|
const now = Date.now();
|
|
46121
46123
|
const angle = now % 1000 / 1000 * 2 * Math.PI;
|
|
46122
46124
|
const mbr2 = this.getMbr();
|
|
@@ -46203,15 +46205,6 @@ class Dice extends BaseItem {
|
|
|
46203
46205
|
prevData: { borderColor: this.borderColor }
|
|
46204
46206
|
});
|
|
46205
46207
|
}
|
|
46206
|
-
setIsRotating(isRotating) {
|
|
46207
|
-
this.emit({
|
|
46208
|
-
class: "Dice",
|
|
46209
|
-
method: "setIsRotating",
|
|
46210
|
-
item: [this.getId()],
|
|
46211
|
-
newData: { isRotating },
|
|
46212
|
-
prevData: { isRotating: false }
|
|
46213
|
-
});
|
|
46214
|
-
}
|
|
46215
46208
|
setValuesRange(range) {
|
|
46216
46209
|
this.emit({
|
|
46217
46210
|
class: "Dice",
|
|
@@ -46230,11 +46223,19 @@ class Dice extends BaseItem {
|
|
|
46230
46223
|
prevData: { value: this.value }
|
|
46231
46224
|
});
|
|
46232
46225
|
}
|
|
46226
|
+
setIsRotating(isRotating) {
|
|
46227
|
+
this.emit({
|
|
46228
|
+
class: "Dice",
|
|
46229
|
+
method: "setIsRotating",
|
|
46230
|
+
item: [this.getId()],
|
|
46231
|
+
newData: { isRotating },
|
|
46232
|
+
prevData: { isRotating: false }
|
|
46233
|
+
});
|
|
46234
|
+
}
|
|
46233
46235
|
throwDice() {
|
|
46234
46236
|
this.setIsRotating(true);
|
|
46235
46237
|
setTimeout(() => {
|
|
46236
46238
|
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
46237
|
-
this.isRotating = false;
|
|
46238
46239
|
}, TIMEOUT);
|
|
46239
46240
|
}
|
|
46240
46241
|
apply(op) {
|
|
@@ -46252,16 +46253,15 @@ class Dice extends BaseItem {
|
|
|
46252
46253
|
this.applyBorderColor(op.newData.borderColor);
|
|
46253
46254
|
break;
|
|
46254
46255
|
case "setIsRotating":
|
|
46255
|
-
this.isRotating = op.newData.isRotating;
|
|
46256
46256
|
if (op.newData.isRotating) {
|
|
46257
|
+
this.startRotation();
|
|
46257
46258
|
setTimeout(() => {
|
|
46258
|
-
this.
|
|
46259
|
+
this.stopRotation();
|
|
46259
46260
|
}, TIMEOUT);
|
|
46260
46261
|
}
|
|
46261
46262
|
break;
|
|
46262
46263
|
case "changeValue":
|
|
46263
46264
|
this.value = op.newData.value;
|
|
46264
|
-
this.isRotating = false;
|
|
46265
46265
|
break;
|
|
46266
46266
|
case "changeValuesRange":
|
|
46267
46267
|
this.range = op.newData;
|
|
@@ -46271,6 +46271,24 @@ class Dice extends BaseItem {
|
|
|
46271
46271
|
}
|
|
46272
46272
|
this.subject.publish(this);
|
|
46273
46273
|
}
|
|
46274
|
+
startRotation() {
|
|
46275
|
+
if (!this.animationFrameId) {
|
|
46276
|
+
const animate = () => {
|
|
46277
|
+
if (this.drawingContext) {
|
|
46278
|
+
this.render(this.drawingContext);
|
|
46279
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
46280
|
+
}
|
|
46281
|
+
};
|
|
46282
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
46283
|
+
}
|
|
46284
|
+
}
|
|
46285
|
+
stopRotation() {
|
|
46286
|
+
if (this.animationFrameId) {
|
|
46287
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
46288
|
+
this.animationFrameId = undefined;
|
|
46289
|
+
this.drawingContext = null;
|
|
46290
|
+
}
|
|
46291
|
+
}
|
|
46274
46292
|
}
|
|
46275
46293
|
registerItem({
|
|
46276
46294
|
item: Dice,
|
package/dist/esm/node.js
CHANGED
|
@@ -48611,7 +48611,7 @@ class AddDice extends ShapeTool {
|
|
|
48611
48611
|
var TIMEOUT = 3000;
|
|
48612
48612
|
var defaultDiceData = {
|
|
48613
48613
|
itemType: "Dice",
|
|
48614
|
-
backgroundColor: "#
|
|
48614
|
+
backgroundColor: "#FFFFFF",
|
|
48615
48615
|
backgroundOpacity: 1,
|
|
48616
48616
|
borderColor: "#000207",
|
|
48617
48617
|
borderOpacity: 1,
|
|
@@ -48626,9 +48626,10 @@ class Dice extends BaseItem {
|
|
|
48626
48626
|
path;
|
|
48627
48627
|
subject = new Subject;
|
|
48628
48628
|
borderWidth = 1;
|
|
48629
|
-
isRotating = false;
|
|
48630
48629
|
value = 1;
|
|
48631
48630
|
range = { min: 1, max: 6 };
|
|
48631
|
+
animationFrameId;
|
|
48632
|
+
drawingContext = null;
|
|
48632
48633
|
constructor(board, id = "") {
|
|
48633
48634
|
super(board, id, defaultDiceData);
|
|
48634
48635
|
this.transformPath();
|
|
@@ -48647,11 +48648,12 @@ class Dice extends BaseItem {
|
|
|
48647
48648
|
this.path.setBorderWidth(this.borderWidth);
|
|
48648
48649
|
}
|
|
48649
48650
|
render(context) {
|
|
48651
|
+
this.drawingContext = context;
|
|
48650
48652
|
if (this.transformationRenderBlock) {
|
|
48651
48653
|
return;
|
|
48652
48654
|
}
|
|
48653
48655
|
context.ctx.save();
|
|
48654
|
-
if (this.
|
|
48656
|
+
if (this.animationFrameId) {
|
|
48655
48657
|
const now = Date.now();
|
|
48656
48658
|
const angle = now % 1000 / 1000 * 2 * Math.PI;
|
|
48657
48659
|
const mbr2 = this.getMbr();
|
|
@@ -48738,15 +48740,6 @@ class Dice extends BaseItem {
|
|
|
48738
48740
|
prevData: { borderColor: this.borderColor }
|
|
48739
48741
|
});
|
|
48740
48742
|
}
|
|
48741
|
-
setIsRotating(isRotating) {
|
|
48742
|
-
this.emit({
|
|
48743
|
-
class: "Dice",
|
|
48744
|
-
method: "setIsRotating",
|
|
48745
|
-
item: [this.getId()],
|
|
48746
|
-
newData: { isRotating },
|
|
48747
|
-
prevData: { isRotating: false }
|
|
48748
|
-
});
|
|
48749
|
-
}
|
|
48750
48743
|
setValuesRange(range) {
|
|
48751
48744
|
this.emit({
|
|
48752
48745
|
class: "Dice",
|
|
@@ -48765,11 +48758,19 @@ class Dice extends BaseItem {
|
|
|
48765
48758
|
prevData: { value: this.value }
|
|
48766
48759
|
});
|
|
48767
48760
|
}
|
|
48761
|
+
setIsRotating(isRotating) {
|
|
48762
|
+
this.emit({
|
|
48763
|
+
class: "Dice",
|
|
48764
|
+
method: "setIsRotating",
|
|
48765
|
+
item: [this.getId()],
|
|
48766
|
+
newData: { isRotating },
|
|
48767
|
+
prevData: { isRotating: false }
|
|
48768
|
+
});
|
|
48769
|
+
}
|
|
48768
48770
|
throwDice() {
|
|
48769
48771
|
this.setIsRotating(true);
|
|
48770
48772
|
setTimeout(() => {
|
|
48771
48773
|
this.setValue(Math.ceil(Math.random() * (this.range.max - this.range.min)) + this.range.min);
|
|
48772
|
-
this.isRotating = false;
|
|
48773
48774
|
}, TIMEOUT);
|
|
48774
48775
|
}
|
|
48775
48776
|
apply(op) {
|
|
@@ -48787,16 +48788,15 @@ class Dice extends BaseItem {
|
|
|
48787
48788
|
this.applyBorderColor(op.newData.borderColor);
|
|
48788
48789
|
break;
|
|
48789
48790
|
case "setIsRotating":
|
|
48790
|
-
this.isRotating = op.newData.isRotating;
|
|
48791
48791
|
if (op.newData.isRotating) {
|
|
48792
|
+
this.startRotation();
|
|
48792
48793
|
setTimeout(() => {
|
|
48793
|
-
this.
|
|
48794
|
+
this.stopRotation();
|
|
48794
48795
|
}, TIMEOUT);
|
|
48795
48796
|
}
|
|
48796
48797
|
break;
|
|
48797
48798
|
case "changeValue":
|
|
48798
48799
|
this.value = op.newData.value;
|
|
48799
|
-
this.isRotating = false;
|
|
48800
48800
|
break;
|
|
48801
48801
|
case "changeValuesRange":
|
|
48802
48802
|
this.range = op.newData;
|
|
@@ -48806,6 +48806,24 @@ class Dice extends BaseItem {
|
|
|
48806
48806
|
}
|
|
48807
48807
|
this.subject.publish(this);
|
|
48808
48808
|
}
|
|
48809
|
+
startRotation() {
|
|
48810
|
+
if (!this.animationFrameId) {
|
|
48811
|
+
const animate = () => {
|
|
48812
|
+
if (this.drawingContext) {
|
|
48813
|
+
this.render(this.drawingContext);
|
|
48814
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
48815
|
+
}
|
|
48816
|
+
};
|
|
48817
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
48818
|
+
}
|
|
48819
|
+
}
|
|
48820
|
+
stopRotation() {
|
|
48821
|
+
if (this.animationFrameId) {
|
|
48822
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
48823
|
+
this.animationFrameId = undefined;
|
|
48824
|
+
this.drawingContext = null;
|
|
48825
|
+
}
|
|
48826
|
+
}
|
|
48809
48827
|
}
|
|
48810
48828
|
registerItem({
|
|
48811
48829
|
item: Dice,
|
|
@@ -11,12 +11,13 @@ export declare class Dice extends BaseItem {
|
|
|
11
11
|
private path;
|
|
12
12
|
readonly subject: Subject<Dice>;
|
|
13
13
|
private borderWidth;
|
|
14
|
-
isRotating: boolean;
|
|
15
14
|
value: number;
|
|
16
15
|
range: {
|
|
17
16
|
min: number;
|
|
18
17
|
max: number;
|
|
19
18
|
};
|
|
19
|
+
private animationFrameId?;
|
|
20
|
+
drawingContext: DrawingContext | null;
|
|
20
21
|
constructor(board: Board, id?: string);
|
|
21
22
|
private transformPath;
|
|
22
23
|
render(context: DrawingContext): void;
|
|
@@ -31,12 +32,14 @@ export declare class Dice extends BaseItem {
|
|
|
31
32
|
setBorderWidth(borderWidth: BorderWidth): void;
|
|
32
33
|
private applyBorderColor;
|
|
33
34
|
setBorderColor(borderColor: string): void;
|
|
34
|
-
setIsRotating(isRotating: boolean): void;
|
|
35
35
|
setValuesRange(range: {
|
|
36
36
|
min: number;
|
|
37
37
|
max: number;
|
|
38
38
|
}): void;
|
|
39
39
|
setValue(value: number): void;
|
|
40
|
+
setIsRotating(isRotating: boolean): void;
|
|
40
41
|
throwDice(): void;
|
|
41
42
|
apply(op: DiceOperation): void;
|
|
43
|
+
startRotation(): void;
|
|
44
|
+
stopRotation(): void;
|
|
42
45
|
}
|