mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +00:00
fix(earthquakes, cyclones): an item that goes takes its double-click follow with it
Removing a followed entity ended the default renderer's follow. A disc gone from the feed, or a storm point gone from the advisory (or a cleared one), now ends it too.
This commit is contained in:
1 parent
def2e1ecca
commit
fbc40ef3b6
6 files changed
+46
-2
No files matched your search
@@ -181,6 +181,10 @@ export function createEarthquakesLayer({
|
||||
|
||||
_discs.set(nextDiscs);
|
||||
_discsById = nextById;
|
||||
// A disc no longer reported takes its follow with it.
|
||||
_stockFollow?.retain((key) =>
|
||||
_discsById.has(key.slice(_discs.id.length + 1)),
|
||||
);
|
||||
_events = nextEvents;
|
||||
if (_enabled) {
|
||||
overlayHost.setEntries(
|
||||
|
||||
@@ -178,9 +178,10 @@ test('a double-click follows a disc, framed to fit it, as its entity was', async
|
||||
const viewer = { isDestroyed: () => false };
|
||||
const unbind = bindRenderer(viewer, renderer);
|
||||
const layer = createEarthquakesLayer({
|
||||
source: { getSnapshot: async () => [row] },
|
||||
source: { getSnapshot: async () => rows },
|
||||
overlayHost: { setEntries() {}, setVisible() {}, clearSource() {} },
|
||||
});
|
||||
let rows = [row];
|
||||
t.after(() => {
|
||||
layer.destroy(viewer);
|
||||
unbind();
|
||||
@@ -203,6 +204,19 @@ test('a double-click follows a disc, framed to fit it, as its entity was', async
|
||||
const p = followed.position(0);
|
||||
const lon = (Math.atan2(p.y, p.x) * 180) / Math.PI;
|
||||
assert.ok(Math.abs(lon - row.lon) < 1e-9, String(lon));
|
||||
await layer.update(viewer);
|
||||
assert.ok(renderer.camera.followed, 'still reported: still followed');
|
||||
rows = [{ ...row, stableId: 'event-b', usgsId: 'event-b' }];
|
||||
await layer.update(viewer);
|
||||
assert.equal(
|
||||
renderer.camera.followed,
|
||||
null,
|
||||
'gone from the feed: not followed',
|
||||
);
|
||||
rows = [row];
|
||||
await layer.update(viewer);
|
||||
renderer.testing.pointer('dblclick', 10, 10);
|
||||
assert.ok(renderer.camera.followed);
|
||||
layer.disable(viewer);
|
||||
assert.equal(renderer.camera.followed, null, 'hiding the layer stops it');
|
||||
});
|
||||
Reference in new issue
Block a user