diff options
-rw-r--r-- | play.js | 48 |
1 files changed, 25 insertions, 23 deletions
@@ -107,8 +107,11 @@ function count_french_cu(s) { /* ANIMATION */ +var animation_list = [] + function remember_position(e) { if (e.parentElement) { + animation_list.push(e) let rect = e.getBoundingClientRect() e.my_parent = e.parentElement e.my_x = rect.x @@ -120,23 +123,26 @@ function remember_position(e) { } } -function animate_position(e) { - if (e.parentElement) { - if (e.my_parent) { - let rect = e.getBoundingClientRect() - let dx = e.my_x - rect.x - let dy = e.my_y - rect.y - if (dx !== 0 || dy !== 0) { - e.animate( - [ - { transform: `translate(${dx}px, ${dy}px)`, }, - { transform: "translate(0, 0)", }, - ], - { duration: 333, easing: "ease" } - ) +function animate_positions() { + for (let e of animation_list) { + if (e.parentElement) { + if (e.my_parent) { + let rect = e.getBoundingClientRect() + let dx = e.my_x - rect.x + let dy = e.my_y - rect.y + if (dx !== 0 || dy !== 0) { + e.animate( + [ + { transform: `translate(${dx}px, ${dy}px)`, }, + { transform: "translate(0, 0)", }, + ], + { duration: 333, easing: "ease" } + ) + } } } } + animation_list.length = 0 } /* BUILD UI */ @@ -491,25 +497,27 @@ function on_update() { e = document.getElementById("played_british_reinforcements") if (view.reinforcements[0] > 0) - e.className = "ops_" + CARDS[view.reinforcements[0]].count + e.className = "reinforcements ops_" + CARDS[view.reinforcements[0]].count else e.className = "" e = document.getElementById("played_american_reinforcements_1") if (view.reinforcements[1] > 0) - e.className = "ops_" + CARDS[view.reinforcements[1]].count + e.className = "reinforcements ops_" + CARDS[view.reinforcements[1]].count else e.className = "" e = document.getElementById("played_american_reinforcements_2") if (view.reinforcements[2] > 0) - e.className = "ops_" + CARDS[view.reinforcements[2]].count + e.className = "reinforcements ops_" + CARDS[view.reinforcements[2]].count else e.className = "" for (let e of action_register) e.classList.toggle("action", is_action(e.my_action, e.my_id)) + animate_positions() + action_button("pickup_french_cu", "Take French CU") action_button("pickup_british_cu", "Take CU") action_button("pickup_american_cu", "Take CU") @@ -525,12 +533,6 @@ function on_update() { action_button("pass", "Pass") action_button("undo", "Undo") - animate_position(ui.b_mcu) - animate_position(ui.a_mcu) - animate_position(ui.f_mcu) - for (let g = 0; g < general_count; ++g) - animate_position(ui.generals[g]) - } /* POPUP MENU */ |