From fd31883bca850ffe4b854d8cc52d7457a61b9010 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Thu, 11 Nov 2021 21:49:35 +0100
Subject: [PATCH] Wait until a player takes focus to animate a move

---
 base_rules.js | 7 +++++++
 1 file changed, 7 insertions(+)

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 => {
-- 
2.44.0