circles: {}, //object of squares' ID --> true (TODO: use a set?)
click: "",
clickTime: 0,
+ initialized: 0,
settings: store.state.settings
};
},
(!myReserveTop && !!this.vr.reserve[playingColor])
);
// Center reserves, assuming same number of pieces for each side:
- const nbReservePieces = myReservePiecesArray.length;
+ const nbReservePieces =
+ Math.max(myReservePiecesArray.length, oppReservePiecesArray.length);
const marginLeft =
((100 - nbReservePieces * (100 / reserveSquareNb)) / 2) + "%";
if (hasReserveTop) {
}
};
}
+ if (this.initialized == 1) this.$emit("rendered");
+ if (this.initialized <= 1) this.initialized++;
return (
h(
"div",
document.getElementById("rootBoardElement").appendChild(arrowCanvas);
},
mousedown: function(e) {
- e.preventDefault();
if (!this.mobileBrowser && e.which != 3)
// Cancel current drawing and circles, if any
this.cancelResetArrows();
document.getElementById("boardContainer").getBoundingClientRect();
// NOTE: classList[0] is enough: 'piece' is the first assigned class
const withPiece = (e.target.classList[0] == "piece");
+ if (withPiece) e.preventDefault();
// Show possible moves if current player allowed to play
const startSquare =
getSquareFromId(withPiece ? e.target.parentNode.id : e.target.id);
}
else if (e.which == 3) {
// Mouse right button
+ e.preventDefault();
this.containerPos =
document.getElementById("gamePosition").getBoundingClientRect();
let elem = e.target;
while (elem.tagName == "IMG") elem = elem.parentNode;
this.startArrow = getSquareFromId(elem.id);
}
+ else e.preventDefault();
},
mousemove: function(e) {
if (!this.selectedPiece && !this.startArrow) return;
}
},
mouseup: function(e) {
- e.preventDefault();
if (this.mobileBrowser || e.which == 1) {
if (!this.selectedPiece) return;
+ e.preventDefault();
// Drag'n drop. Selected piece is no longer needed:
this.selectedPiece.parentNode.removeChild(this.selectedPiece);
delete this.selectedPiece;
this.selectedPiece = null;
this.processMoveAttempt(e);
- } else if (e.which == 3) {
+ }
+ else if (e.which == 3) {
+ e.preventDefault();
if (!this.startArrow) return;
// Mouse right button
this.movingArrow = null;
</style>
<style lang="sass" scoped>
-@import "@/styles/_board_squares_img.sass";
+@import "@/styles/_board_squares_img.sass"
//.game.reserve-div
// TODO: would be cleaner to restrict width so that it doesn't overflow