From: Benjamin Auder Date: Thu, 11 Nov 2021 20:49:35 +0000 (+0100) Subject: Wait until a player takes focus to animate a move X-Git-Url: https://git.auder.net/variants/Chakart/%7B%7B%20path%28%27mixstore_user_admin_delete%27%2C%20%7B%20id:%20user.id%20%7D%29%20%7D%7D?a=commitdiff_plain;h=fd31883bca850ffe4b854d8cc52d7457a61b9010;p=xogo.git Wait until a player takes focus to animate a move --- diff --git a/base_rules.js b/base_rules.js index ffb9fd6..6f11aa1 100644 --- a/base_rules.js +++ b/base_rules.js @@ -2067,6 +2067,13 @@ export default class ChessRules { } playReceivedMove(moves, callback) { + if (!document.hasFocus()) { + window.onfocus = () => { + window.onfocus = undefined; + setTimeout(() => this.playReceivedMove(moves, callback), 700); + }; + return; + } const r = document.getElementById(this.containerId).getBoundingClientRect(); const animateRec = i => {