Enable rotating with the right mouse button

This commit is contained in:
Andrio Celos
2023-02-22 23:59:58 +11:00
parent 7cc60b49d1
commit 22bcc42858

View File

@@ -214,6 +214,18 @@ class Board {
td.dataset.x = x.toString();
td.dataset.y = y.toString();
col.push(td);
td.addEventListener('click', e => {
if (this.autoHighlight && this.cardPlaying != null && this.onclick) {
if (this.touchscreenMode) {
this.onclick(this.highlightX, this.highlightY);
} else {
const x = parseInt((e.target as HTMLTableCellElement).dataset.x!) - (this.flip ? 4 : 3);
const y = parseInt((e.target as HTMLTableCellElement).dataset.y!) - (this.flip ? 4 : 3);
this.onclick(x, y);
}
}
});
td.addEventListener('contextmenu', e => e.preventDefault());
td.addEventListener('mousemove', e => {
if (e.buttons == 0)
this.touchscreenMode = false;
@@ -229,14 +241,11 @@ class Board {
}
}
});
td.addEventListener('click', e => {
if (this.autoHighlight && this.cardPlaying != null && this.onclick) {
if (this.touchscreenMode) {
this.onclick(this.highlightX, this.highlightY);
} else {
const x = parseInt((e.target as HTMLTableCellElement).dataset.x!) - (this.flip ? 4 : 3);
const y = parseInt((e.target as HTMLTableCellElement).dataset.y!) - (this.flip ? 4 : 3);
this.onclick(x, y);
td.addEventListener('mouseup', e => {
if (this.autoHighlight && this.cardPlaying != null) {
if (e.button == 2) {
this.cardRotation++;
this.refreshHighlight();
}
}
});