From: Steinar H. Gunderson Date: Sun, 20 Mar 2016 11:04:25 +0000 (+0100) Subject: Keep track of whether the board is animating (not used for anything yet). X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=e013c00f3db60d47d7911b7c2e6c2219d5e1a148 Keep track of whether the board is animating (not used for anything yet). --- diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index b235031..da9f70a 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -20,6 +20,9 @@ var backend_url = "/analysis.pl"; /** @type {window.ChessBoard} @private */ var board = null; +/** @type {boolean} @private */ +var board_is_animating = false; + /** * The most recent analysis data we have from the server * (about the most recent position). @@ -1489,7 +1492,10 @@ var update_displayed_line = function() { } var hiddenboard = chess_from(current_display_line.start_fen, current_display_line.pretty_pv, current_display_move); + board_is_animating = true; + var old_fen = board.fen(); board.position(hiddenboard.fen()); + if (board.fen() === old_fen) board_is_animating = false; update_imbalance(hiddenboard.fen()); } @@ -1567,7 +1573,9 @@ var init = function() { } // Create board. - board = new window.ChessBoard('board', 'start'); + board = new window.ChessBoard('board', { + onMoveEnd: function() { board_is_animating = false; } + }); request_update(); $(window).resize(function() {