mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-11 04:07:44 +02:00
[eric] dashboard: scroll zooms the canvas over any card (Google Maps); click into a card to scroll its content
This commit is contained in:
@@ -25,6 +25,7 @@ export interface BrowserWebview extends HTMLElement {
|
||||
isLoading: () => boolean;
|
||||
// Optional: present on real Electron webviews; the iframe fallback lacks it, callers must ?.() it.
|
||||
isCurrentlyAudible?: () => boolean;
|
||||
send?: (channel: string, ...args: any[]) => void;
|
||||
capturePage: (rect?: { x: number; y: number; width: number; height: number }) => Promise<ElectronNativeImage>;
|
||||
executeJavaScript: (code: string) => Promise<any>;
|
||||
sendInputEvent: (event: any) => void;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// The card you've clicked INTO, so plain scroll reads its content (chat transcript, web page)
|
||||
// while scroll everywhere else zooms the canvas (Google Maps model). Imperative + read on the
|
||||
// wheel handler so no re-render; cleared when you click blank canvas.
|
||||
let scrollFocusedCardId: string | null = null;
|
||||
type Listener = (id: string | null) => void;
|
||||
const listeners = new Set<Listener>();
|
||||
|
||||
export function setScrollFocusedCard(id: string | null): void {
|
||||
if (scrollFocusedCardId === id) return;
|
||||
scrollFocusedCardId = id;
|
||||
for (const l of listeners) l(id);
|
||||
}
|
||||
|
||||
export function getScrollFocusedCard(): string | null {
|
||||
return scrollFocusedCardId;
|
||||
}
|
||||
|
||||
// Browser cards subscribe so they can tell their (out-of-process) guest whether plain wheel should scroll the page or zoom the canvas.
|
||||
export function onScrollFocusChange(l: Listener): () => void {
|
||||
listeners.add(l);
|
||||
return () => { listeners.delete(l); };
|
||||
}
|
||||
Reference in New Issue
Block a user