Eightpieces almost ready
[vchess.git] / client / src / components / Board.vue
index 5080e84..fdeeef3 100644 (file)
@@ -275,9 +275,10 @@ export default {
     if (!!this.vr.reserve) elementArray.push(reserveBottom);
     const boardElt = document.querySelector(".game");
     if (this.choices.length > 0 && !!boardElt) {
-      //no choices to show at first drawing
+      // No choices to show at first drawing
       const squareWidth = boardElt.offsetWidth / sizeY;
       const offset = [boardElt.offsetTop, boardElt.offsetLeft];
+      // TODO: multi-rows if more than V.size.y pieces (as inEightpieces)
       const choices = h(
         "div",
         {
@@ -294,7 +295,16 @@ export default {
           }
         },
         this.choices.map(m => {
-          //a "choice" is a move
+          // A "choice" is a move
+          const applyMove = (e) => {
+            e.stopPropagation();
+            this.play(m);
+            this.choices = [];
+          };
+          const onClick =
+            this.mobileBrowser
+              ? { touchend: applyMove }
+              : { mouseup: applyMove };
           return h(
             "div",
             {
@@ -316,12 +326,7 @@ export default {
                     ".svg"
                 },
                 class: { "choice-piece": true },
-                on: {
-                  click: () => {
-                    this.play(m);
-                    this.choices = [];
-                  }
-                }
+                on: onClick
               })
             ]
           );