+ const checkDisplayThenAnimate = () => {
+ if (boardContainer.style.display == "none") {
+ alert("New move! Let's go back to game...");
+ document.getElementById("gameInfos").style.display = "none";
+ boardContainer.style.display = "block";
+ setTimeout(launchAnimation, 700);
+ }
+ else launchAnimation(); //focused user!
+ };
+ let boardContainer = document.getElementById("boardContainer");
+ if (document.hidden) {
+ document.onvisibilitychange = () => {
+ document.onvisibilitychange = undefined;
+ checkDisplayThenAnimate();
+ };
+ }
+ else checkDisplayThenAnimate();