let elt = document.getElementById(this.coordsToId([x, y]));
elt.classList.remove("in-shadow");
if (this.board[x][y] != "") {
- const color = this.getColor(i, j);
- const piece = this.getPiece(i, j);
+ const color = this.getColor(x, y);
+ const piece = this.getPiece(x, y);
this.g_pieces[x][y] = document.createElement("piece");
let newClasses = [
this.pieces()[piece]["class"],
// Touch screen, dragend
touchLocation = e.changedTouches[0];
if (touchLocation)
- return {x: touchLocation.pageX, y: touchLocation.pageY};
+ return {x: touchLocation.clientX, y: touchLocation.clientY};
return [0, 0]; //Big trouble here =)
}
e.preventDefault();
centerOnCursor(curPiece, e);
}
+ else if (e.changedTouches && e.changedTouches.length >= 1)
+ // Attempt to prevent horizontal swipe...
+ e.preventDefault();
};
const mouseup = (e) => {
document.addEventListener("touchmove", mousemove, {passive: false});
document.addEventListener("touchend", mouseup, {passive: false});
}
+ // TODO: onpointerdown/move/up ? See reveal.js /controllers/touch.js
}
showChoices(moves, r) {