X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=base_rules.js;h=82eec3a6cedf8a44051322be3848dc26d5a3568a;hb=cb17fed82eff544b3e8a340584dd8f61a905f06f;hp=4808d0c22eed87c4a4870119bfa9d0949f21b514;hpb=dbc2acb0bcbeec800f7b24494e3224a4e3dc35e8;p=xogo.git diff --git a/base_rules.js b/base_rules.js index 4808d0c..82eec3a 100644 --- a/base_rules.js +++ b/base_rules.js @@ -876,6 +876,8 @@ export default class ChessRules { startPiece, curPiece = null, sqSize; const mousedown = (e) => { + // Disable zoom on smartphones: + if (e.touches && e.touches.length > 1) e.preventDefault(); r = container.getBoundingClientRect(); sqSize = this.getSquareWidth(r.width); const square = this.idToCoords(e.target.id); @@ -943,9 +945,10 @@ export default class ChessRules { document.addEventListener("mouseup", mouseup); } if ('ontouchstart' in window) { - document.addEventListener("touchstart", mousedown); - document.addEventListener("touchmove", mousemove); - document.addEventListener("touchend", mouseup); + // https://stackoverflow.com/a/42509310/12660887 + document.addEventListener("touchstart", mousedown, {passive: false}); + document.addEventListener("touchmove", mousemove, {passive: false}); + document.addEventListener("touchend", mouseup, {passive: false}); } }