microboard-temp 0.5.27 → 0.5.29
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 +38 -9
- package/dist/cjs/index.js +38 -9
- package/dist/cjs/node.js +38 -9
- package/dist/esm/browser.js +38 -9
- package/dist/esm/index.js +38 -9
- package/dist/esm/node.js +38 -9
- package/dist/types/Items/Examples/CardGame/Card/Card.d.ts +1 -0
- package/dist/types/Items/Examples/CardGame/Deck/Deck.d.ts +2 -0
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -7069,7 +7069,7 @@ var conf = {
|
|
|
7069
7069
|
FALLBACK_LNG: "en",
|
|
7070
7070
|
cursorsMap,
|
|
7071
7071
|
DECK_HORIZONTAL_OFFSET: 2,
|
|
7072
|
-
DECK_VERTICAL_OFFSET:
|
|
7072
|
+
DECK_VERTICAL_OFFSET: 2,
|
|
7073
7073
|
CARD_DIMENSIONS: { width: 250, height: 400 }
|
|
7074
7074
|
};
|
|
7075
7075
|
initDefaultI18N();
|
|
@@ -42121,10 +42121,22 @@ class ImageItem extends BaseItem {
|
|
|
42121
42121
|
};
|
|
42122
42122
|
updateMbr() {
|
|
42123
42123
|
const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
|
|
42124
|
-
|
|
42125
|
-
this.
|
|
42126
|
-
|
|
42127
|
-
|
|
42124
|
+
const rotation = this.transformation.getRotation();
|
|
42125
|
+
const width2 = this.image.width * scaleX;
|
|
42126
|
+
const height2 = this.image.height * scaleY;
|
|
42127
|
+
if (rotation % 180 === 0) {
|
|
42128
|
+
this.left = translateX;
|
|
42129
|
+
this.top = translateY;
|
|
42130
|
+
this.right = this.left + width2;
|
|
42131
|
+
this.bottom = this.top + height2;
|
|
42132
|
+
} else {
|
|
42133
|
+
const centerX = translateX + width2 / 2;
|
|
42134
|
+
const centerY = translateY + height2 / 2;
|
|
42135
|
+
this.left = centerX - height2 / 2;
|
|
42136
|
+
this.top = centerY - width2 / 2;
|
|
42137
|
+
this.right = this.left + height2;
|
|
42138
|
+
this.bottom = this.top + width2;
|
|
42139
|
+
}
|
|
42128
42140
|
}
|
|
42129
42141
|
doOnceBeforeOnLoad = (callback) => {
|
|
42130
42142
|
this.loadCallbacks.push(callback);
|
|
@@ -42229,6 +42241,14 @@ class ImageItem extends BaseItem {
|
|
|
42229
42241
|
const ctx = context.ctx;
|
|
42230
42242
|
ctx.save();
|
|
42231
42243
|
this.transformation.matrix.applyToContext(ctx);
|
|
42244
|
+
const rotation = this.transformation.getRotation();
|
|
42245
|
+
if (rotation !== 0) {
|
|
42246
|
+
const imgWidth = this.image.width || 0;
|
|
42247
|
+
const imgHeight = this.image.height || 0;
|
|
42248
|
+
ctx.translate(imgWidth / 2, imgHeight / 2);
|
|
42249
|
+
ctx.rotate(rotation * Math.PI / 180);
|
|
42250
|
+
ctx.translate(-imgWidth / 2, -imgHeight / 2);
|
|
42251
|
+
}
|
|
42232
42252
|
ctx.drawImage(this.image, 0, 0);
|
|
42233
42253
|
ctx.restore();
|
|
42234
42254
|
if (this.getLinkTo()) {
|
|
@@ -47874,6 +47894,9 @@ class Card extends BaseItem {
|
|
|
47874
47894
|
getImage() {
|
|
47875
47895
|
return this.imageToRender;
|
|
47876
47896
|
}
|
|
47897
|
+
getIsRotatedPerpendicular() {
|
|
47898
|
+
return Boolean(this.transformation.getRotation() % 180);
|
|
47899
|
+
}
|
|
47877
47900
|
render(context, left, top) {
|
|
47878
47901
|
if (this.transformationRenderBlock) {
|
|
47879
47902
|
return;
|
|
@@ -47886,7 +47909,7 @@ class Card extends BaseItem {
|
|
|
47886
47909
|
const height3 = this.getHeight();
|
|
47887
47910
|
if (typeof left === "number" && typeof top === "number") {
|
|
47888
47911
|
centerX = left + width2 / 2;
|
|
47889
|
-
|
|
47912
|
+
centerY = top + height3 / 2;
|
|
47890
47913
|
}
|
|
47891
47914
|
ctx.translate(centerX, centerY);
|
|
47892
47915
|
ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
|
|
@@ -48014,6 +48037,7 @@ class Deck extends BaseItem {
|
|
|
48014
48037
|
isCacheDirty = true;
|
|
48015
48038
|
enableResize = false;
|
|
48016
48039
|
path = null;
|
|
48040
|
+
isPerpendicular = undefined;
|
|
48017
48041
|
constructor(board, id = "") {
|
|
48018
48042
|
super(board, id, defaultDeckData, true);
|
|
48019
48043
|
this.index.getUnderPoint = () => [];
|
|
@@ -48025,6 +48049,9 @@ class Deck extends BaseItem {
|
|
|
48025
48049
|
});
|
|
48026
48050
|
this.updateMbr();
|
|
48027
48051
|
}
|
|
48052
|
+
getIsPerpendicular() {
|
|
48053
|
+
return this.isPerpendicular;
|
|
48054
|
+
}
|
|
48028
48055
|
applyAddChildren(childIds) {
|
|
48029
48056
|
if (!this.index) {
|
|
48030
48057
|
return;
|
|
@@ -48032,13 +48059,15 @@ class Deck extends BaseItem {
|
|
|
48032
48059
|
childIds.forEach((childId) => {
|
|
48033
48060
|
const foundItem = this.board.items.getById(childId);
|
|
48034
48061
|
if (this.parent !== childId && this.getId() !== childId) {
|
|
48035
|
-
|
|
48062
|
+
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
|
|
48063
|
+
if (canAddItem) {
|
|
48064
|
+
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
48036
48065
|
foundItem.transformation.apply({
|
|
48037
48066
|
class: "Transformation",
|
|
48038
48067
|
method: "translateTo",
|
|
48039
48068
|
item: [this.id],
|
|
48040
|
-
x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
|
|
48041
|
-
y: this.top
|
|
48069
|
+
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
48070
|
+
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
48042
48071
|
});
|
|
48043
48072
|
this.board.items.index.remove(foundItem);
|
|
48044
48073
|
foundItem.parent = this.getId();
|
package/dist/cjs/index.js
CHANGED
|
@@ -7069,7 +7069,7 @@ var conf = {
|
|
|
7069
7069
|
FALLBACK_LNG: "en",
|
|
7070
7070
|
cursorsMap,
|
|
7071
7071
|
DECK_HORIZONTAL_OFFSET: 2,
|
|
7072
|
-
DECK_VERTICAL_OFFSET:
|
|
7072
|
+
DECK_VERTICAL_OFFSET: 2,
|
|
7073
7073
|
CARD_DIMENSIONS: { width: 250, height: 400 }
|
|
7074
7074
|
};
|
|
7075
7075
|
initDefaultI18N();
|
|
@@ -42121,10 +42121,22 @@ class ImageItem extends BaseItem {
|
|
|
42121
42121
|
};
|
|
42122
42122
|
updateMbr() {
|
|
42123
42123
|
const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
|
|
42124
|
-
|
|
42125
|
-
this.
|
|
42126
|
-
|
|
42127
|
-
|
|
42124
|
+
const rotation = this.transformation.getRotation();
|
|
42125
|
+
const width2 = this.image.width * scaleX;
|
|
42126
|
+
const height2 = this.image.height * scaleY;
|
|
42127
|
+
if (rotation % 180 === 0) {
|
|
42128
|
+
this.left = translateX;
|
|
42129
|
+
this.top = translateY;
|
|
42130
|
+
this.right = this.left + width2;
|
|
42131
|
+
this.bottom = this.top + height2;
|
|
42132
|
+
} else {
|
|
42133
|
+
const centerX = translateX + width2 / 2;
|
|
42134
|
+
const centerY = translateY + height2 / 2;
|
|
42135
|
+
this.left = centerX - height2 / 2;
|
|
42136
|
+
this.top = centerY - width2 / 2;
|
|
42137
|
+
this.right = this.left + height2;
|
|
42138
|
+
this.bottom = this.top + width2;
|
|
42139
|
+
}
|
|
42128
42140
|
}
|
|
42129
42141
|
doOnceBeforeOnLoad = (callback) => {
|
|
42130
42142
|
this.loadCallbacks.push(callback);
|
|
@@ -42229,6 +42241,14 @@ class ImageItem extends BaseItem {
|
|
|
42229
42241
|
const ctx = context.ctx;
|
|
42230
42242
|
ctx.save();
|
|
42231
42243
|
this.transformation.matrix.applyToContext(ctx);
|
|
42244
|
+
const rotation = this.transformation.getRotation();
|
|
42245
|
+
if (rotation !== 0) {
|
|
42246
|
+
const imgWidth = this.image.width || 0;
|
|
42247
|
+
const imgHeight = this.image.height || 0;
|
|
42248
|
+
ctx.translate(imgWidth / 2, imgHeight / 2);
|
|
42249
|
+
ctx.rotate(rotation * Math.PI / 180);
|
|
42250
|
+
ctx.translate(-imgWidth / 2, -imgHeight / 2);
|
|
42251
|
+
}
|
|
42232
42252
|
ctx.drawImage(this.image, 0, 0);
|
|
42233
42253
|
ctx.restore();
|
|
42234
42254
|
if (this.getLinkTo()) {
|
|
@@ -47874,6 +47894,9 @@ class Card extends BaseItem {
|
|
|
47874
47894
|
getImage() {
|
|
47875
47895
|
return this.imageToRender;
|
|
47876
47896
|
}
|
|
47897
|
+
getIsRotatedPerpendicular() {
|
|
47898
|
+
return Boolean(this.transformation.getRotation() % 180);
|
|
47899
|
+
}
|
|
47877
47900
|
render(context, left, top) {
|
|
47878
47901
|
if (this.transformationRenderBlock) {
|
|
47879
47902
|
return;
|
|
@@ -47886,7 +47909,7 @@ class Card extends BaseItem {
|
|
|
47886
47909
|
const height3 = this.getHeight();
|
|
47887
47910
|
if (typeof left === "number" && typeof top === "number") {
|
|
47888
47911
|
centerX = left + width2 / 2;
|
|
47889
|
-
|
|
47912
|
+
centerY = top + height3 / 2;
|
|
47890
47913
|
}
|
|
47891
47914
|
ctx.translate(centerX, centerY);
|
|
47892
47915
|
ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
|
|
@@ -48014,6 +48037,7 @@ class Deck extends BaseItem {
|
|
|
48014
48037
|
isCacheDirty = true;
|
|
48015
48038
|
enableResize = false;
|
|
48016
48039
|
path = null;
|
|
48040
|
+
isPerpendicular = undefined;
|
|
48017
48041
|
constructor(board, id = "") {
|
|
48018
48042
|
super(board, id, defaultDeckData, true);
|
|
48019
48043
|
this.index.getUnderPoint = () => [];
|
|
@@ -48025,6 +48049,9 @@ class Deck extends BaseItem {
|
|
|
48025
48049
|
});
|
|
48026
48050
|
this.updateMbr();
|
|
48027
48051
|
}
|
|
48052
|
+
getIsPerpendicular() {
|
|
48053
|
+
return this.isPerpendicular;
|
|
48054
|
+
}
|
|
48028
48055
|
applyAddChildren(childIds) {
|
|
48029
48056
|
if (!this.index) {
|
|
48030
48057
|
return;
|
|
@@ -48032,13 +48059,15 @@ class Deck extends BaseItem {
|
|
|
48032
48059
|
childIds.forEach((childId) => {
|
|
48033
48060
|
const foundItem = this.board.items.getById(childId);
|
|
48034
48061
|
if (this.parent !== childId && this.getId() !== childId) {
|
|
48035
|
-
|
|
48062
|
+
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
|
|
48063
|
+
if (canAddItem) {
|
|
48064
|
+
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
48036
48065
|
foundItem.transformation.apply({
|
|
48037
48066
|
class: "Transformation",
|
|
48038
48067
|
method: "translateTo",
|
|
48039
48068
|
item: [this.id],
|
|
48040
|
-
x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
|
|
48041
|
-
y: this.top
|
|
48069
|
+
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
48070
|
+
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
48042
48071
|
});
|
|
48043
48072
|
this.board.items.index.remove(foundItem);
|
|
48044
48073
|
foundItem.parent = this.getId();
|
package/dist/cjs/node.js
CHANGED
|
@@ -8106,7 +8106,7 @@ var conf = {
|
|
|
8106
8106
|
FALLBACK_LNG: "en",
|
|
8107
8107
|
cursorsMap,
|
|
8108
8108
|
DECK_HORIZONTAL_OFFSET: 2,
|
|
8109
|
-
DECK_VERTICAL_OFFSET:
|
|
8109
|
+
DECK_VERTICAL_OFFSET: 2,
|
|
8110
8110
|
CARD_DIMENSIONS: { width: 250, height: 400 }
|
|
8111
8111
|
};
|
|
8112
8112
|
initDefaultI18N();
|
|
@@ -44594,10 +44594,22 @@ class ImageItem extends BaseItem {
|
|
|
44594
44594
|
};
|
|
44595
44595
|
updateMbr() {
|
|
44596
44596
|
const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
|
|
44597
|
-
|
|
44598
|
-
this.
|
|
44599
|
-
|
|
44600
|
-
|
|
44597
|
+
const rotation = this.transformation.getRotation();
|
|
44598
|
+
const width2 = this.image.width * scaleX;
|
|
44599
|
+
const height2 = this.image.height * scaleY;
|
|
44600
|
+
if (rotation % 180 === 0) {
|
|
44601
|
+
this.left = translateX;
|
|
44602
|
+
this.top = translateY;
|
|
44603
|
+
this.right = this.left + width2;
|
|
44604
|
+
this.bottom = this.top + height2;
|
|
44605
|
+
} else {
|
|
44606
|
+
const centerX = translateX + width2 / 2;
|
|
44607
|
+
const centerY = translateY + height2 / 2;
|
|
44608
|
+
this.left = centerX - height2 / 2;
|
|
44609
|
+
this.top = centerY - width2 / 2;
|
|
44610
|
+
this.right = this.left + height2;
|
|
44611
|
+
this.bottom = this.top + width2;
|
|
44612
|
+
}
|
|
44601
44613
|
}
|
|
44602
44614
|
doOnceBeforeOnLoad = (callback) => {
|
|
44603
44615
|
this.loadCallbacks.push(callback);
|
|
@@ -44702,6 +44714,14 @@ class ImageItem extends BaseItem {
|
|
|
44702
44714
|
const ctx = context.ctx;
|
|
44703
44715
|
ctx.save();
|
|
44704
44716
|
this.transformation.matrix.applyToContext(ctx);
|
|
44717
|
+
const rotation = this.transformation.getRotation();
|
|
44718
|
+
if (rotation !== 0) {
|
|
44719
|
+
const imgWidth = this.image.width || 0;
|
|
44720
|
+
const imgHeight = this.image.height || 0;
|
|
44721
|
+
ctx.translate(imgWidth / 2, imgHeight / 2);
|
|
44722
|
+
ctx.rotate(rotation * Math.PI / 180);
|
|
44723
|
+
ctx.translate(-imgWidth / 2, -imgHeight / 2);
|
|
44724
|
+
}
|
|
44705
44725
|
ctx.drawImage(this.image, 0, 0);
|
|
44706
44726
|
ctx.restore();
|
|
44707
44727
|
if (this.getLinkTo()) {
|
|
@@ -50347,6 +50367,9 @@ class Card extends BaseItem {
|
|
|
50347
50367
|
getImage() {
|
|
50348
50368
|
return this.imageToRender;
|
|
50349
50369
|
}
|
|
50370
|
+
getIsRotatedPerpendicular() {
|
|
50371
|
+
return Boolean(this.transformation.getRotation() % 180);
|
|
50372
|
+
}
|
|
50350
50373
|
render(context, left, top) {
|
|
50351
50374
|
if (this.transformationRenderBlock) {
|
|
50352
50375
|
return;
|
|
@@ -50359,7 +50382,7 @@ class Card extends BaseItem {
|
|
|
50359
50382
|
const height3 = this.getHeight();
|
|
50360
50383
|
if (typeof left === "number" && typeof top === "number") {
|
|
50361
50384
|
centerX = left + width2 / 2;
|
|
50362
|
-
|
|
50385
|
+
centerY = top + height3 / 2;
|
|
50363
50386
|
}
|
|
50364
50387
|
ctx.translate(centerX, centerY);
|
|
50365
50388
|
ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
|
|
@@ -50487,6 +50510,7 @@ class Deck extends BaseItem {
|
|
|
50487
50510
|
isCacheDirty = true;
|
|
50488
50511
|
enableResize = false;
|
|
50489
50512
|
path = null;
|
|
50513
|
+
isPerpendicular = undefined;
|
|
50490
50514
|
constructor(board, id = "") {
|
|
50491
50515
|
super(board, id, defaultDeckData, true);
|
|
50492
50516
|
this.index.getUnderPoint = () => [];
|
|
@@ -50498,6 +50522,9 @@ class Deck extends BaseItem {
|
|
|
50498
50522
|
});
|
|
50499
50523
|
this.updateMbr();
|
|
50500
50524
|
}
|
|
50525
|
+
getIsPerpendicular() {
|
|
50526
|
+
return this.isPerpendicular;
|
|
50527
|
+
}
|
|
50501
50528
|
applyAddChildren(childIds) {
|
|
50502
50529
|
if (!this.index) {
|
|
50503
50530
|
return;
|
|
@@ -50505,13 +50532,15 @@ class Deck extends BaseItem {
|
|
|
50505
50532
|
childIds.forEach((childId) => {
|
|
50506
50533
|
const foundItem = this.board.items.getById(childId);
|
|
50507
50534
|
if (this.parent !== childId && this.getId() !== childId) {
|
|
50508
|
-
|
|
50535
|
+
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
|
|
50536
|
+
if (canAddItem) {
|
|
50537
|
+
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
50509
50538
|
foundItem.transformation.apply({
|
|
50510
50539
|
class: "Transformation",
|
|
50511
50540
|
method: "translateTo",
|
|
50512
50541
|
item: [this.id],
|
|
50513
|
-
x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
|
|
50514
|
-
y: this.top
|
|
50542
|
+
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
50543
|
+
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
50515
50544
|
});
|
|
50516
50545
|
this.board.items.index.remove(foundItem);
|
|
50517
50546
|
foundItem.parent = this.getId();
|
package/dist/esm/browser.js
CHANGED
|
@@ -6906,7 +6906,7 @@ var conf = {
|
|
|
6906
6906
|
FALLBACK_LNG: "en",
|
|
6907
6907
|
cursorsMap,
|
|
6908
6908
|
DECK_HORIZONTAL_OFFSET: 2,
|
|
6909
|
-
DECK_VERTICAL_OFFSET:
|
|
6909
|
+
DECK_VERTICAL_OFFSET: 2,
|
|
6910
6910
|
CARD_DIMENSIONS: { width: 250, height: 400 }
|
|
6911
6911
|
};
|
|
6912
6912
|
initDefaultI18N();
|
|
@@ -41967,10 +41967,22 @@ class ImageItem extends BaseItem {
|
|
|
41967
41967
|
};
|
|
41968
41968
|
updateMbr() {
|
|
41969
41969
|
const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
|
|
41970
|
-
|
|
41971
|
-
this.
|
|
41972
|
-
|
|
41973
|
-
|
|
41970
|
+
const rotation = this.transformation.getRotation();
|
|
41971
|
+
const width2 = this.image.width * scaleX;
|
|
41972
|
+
const height2 = this.image.height * scaleY;
|
|
41973
|
+
if (rotation % 180 === 0) {
|
|
41974
|
+
this.left = translateX;
|
|
41975
|
+
this.top = translateY;
|
|
41976
|
+
this.right = this.left + width2;
|
|
41977
|
+
this.bottom = this.top + height2;
|
|
41978
|
+
} else {
|
|
41979
|
+
const centerX = translateX + width2 / 2;
|
|
41980
|
+
const centerY = translateY + height2 / 2;
|
|
41981
|
+
this.left = centerX - height2 / 2;
|
|
41982
|
+
this.top = centerY - width2 / 2;
|
|
41983
|
+
this.right = this.left + height2;
|
|
41984
|
+
this.bottom = this.top + width2;
|
|
41985
|
+
}
|
|
41974
41986
|
}
|
|
41975
41987
|
doOnceBeforeOnLoad = (callback) => {
|
|
41976
41988
|
this.loadCallbacks.push(callback);
|
|
@@ -42075,6 +42087,14 @@ class ImageItem extends BaseItem {
|
|
|
42075
42087
|
const ctx = context.ctx;
|
|
42076
42088
|
ctx.save();
|
|
42077
42089
|
this.transformation.matrix.applyToContext(ctx);
|
|
42090
|
+
const rotation = this.transformation.getRotation();
|
|
42091
|
+
if (rotation !== 0) {
|
|
42092
|
+
const imgWidth = this.image.width || 0;
|
|
42093
|
+
const imgHeight = this.image.height || 0;
|
|
42094
|
+
ctx.translate(imgWidth / 2, imgHeight / 2);
|
|
42095
|
+
ctx.rotate(rotation * Math.PI / 180);
|
|
42096
|
+
ctx.translate(-imgWidth / 2, -imgHeight / 2);
|
|
42097
|
+
}
|
|
42078
42098
|
ctx.drawImage(this.image, 0, 0);
|
|
42079
42099
|
ctx.restore();
|
|
42080
42100
|
if (this.getLinkTo()) {
|
|
@@ -47720,6 +47740,9 @@ class Card extends BaseItem {
|
|
|
47720
47740
|
getImage() {
|
|
47721
47741
|
return this.imageToRender;
|
|
47722
47742
|
}
|
|
47743
|
+
getIsRotatedPerpendicular() {
|
|
47744
|
+
return Boolean(this.transformation.getRotation() % 180);
|
|
47745
|
+
}
|
|
47723
47746
|
render(context, left, top) {
|
|
47724
47747
|
if (this.transformationRenderBlock) {
|
|
47725
47748
|
return;
|
|
@@ -47732,7 +47755,7 @@ class Card extends BaseItem {
|
|
|
47732
47755
|
const height3 = this.getHeight();
|
|
47733
47756
|
if (typeof left === "number" && typeof top === "number") {
|
|
47734
47757
|
centerX = left + width2 / 2;
|
|
47735
|
-
|
|
47758
|
+
centerY = top + height3 / 2;
|
|
47736
47759
|
}
|
|
47737
47760
|
ctx.translate(centerX, centerY);
|
|
47738
47761
|
ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
|
|
@@ -47860,6 +47883,7 @@ class Deck extends BaseItem {
|
|
|
47860
47883
|
isCacheDirty = true;
|
|
47861
47884
|
enableResize = false;
|
|
47862
47885
|
path = null;
|
|
47886
|
+
isPerpendicular = undefined;
|
|
47863
47887
|
constructor(board, id = "") {
|
|
47864
47888
|
super(board, id, defaultDeckData, true);
|
|
47865
47889
|
this.index.getUnderPoint = () => [];
|
|
@@ -47871,6 +47895,9 @@ class Deck extends BaseItem {
|
|
|
47871
47895
|
});
|
|
47872
47896
|
this.updateMbr();
|
|
47873
47897
|
}
|
|
47898
|
+
getIsPerpendicular() {
|
|
47899
|
+
return this.isPerpendicular;
|
|
47900
|
+
}
|
|
47874
47901
|
applyAddChildren(childIds) {
|
|
47875
47902
|
if (!this.index) {
|
|
47876
47903
|
return;
|
|
@@ -47878,13 +47905,15 @@ class Deck extends BaseItem {
|
|
|
47878
47905
|
childIds.forEach((childId) => {
|
|
47879
47906
|
const foundItem = this.board.items.getById(childId);
|
|
47880
47907
|
if (this.parent !== childId && this.getId() !== childId) {
|
|
47881
|
-
|
|
47908
|
+
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
|
|
47909
|
+
if (canAddItem) {
|
|
47910
|
+
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
47882
47911
|
foundItem.transformation.apply({
|
|
47883
47912
|
class: "Transformation",
|
|
47884
47913
|
method: "translateTo",
|
|
47885
47914
|
item: [this.id],
|
|
47886
|
-
x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
|
|
47887
|
-
y: this.top
|
|
47915
|
+
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
47916
|
+
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
47888
47917
|
});
|
|
47889
47918
|
this.board.items.index.remove(foundItem);
|
|
47890
47919
|
foundItem.parent = this.getId();
|
package/dist/esm/index.js
CHANGED
|
@@ -6899,7 +6899,7 @@ var conf = {
|
|
|
6899
6899
|
FALLBACK_LNG: "en",
|
|
6900
6900
|
cursorsMap,
|
|
6901
6901
|
DECK_HORIZONTAL_OFFSET: 2,
|
|
6902
|
-
DECK_VERTICAL_OFFSET:
|
|
6902
|
+
DECK_VERTICAL_OFFSET: 2,
|
|
6903
6903
|
CARD_DIMENSIONS: { width: 250, height: 400 }
|
|
6904
6904
|
};
|
|
6905
6905
|
initDefaultI18N();
|
|
@@ -41960,10 +41960,22 @@ class ImageItem extends BaseItem {
|
|
|
41960
41960
|
};
|
|
41961
41961
|
updateMbr() {
|
|
41962
41962
|
const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
|
|
41963
|
-
|
|
41964
|
-
this.
|
|
41965
|
-
|
|
41966
|
-
|
|
41963
|
+
const rotation = this.transformation.getRotation();
|
|
41964
|
+
const width2 = this.image.width * scaleX;
|
|
41965
|
+
const height2 = this.image.height * scaleY;
|
|
41966
|
+
if (rotation % 180 === 0) {
|
|
41967
|
+
this.left = translateX;
|
|
41968
|
+
this.top = translateY;
|
|
41969
|
+
this.right = this.left + width2;
|
|
41970
|
+
this.bottom = this.top + height2;
|
|
41971
|
+
} else {
|
|
41972
|
+
const centerX = translateX + width2 / 2;
|
|
41973
|
+
const centerY = translateY + height2 / 2;
|
|
41974
|
+
this.left = centerX - height2 / 2;
|
|
41975
|
+
this.top = centerY - width2 / 2;
|
|
41976
|
+
this.right = this.left + height2;
|
|
41977
|
+
this.bottom = this.top + width2;
|
|
41978
|
+
}
|
|
41967
41979
|
}
|
|
41968
41980
|
doOnceBeforeOnLoad = (callback) => {
|
|
41969
41981
|
this.loadCallbacks.push(callback);
|
|
@@ -42068,6 +42080,14 @@ class ImageItem extends BaseItem {
|
|
|
42068
42080
|
const ctx = context.ctx;
|
|
42069
42081
|
ctx.save();
|
|
42070
42082
|
this.transformation.matrix.applyToContext(ctx);
|
|
42083
|
+
const rotation = this.transformation.getRotation();
|
|
42084
|
+
if (rotation !== 0) {
|
|
42085
|
+
const imgWidth = this.image.width || 0;
|
|
42086
|
+
const imgHeight = this.image.height || 0;
|
|
42087
|
+
ctx.translate(imgWidth / 2, imgHeight / 2);
|
|
42088
|
+
ctx.rotate(rotation * Math.PI / 180);
|
|
42089
|
+
ctx.translate(-imgWidth / 2, -imgHeight / 2);
|
|
42090
|
+
}
|
|
42071
42091
|
ctx.drawImage(this.image, 0, 0);
|
|
42072
42092
|
ctx.restore();
|
|
42073
42093
|
if (this.getLinkTo()) {
|
|
@@ -47713,6 +47733,9 @@ class Card extends BaseItem {
|
|
|
47713
47733
|
getImage() {
|
|
47714
47734
|
return this.imageToRender;
|
|
47715
47735
|
}
|
|
47736
|
+
getIsRotatedPerpendicular() {
|
|
47737
|
+
return Boolean(this.transformation.getRotation() % 180);
|
|
47738
|
+
}
|
|
47716
47739
|
render(context, left, top) {
|
|
47717
47740
|
if (this.transformationRenderBlock) {
|
|
47718
47741
|
return;
|
|
@@ -47725,7 +47748,7 @@ class Card extends BaseItem {
|
|
|
47725
47748
|
const height3 = this.getHeight();
|
|
47726
47749
|
if (typeof left === "number" && typeof top === "number") {
|
|
47727
47750
|
centerX = left + width2 / 2;
|
|
47728
|
-
|
|
47751
|
+
centerY = top + height3 / 2;
|
|
47729
47752
|
}
|
|
47730
47753
|
ctx.translate(centerX, centerY);
|
|
47731
47754
|
ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
|
|
@@ -47853,6 +47876,7 @@ class Deck extends BaseItem {
|
|
|
47853
47876
|
isCacheDirty = true;
|
|
47854
47877
|
enableResize = false;
|
|
47855
47878
|
path = null;
|
|
47879
|
+
isPerpendicular = undefined;
|
|
47856
47880
|
constructor(board, id = "") {
|
|
47857
47881
|
super(board, id, defaultDeckData, true);
|
|
47858
47882
|
this.index.getUnderPoint = () => [];
|
|
@@ -47864,6 +47888,9 @@ class Deck extends BaseItem {
|
|
|
47864
47888
|
});
|
|
47865
47889
|
this.updateMbr();
|
|
47866
47890
|
}
|
|
47891
|
+
getIsPerpendicular() {
|
|
47892
|
+
return this.isPerpendicular;
|
|
47893
|
+
}
|
|
47867
47894
|
applyAddChildren(childIds) {
|
|
47868
47895
|
if (!this.index) {
|
|
47869
47896
|
return;
|
|
@@ -47871,13 +47898,15 @@ class Deck extends BaseItem {
|
|
|
47871
47898
|
childIds.forEach((childId) => {
|
|
47872
47899
|
const foundItem = this.board.items.getById(childId);
|
|
47873
47900
|
if (this.parent !== childId && this.getId() !== childId) {
|
|
47874
|
-
|
|
47901
|
+
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
|
|
47902
|
+
if (canAddItem) {
|
|
47903
|
+
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
47875
47904
|
foundItem.transformation.apply({
|
|
47876
47905
|
class: "Transformation",
|
|
47877
47906
|
method: "translateTo",
|
|
47878
47907
|
item: [this.id],
|
|
47879
|
-
x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
|
|
47880
|
-
y: this.top
|
|
47908
|
+
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
47909
|
+
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
47881
47910
|
});
|
|
47882
47911
|
this.board.items.index.remove(foundItem);
|
|
47883
47912
|
foundItem.parent = this.getId();
|
package/dist/esm/node.js
CHANGED
|
@@ -7683,7 +7683,7 @@ var conf = {
|
|
|
7683
7683
|
FALLBACK_LNG: "en",
|
|
7684
7684
|
cursorsMap,
|
|
7685
7685
|
DECK_HORIZONTAL_OFFSET: 2,
|
|
7686
|
-
DECK_VERTICAL_OFFSET:
|
|
7686
|
+
DECK_VERTICAL_OFFSET: 2,
|
|
7687
7687
|
CARD_DIMENSIONS: { width: 250, height: 400 }
|
|
7688
7688
|
};
|
|
7689
7689
|
initDefaultI18N();
|
|
@@ -44428,10 +44428,22 @@ class ImageItem extends BaseItem {
|
|
|
44428
44428
|
};
|
|
44429
44429
|
updateMbr() {
|
|
44430
44430
|
const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
|
|
44431
|
-
|
|
44432
|
-
this.
|
|
44433
|
-
|
|
44434
|
-
|
|
44431
|
+
const rotation = this.transformation.getRotation();
|
|
44432
|
+
const width2 = this.image.width * scaleX;
|
|
44433
|
+
const height2 = this.image.height * scaleY;
|
|
44434
|
+
if (rotation % 180 === 0) {
|
|
44435
|
+
this.left = translateX;
|
|
44436
|
+
this.top = translateY;
|
|
44437
|
+
this.right = this.left + width2;
|
|
44438
|
+
this.bottom = this.top + height2;
|
|
44439
|
+
} else {
|
|
44440
|
+
const centerX = translateX + width2 / 2;
|
|
44441
|
+
const centerY = translateY + height2 / 2;
|
|
44442
|
+
this.left = centerX - height2 / 2;
|
|
44443
|
+
this.top = centerY - width2 / 2;
|
|
44444
|
+
this.right = this.left + height2;
|
|
44445
|
+
this.bottom = this.top + width2;
|
|
44446
|
+
}
|
|
44435
44447
|
}
|
|
44436
44448
|
doOnceBeforeOnLoad = (callback) => {
|
|
44437
44449
|
this.loadCallbacks.push(callback);
|
|
@@ -44536,6 +44548,14 @@ class ImageItem extends BaseItem {
|
|
|
44536
44548
|
const ctx = context.ctx;
|
|
44537
44549
|
ctx.save();
|
|
44538
44550
|
this.transformation.matrix.applyToContext(ctx);
|
|
44551
|
+
const rotation = this.transformation.getRotation();
|
|
44552
|
+
if (rotation !== 0) {
|
|
44553
|
+
const imgWidth = this.image.width || 0;
|
|
44554
|
+
const imgHeight = this.image.height || 0;
|
|
44555
|
+
ctx.translate(imgWidth / 2, imgHeight / 2);
|
|
44556
|
+
ctx.rotate(rotation * Math.PI / 180);
|
|
44557
|
+
ctx.translate(-imgWidth / 2, -imgHeight / 2);
|
|
44558
|
+
}
|
|
44539
44559
|
ctx.drawImage(this.image, 0, 0);
|
|
44540
44560
|
ctx.restore();
|
|
44541
44561
|
if (this.getLinkTo()) {
|
|
@@ -50181,6 +50201,9 @@ class Card extends BaseItem {
|
|
|
50181
50201
|
getImage() {
|
|
50182
50202
|
return this.imageToRender;
|
|
50183
50203
|
}
|
|
50204
|
+
getIsRotatedPerpendicular() {
|
|
50205
|
+
return Boolean(this.transformation.getRotation() % 180);
|
|
50206
|
+
}
|
|
50184
50207
|
render(context, left, top) {
|
|
50185
50208
|
if (this.transformationRenderBlock) {
|
|
50186
50209
|
return;
|
|
@@ -50193,7 +50216,7 @@ class Card extends BaseItem {
|
|
|
50193
50216
|
const height3 = this.getHeight();
|
|
50194
50217
|
if (typeof left === "number" && typeof top === "number") {
|
|
50195
50218
|
centerX = left + width2 / 2;
|
|
50196
|
-
|
|
50219
|
+
centerY = top + height3 / 2;
|
|
50197
50220
|
}
|
|
50198
50221
|
ctx.translate(centerX, centerY);
|
|
50199
50222
|
ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
|
|
@@ -50321,6 +50344,7 @@ class Deck extends BaseItem {
|
|
|
50321
50344
|
isCacheDirty = true;
|
|
50322
50345
|
enableResize = false;
|
|
50323
50346
|
path = null;
|
|
50347
|
+
isPerpendicular = undefined;
|
|
50324
50348
|
constructor(board, id = "") {
|
|
50325
50349
|
super(board, id, defaultDeckData, true);
|
|
50326
50350
|
this.index.getUnderPoint = () => [];
|
|
@@ -50332,6 +50356,9 @@ class Deck extends BaseItem {
|
|
|
50332
50356
|
});
|
|
50333
50357
|
this.updateMbr();
|
|
50334
50358
|
}
|
|
50359
|
+
getIsPerpendicular() {
|
|
50360
|
+
return this.isPerpendicular;
|
|
50361
|
+
}
|
|
50335
50362
|
applyAddChildren(childIds) {
|
|
50336
50363
|
if (!this.index) {
|
|
50337
50364
|
return;
|
|
@@ -50339,13 +50366,15 @@ class Deck extends BaseItem {
|
|
|
50339
50366
|
childIds.forEach((childId) => {
|
|
50340
50367
|
const foundItem = this.board.items.getById(childId);
|
|
50341
50368
|
if (this.parent !== childId && this.getId() !== childId) {
|
|
50342
|
-
|
|
50369
|
+
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
|
|
50370
|
+
if (canAddItem) {
|
|
50371
|
+
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
50343
50372
|
foundItem.transformation.apply({
|
|
50344
50373
|
class: "Transformation",
|
|
50345
50374
|
method: "translateTo",
|
|
50346
50375
|
item: [this.id],
|
|
50347
|
-
x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
|
|
50348
|
-
y: this.top
|
|
50376
|
+
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
50377
|
+
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
50349
50378
|
});
|
|
50350
50379
|
this.board.items.index.remove(foundItem);
|
|
50351
50380
|
foundItem.parent = this.getId();
|
|
@@ -25,6 +25,7 @@ export declare class Card extends BaseItem {
|
|
|
25
25
|
createImages(): void;
|
|
26
26
|
updateImageToRender(): void;
|
|
27
27
|
getImage(): HTMLImageElement | null;
|
|
28
|
+
getIsRotatedPerpendicular(): boolean;
|
|
28
29
|
render(context: DrawingContext, left?: number, top?: number): void;
|
|
29
30
|
renderHTML(documentFactory: DocumentFactory): HTMLElement;
|
|
30
31
|
updateMbr(): void;
|
|
@@ -14,7 +14,9 @@ export declare class Deck extends BaseItem {
|
|
|
14
14
|
private isCacheDirty;
|
|
15
15
|
enableResize: boolean;
|
|
16
16
|
path: Path | null;
|
|
17
|
+
private isPerpendicular;
|
|
17
18
|
constructor(board: Board, id?: string);
|
|
19
|
+
getIsPerpendicular(): boolean | undefined;
|
|
18
20
|
applyAddChildren(childIds: string[]): void;
|
|
19
21
|
applyRemoveChildren(childIds: string[]): void;
|
|
20
22
|
getDeck(): Card[];
|