mousedown: this.mousedown,
mousemove: this.mousemove,
mouseup: this.mouseup,
- touchdown: this.mousedown,
- touchmove: this.mousemove,
- touchup: this.mouseup,
+// touchstart: this.mousedown, //TODO...
+// touchmove: this.mousemove,
+// touchend: this.mouseup,
},
},
elementArray
},
mousedown: function(e) {
e = e || window.event;
+ let ingame = false;
+ let elem = e.target;
+ while (!ingame && elem !== null)
+ {
+ if (elem.classList.contains("game"))
+ {
+ ingame = true;
+ break;
+ }
+ elem = elem.parentElement;
+ }
+ if (!ingame) //let default behavior (click on button...)
+ return;
e.preventDefault(); //disable native drag & drop
if (!this.selectedPiece && e.target.classList.contains("piece"))
{
this.possibleMoves = this.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare)
? this.vr.getPossibleMovesFrom(startSquare)
: [];
- console.log(this.possibleMoves);
- console.log(this.vr.promoted);
- e.target.parentNode.appendChild(this.selectedPiece);
+ // Next line add moving piece just after current image (required for Crazyhouse reserve)
+ e.target.parentNode.insertBefore(this.selectedPiece, e.target.nextSibling);
}
},
mousemove: function(e) {