Add additional params to observable calls; reveal counter and record logic on selections
This commit is contained in:
@@ -359,7 +359,7 @@ function reveal(record) {
|
||||
record.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
|
||||
function select(data) {
|
||||
function select(data, opts) {
|
||||
const record = data && getRecord(data);
|
||||
const isSelected = record?.classList.contains('selected');
|
||||
|
||||
@@ -367,7 +367,7 @@ function select(data) {
|
||||
|
||||
if (isSelected || !data) return;
|
||||
|
||||
reveal(record);
|
||||
if (opts?.revealRecord) reveal(record);
|
||||
record.classList.add('selected');
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ function endMove() {
|
||||
selected.classList.toggle('movement-ended');
|
||||
deselect();
|
||||
|
||||
if (next) Observable.notify('select', next);
|
||||
if (next) Observable.notify('select', next, { revealCounter: true, revealRecord: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ export function start(startLoc, units) {
|
||||
}
|
||||
|
||||
document.querySelectorAll('.soldier-record').forEach(el =>
|
||||
el.addEventListener('click', () => Observable.notify('select', el))
|
||||
el.addEventListener('click', () => Observable.notify('select', el, { revealCounter: true }))
|
||||
);
|
||||
|
||||
Observable.subscribe('select', select);
|
||||
|
||||
Reference in New Issue
Block a user