mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
fix(wildlife): a tap selects only a sighting exactly under it again
A click read the scene's exact pick at the tap. Through the input dispatcher it read the click's id, which on a touch screen comes from the wider contact search: a tap near a sighting selected it, and one near another layer's contact kept the selection. It reads the exact top hit again, as the shipwrecks and Local ADS-B layers do.
This commit is contained in:
1 parent
cbc0c114eb
commit
4f24b9a062
3 files changed
+28
-5
No files matched your search
@@ -204,7 +204,9 @@ function harness(
|
||||
clicks.callback = (click) =>
|
||||
fn({
|
||||
screenPosition: click.position,
|
||||
id: picked?.id ?? picked?.primitive?.id ?? null,
|
||||
topHit: picked
|
||||
? { set: 'wildlife', id: picked.id ?? picked.primitive?.id }
|
||||
: null,
|
||||
});
|
||||
return () => {
|
||||
clicks.destroyed = true;
|
||||
|
||||
@@ -498,7 +498,13 @@ export function createSelection({ state, services, parts }) {
|
||||
return;
|
||||
}
|
||||
// A sighting icon's item id is its pick id, `wildlife:<stableId>`.
|
||||
const id = click.id;
|
||||
// Read from what is exactly under the click, as the scene's pick was:
|
||||
// a touch's wider contact search would select a sighting the tap
|
||||
// missed, or keep one open for a tap near another layer's contact.
|
||||
const picked = click.topHit;
|
||||
const id = picked
|
||||
? (services.picking?.resolvePickId?.(picked) ?? picked.id ?? null)
|
||||
: null;
|
||||
if (
|
||||
typeof id === 'string' &&
|
||||
id.startsWith('wildlife:') &&
|
||||
|
||||
@@ -99,9 +99,13 @@ function fixture(sighting = row, extraServices = {}) {
|
||||
for (const id of ids) painted.add(id);
|
||||
selection.photoCardsChanged();
|
||||
},
|
||||
click(id = `wildlife:${sighting.stableId}`) {
|
||||
// The input dispatcher hands the pick's registry-resolved id.
|
||||
click({ screenPosition: { x: 10, y: 20 }, id: id ?? undefined });
|
||||
click(id = `wildlife:${sighting.stableId}`, { touchId } = {}) {
|
||||
// The exact top hit, and the id a touch's wider contact search finds.
|
||||
click({
|
||||
screenPosition: { x: 10, y: 20 },
|
||||
topHit: id ? { set: 'wildlife', id } : null,
|
||||
id: touchId ?? id ?? undefined,
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -300,6 +304,17 @@ test('empty clicks and layer removal release the selected row and its overlay',
|
||||
assert.equal(f.entries.size, 0);
|
||||
});
|
||||
|
||||
test('a tap selects only a sighting exactly under it, not one the touch search found near it', () => {
|
||||
const f = fixture();
|
||||
f.selection.install();
|
||||
f.click(null, { touchId: `wildlife:${row.stableId}` });
|
||||
assert.equal(f.state.selectedId, null);
|
||||
f.click();
|
||||
assert.ok(f.state.selectedId);
|
||||
f.click(null, { touchId: 'other:aircraft' });
|
||||
assert.equal(f.state.selectedId, null, 'a tap near another contact clears');
|
||||
});
|
||||
|
||||
test('each sighting in context carries the point voice projects to find what is in view', () => {
|
||||
const registered = [];
|
||||
const f = fixture(row, {
|
||||
|
||||
Reference in new issue
Block a user