+ const launchAnimation = () => {
+ const r =
+ document.getElementById(this.containerId).getBoundingClientRect();
+ const animateRec = i => {
+ this.animate(moves[i], () => {
+ this.playVisual(moves[i], r);
+ this.play(moves[i]);
+ if (i < moves.length - 1) setTimeout(() => animateRec(i+1), 300);
+ else callback();
+ });
+ };
+ animateRec(0);
+ };
+ 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");