diff --git a/src/ui/panel.ts b/src/ui/panel.ts index 005566f..d155f2e 100644 --- a/src/ui/panel.ts +++ b/src/ui/panel.ts @@ -12,13 +12,7 @@ import { EV_ANCHOR_SET, EV_AUTOCAP_CHANGED } from '../core/events'; let panelEl: HTMLDivElement | null = null; -function $(id: string): HTMLElement { - const el = document.getElementById(id); - if (!el) { - throw new Error(`Element with id "${id}" not found.`); - } - return el; -} +function $(id: string): HTMLElement | null { return document.getElementById(id); } export function createUI() { if (document.getElementById('overlay-pro-panel')) return; @@ -29,8 +23,10 @@ export function createUI() { const panelW = 340; const defaultLeft = Math.max(12, window.innerWidth - panelW - 80); - panel.style.left = `${Number.isFinite(config.panelX as any) ? (config.panelX as any) : defaultLeft}px`; - panel.style.top = `${Number.isFinite(config.panelY as any) ? (config.panelY as any) : 120}px`; + const initLeft = (typeof config.panelX === 'number' && Number.isFinite(config.panelX)) ? config.panelX : defaultLeft; + const initTop = (typeof config.panelY === 'number' && Number.isFinite(config.panelY)) ? config.panelY : 120; + panel.style.left = `${initLeft}px`; + panel.style.top = `${initTop}px`; panel.innerHTML = `