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
@@ -13,8 +13,7 @@ export function createSelection({
|
||||
config,
|
||||
feed,
|
||||
}) {
|
||||
const { resolvePickId, isOwnedByOtherLayer, isActedOnByOtherLayer } =
|
||||
services.picking;
|
||||
const { resolvePickId, isOwnedByOtherLayer, clickCard } = services.picking;
|
||||
const { requestWorldFocus } = services.focus;
|
||||
const {
|
||||
selectEntityContext,
|
||||
@@ -22,7 +21,7 @@ export function createSelection({
|
||||
getContextStore,
|
||||
registerEntityContext,
|
||||
} = services.context;
|
||||
const { id, name, overlayHost } = config;
|
||||
const { id, name } = config;
|
||||
|
||||
/**
|
||||
* Install the LEFT_CLICK handler for fire selection (enable-time only,
|
||||
@@ -35,48 +34,25 @@ export function createSelection({
|
||||
if (layerState._clickSubscription || !layerState._viewer) return;
|
||||
const input = inputFor(layerState._viewer);
|
||||
layerState._clickSubscription = input.onClick((event) => {
|
||||
const picked = event.topHit;
|
||||
// The card or label painted on top takes the click, read once per
|
||||
// click so every layer agrees: ours acts whatever is drawn under it;
|
||||
// another layer's is that layer's click.
|
||||
const top = clickCard?.(event) ?? null;
|
||||
if (top) {
|
||||
if (top.sourceId !== FIRMS_OVERLAY_SOURCE_ID) return;
|
||||
const carded = layerState._fireByCardId.get(top.entryId);
|
||||
if (carded) selectAndFocusFire(carded);
|
||||
return;
|
||||
}
|
||||
const fire = pickedFire(event.drawHit);
|
||||
if (fire) {
|
||||
selectAndFocusFire(fire);
|
||||
return;
|
||||
}
|
||||
// A pick that belongs to a sibling layer (e.g. an aircraft) is not
|
||||
// "empty space" — leave the selection alone and let that layer handle it.
|
||||
// A passive owner's pick (a flight trail, a directions route) acts for
|
||||
// nobody, so a card of ours painted over it still takes the click.
|
||||
let passivePick = false;
|
||||
if (picked) {
|
||||
const pickedId = resolvePickId(picked);
|
||||
if (pickedId && isOwnedByOtherLayer(id, pickedId)) {
|
||||
passivePick =
|
||||
Boolean(isActedOnByOtherLayer) &&
|
||||
!isActedOnByOtherLayer(id, pickedId, { click: event });
|
||||
if (!passivePick) return;
|
||||
}
|
||||
}
|
||||
const cardHit = overlayHost.hitTest?.(
|
||||
event.screenPosition?.x,
|
||||
event.screenPosition?.y,
|
||||
);
|
||||
if (passivePick && cardHit?.sourceId !== FIRMS_OVERLAY_SOURCE_ID) return;
|
||||
// A coarse tap's touch contact (not the exact pick) that its layer acts
|
||||
// on (an aircraft, a vessel, a radio station) is that layer's click,
|
||||
// even under a card of ours.
|
||||
const contactId = resolvePickId(event.hit ?? null);
|
||||
if (
|
||||
cardHit &&
|
||||
contactId &&
|
||||
contactId !== resolvePickId(picked ?? null) &&
|
||||
isActedOnByOtherLayer?.(id, contactId, { expanded: true, click: event })
|
||||
)
|
||||
return;
|
||||
if (cardHit) {
|
||||
if (cardHit.sourceId !== FIRMS_OVERLAY_SOURCE_ID) return;
|
||||
const carded = layerState._fireByCardId.get(cardHit.entryId);
|
||||
if (carded) selectAndFocusFire(carded);
|
||||
return;
|
||||
}
|
||||
// A pick that belongs to a sibling layer (an aircraft, a flight trail)
|
||||
// is not "empty space": leave the selection alone.
|
||||
const pickedId = resolvePickId(event.topHit ?? null);
|
||||
if (pickedId && isOwnedByOtherLayer(id, pickedId)) return;
|
||||
clearFireSelection();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user