mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +00:00
fix(input): no double-click follow or zoom on the map
The globe viewer's own double-click tracked a picked entity with a position or zoomed to one without. Layers moving onto the draw port had it re-created one by one (data/stockFollow.js); following is a click in GEV, so the viewer's handler is removed where the viewer is made and every re-creation goes: earthquakes, cyclones, air quality, news, perimeters, drone airspace, ghost maps, places, radio, cables, CCTV, ALPR, launches, bikeshare, Local ADS-B, installations, directions, trails, data packs, annotations, the library's view and local GeoJSON. The Cockpit's own double-click and the draw tool's finishing double-click stay.
This commit is contained in:
1 parent
bb2d22dbce
commit
b86014244d
69 files changed
+94
-2797
No files matched your search
@@ -2,7 +2,6 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createGhostMapsLayer } from './index.js';
|
||||
import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs';
|
||||
import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs';
|
||||
import { GHOSTMAPS_PRODUCTS, GHOSTMAPS_LATEST_DROP } from './catalog.js';
|
||||
|
||||
function element(localName, children = [], value = '', attributes = {}) {
|
||||
@@ -122,26 +121,13 @@ function fixture(
|
||||
const viewer = {};
|
||||
// An input port and a query port: a click picks what `click(id)` names.
|
||||
const listeners = new Set();
|
||||
const doubleListeners = new Set();
|
||||
let picked = null;
|
||||
const camera = fakeCameraPort();
|
||||
// What the camera follows, as the port's `follow` sets it.
|
||||
camera.port.followed = null;
|
||||
camera.port.follow = (target) => (camera.port.followed = target ?? null);
|
||||
const { draw, unbind } = bindFakeDraw(viewer, {
|
||||
camera: camera.port,
|
||||
input: {
|
||||
behaviours: { dblclickFollow: { enabled: true } },
|
||||
on(type, cb) {
|
||||
const into =
|
||||
type === 'click'
|
||||
? listeners
|
||||
: type === 'dblclick'
|
||||
? doubleListeners
|
||||
: null;
|
||||
if (!into) return () => {};
|
||||
into.add(cb);
|
||||
return () => into.delete(cb);
|
||||
if (type !== 'click') return () => {};
|
||||
listeners.add(cb);
|
||||
return () => listeners.delete(cb);
|
||||
},
|
||||
},
|
||||
query: { pick: () => picked },
|
||||
@@ -165,17 +151,6 @@ function fixture(
|
||||
modifiers: { shift: false, ctrl: false, alt: false },
|
||||
});
|
||||
};
|
||||
const dblclick = (id) => {
|
||||
const set = items().get(id);
|
||||
picked = set ? { set, id, surface: false } : null;
|
||||
for (const cb of [...doubleListeners])
|
||||
cb({
|
||||
type: 'dblclick',
|
||||
position: { x: 0, y: 0 },
|
||||
button: 0,
|
||||
modifiers: { shift: false, ctrl: false, alt: false },
|
||||
});
|
||||
};
|
||||
// The editions drawn: each draws in sets of its own.
|
||||
const mounted = {
|
||||
get size() {
|
||||
@@ -216,8 +191,6 @@ function fixture(
|
||||
items,
|
||||
liveSets,
|
||||
click,
|
||||
dblclick,
|
||||
camera: camera.port,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -669,13 +642,3 @@ test('narrowing to a window the loaded data covers clears a failed wider reload'
|
||||
assert.equal(layer.getStats().error, null);
|
||||
assert.equal(layer.getStats().count, 1);
|
||||
});
|
||||
|
||||
test('a double-click follows a pin until its edition goes, as its entity was', async (t) => {
|
||||
const { layer, viewer, dblclick, camera } = fixture(t);
|
||||
await layer.update(viewer);
|
||||
dblclick('ghostmaps:cip:0:0');
|
||||
assert.ok(camera.followed, 'the pin is followed');
|
||||
assert.match(camera.followed.key, /:icons:ghostmaps:cip:0:0$/);
|
||||
layer.disable();
|
||||
assert.equal(camera.followed, null, 'its edition gone, so is the follow');
|
||||
});
|
||||
Reference in new issue
Block a user