Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/record_sheet.js')
-rw-r--r--src/modules/record_sheet.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js
index 824668e..e5be4bf 100644
--- a/src/modules/record_sheet.js
+++ b/src/modules/record_sheet.js
@@ -263,13 +263,14 @@ function endMove() {
const selected = getSelected();
if (selected) {
+ const list = selected.closest('.records').querySelectorAll('.soldier-record:not(.movement-ended, .inactive)');
+ const index = [...list].findIndex(s => s === selected);
+ const next = list.length > 1 ? list[(index + 1) % list.length] : null;
selected.classList.toggle('movement-ended');
- const next = selected.parentElement.querySelector(`.soldier-record[data-squad="${selected.dataset.squad}"]:not(.movement-ended, .inactive)`);
deselect();
if (next) {
Observable.notify('select', next);
- next.scrollIntoView({ behavior: 'smooth' });
}
}
}