mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
fix(click): the card or label on top takes the click in every layer
Review fixes for #1781: - One rule for cards: the world-overlay host hands its hit test to the pick registry, and every click handler reads the topmost interactive card or label once per click (`clickCard`, `isUnderOtherCard` in src/data/pickRegistry.js), so all handlers agree in any listener order. A layer whose own card or label is on top acts on it whatever is drawn under it; a layer under another layer's card neither acts nor treats the click as empty space (a tracked aircraft stays tracked, a selection stays selected); Context names nothing under a card. A selected news card over a vessel no longer opens the link and selects the vessel. - With one rule, the per-owner arbitration options are no longer read and are removed: `passive`, `expanded` and `declinesClick` pick owners, `rememberClickPickActions`, `isActedOnByOtherLayer`, card backgrounds and `cardKeepsClick`. The dispatcher is unchanged from main. - A drag that ends on a quake disc, label or card does nothing; opening the USGS page or clearing the selection needs a clean click. - A click on the map under another layer's card opens no Street Level ground image. - A CCTV card that is going away is still not the scene under it. - Docs and changelog describe the new rule.
This commit is contained in:
1 parent
7312280817
commit
bb3bf9858b
87 files changed
+1398
-1775
No files matched your search
@@ -23,29 +23,22 @@ export function createSelection({ state, parts }) {
|
||||
/** The id carries a provider's prefix: that provider handles the pick. */
|
||||
function onClick(event) {
|
||||
if (!state.viewer || !state.enabled) return;
|
||||
// Another layer's card or label painted on top takes the click, read once
|
||||
// per click so every layer agrees: no image, sequence or ground under it
|
||||
// opens. Street Level paints no cards of its own.
|
||||
if (picking?.isUnderOtherCard?.(event)) return;
|
||||
const hit = event.windowHit(CLICK_PICK_WINDOW_PX, CLICK_PICK_WINDOW_PX);
|
||||
const windowId = pickIdOf(hit);
|
||||
// A coarse tap's touch contact (event.hit) reaches farther than this
|
||||
// window; a card or label over it yields to our item there, so it is ours.
|
||||
// window: an item of ours there is still ours.
|
||||
const contact = event.hit;
|
||||
const contactId =
|
||||
contact && !contact.surface
|
||||
? pickIdOf({ drawHit: contact.set ? contact : null, id: event.id })
|
||||
: null;
|
||||
let route = parts.router.resolve(windowId);
|
||||
// Found only through our window, not as the contact (which is the exact
|
||||
// hit whenever there is one): another layer's card or label painted here
|
||||
// is that layer's click, since its handler never sees this window.
|
||||
// An item of ours that is the contact is still ours: that card yields
|
||||
// to it.
|
||||
if (route && windowId !== contactId) {
|
||||
const at = event.screenPosition;
|
||||
if (state.services.overlayHit?.(at?.x, at?.y)) {
|
||||
route = contactId ? parts.router.resolve(contactId) : null;
|
||||
if (!route) return;
|
||||
}
|
||||
}
|
||||
if (!route && contactId) route = parts.router.resolve(contactId);
|
||||
const route =
|
||||
parts.router.resolve(windowId) ??
|
||||
(contactId ? parts.router.resolve(contactId) : null);
|
||||
// Not ours: the ground handler decides whether it is the map itself.
|
||||
if (!route) {
|
||||
parts.openAtGround?.({ surface: hit.surface, ground: groundOf(event) });
|
||||
@@ -92,12 +85,7 @@ export function createSelection({ state, parts }) {
|
||||
if (state.clickSubscription) return;
|
||||
state.clickSubscription = inputFor(viewer).onClick(onClick);
|
||||
document.addEventListener('keydown', onKeyDown);
|
||||
picking?.registerPickOwner?.(STREET_LEVEL_LAYER_ID, parts.router.ownsPick, {
|
||||
expanded: true,
|
||||
// The core's position marker is ours but selects nothing: a card over
|
||||
// it keeps the tap.
|
||||
passive: (id) => !parts.router.resolve(id)?.instance,
|
||||
});
|
||||
picking?.registerPickOwner?.(STREET_LEVEL_LAYER_ID, parts.router.ownsPick);
|
||||
}
|
||||
|
||||
function uninstall() {
|
||||
|
||||
Reference in new issue
Block a user