X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=base_rules.js;h=a39cc0a835b54e0598fbf44005aa71ecbd327b92;hb=bb3d72a8b98cd8249b528201a83b4e6baab7936e;hp=30cb2726491ffa700c6a3f19e5c6fb6c3f625eb7;hpb=1aa9054d1d0564f97e8e01504a0363859d07c7f8;p=xogo.git diff --git a/base_rules.js b/base_rules.js index 30cb272..a39cc0a 100644 --- a/base_rules.js +++ b/base_rules.js @@ -495,8 +495,8 @@ export default class ChessRules { 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"], @@ -859,7 +859,7 @@ export default class ChessRules { // 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 =) } @@ -909,6 +909,9 @@ export default class ChessRules { e.preventDefault(); centerOnCursor(curPiece, e); } + else if (e.changedTouches && e.changedTouches.length >= 1) + // Attempt to prevent horizontal swipe... + e.preventDefault(); }; const mouseup = (e) => { @@ -949,6 +952,7 @@ export default class ChessRules { 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) {