mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-22 16:46:10 -08:00
Overlay 2.0 (#12)
This commit is contained in:
1 parent
45df3c466b
commit
44c7761c7c
397 files changed
+15139
-7127
No files matched your search
@@ -1,6 +1,20 @@
|
||||
import type { RuntimeOptionApplyResult, RuntimeOptionState, RuntimeOptionValue } from '../../types';
|
||||
import type { ModalStateReader, RendererContext } from '../context';
|
||||
|
||||
type RuntimeOptionsListLike = Pick<HTMLUListElement, 'querySelector'>;
|
||||
|
||||
export function scrollActiveRuntimeOptionIntoView(list: RuntimeOptionsListLike): void {
|
||||
const active = list.querySelector('.runtime-options-item.active');
|
||||
if (!active) return;
|
||||
|
||||
const maybeScrollable = active as unknown as {
|
||||
scrollIntoView?: (options?: ScrollIntoViewOptions) => void;
|
||||
};
|
||||
if (typeof maybeScrollable.scrollIntoView !== 'function') return;
|
||||
|
||||
maybeScrollable.scrollIntoView({ block: 'nearest' });
|
||||
}
|
||||
|
||||
export function createRuntimeOptionsModal(
|
||||
ctx: RendererContext,
|
||||
options: {
|
||||
@@ -82,6 +96,8 @@ export function createRuntimeOptionsModal(
|
||||
|
||||
ctx.dom.runtimeOptionsList.appendChild(li);
|
||||
});
|
||||
|
||||
scrollActiveRuntimeOptionIntoView(ctx.dom.runtimeOptionsList);
|
||||
}
|
||||
|
||||
function updateRuntimeOptions(optionsList: RuntimeOptionState[]): void {
|
||||
@@ -162,8 +178,6 @@ export function createRuntimeOptionsModal(
|
||||
}
|
||||
|
||||
async function openRuntimeOptionsModal(): Promise<void> {
|
||||
if (ctx.platform.isInvisibleLayer) return;
|
||||
|
||||
const optionsList = await window.electronAPI.getRuntimeOptions();
|
||||
updateRuntimeOptions(optionsList);
|
||||
|
||||
|
||||
Reference in new issue
Block a user