From 74fcb45428637275e9ee93545a67f79b960cc6ba Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Tue, 29 Dec 2020 17:25:37 +0100 Subject: [PATCH] Experimenting smartphone 'touch' move confirmation --- client/src/components/BaseGame.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 61c67dec..5f825c92 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -92,6 +92,7 @@ export default { moves: [], cursor: -1, //index of the move just played lastMove: null, + touchLastClick: "", firstMoveNumber: 0, //for printing incheck: [], //for Board inMultimove: false, @@ -434,8 +435,16 @@ export default { // Some variants make use of a single click at specific times: const move_s = this.vr.doClick(square); if (!!move_s) { - if (!Array.isArray(move_s)) this.play(move_s); - else this.$refs["board"].choices = move_s; + const playMove = () => { + if (!Array.isArray(move_s)) this.play(move_s); + else this.$refs["board"].choices = move_s; + } + if ("ontouchstart" in window) { + // Touch screen (smartphone): require confirmation + if (this.touchLastClick == square) playMove(); + this.touchLastClick = square; + } + else playMove(); } }, // "light": if gotoMove() or gotoEnd() -- 2.44.0