Fix: Clear Moku Cache & SelectPortal Zoom (#82)

This commit is contained in:
Youwes09
2026-05-16 22:05:13 -05:00
parent e3abc72f1b
commit 897ecfd316
3 changed files with 39 additions and 22 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ export const GET_SOURCES = `
sources {
nodes {
id name lang displayName iconUrl isNsfw
isConfigurable supportsLatest baseUrl
isConfigurable supportsLatest
extension { pkgName }
}
}
@@ -92,7 +92,7 @@ export const GET_MIGRATABLE_SOURCES = `
nodes {
sourceId
source {
id name lang displayName iconUrl isNsfw isConfigurable supportsLatest baseUrl
id name lang displayName iconUrl isNsfw isConfigurable supportsLatest
}
}
}
+15 -17
View File
@@ -1,32 +1,30 @@
import type { Attachment } from "svelte/attachments";
/**
* {@attach selectPortal(triggerEl)}
*
* Moves the decorated element to <body> and positions it below `triggerEl`.
* The element stays reactive — Svelte still owns its DOM, we just re-parent it.
*
* The portalled menu element is stored on `triggerEl.__selectMenuEl` so that
* the outside-click guard in Settings.svelte can exclude it from dismissal.
*/
export function selectPortal(triggerEl: HTMLElement & { __selectMenuEl?: HTMLElement | null }): Attachment {
return (menuEl: HTMLElement) => {
// Position & move to body
function position() {
const zoom = parseFloat(document.documentElement.style.zoom) / 100 || 1;
const r = triggerEl.getBoundingClientRect();
const top = r.bottom / zoom + 4;
const right = r.right / zoom;
const width = menuEl.offsetWidth;
const left = Math.max(8, right - width);
menuEl.style.position = "fixed";
menuEl.style.top = `${r.bottom + 4}px`;
menuEl.style.left = `${r.right - menuEl.offsetWidth}px`;
// clamp to viewport left edge
const left = parseFloat(menuEl.style.left);
if (left < 8) menuEl.style.left = "8px";
menuEl.style.top = `${top}px`;
menuEl.style.left = `${left}px`;
}
menuEl.style.visibility = "hidden";
document.body.appendChild(menuEl);
triggerEl.__selectMenuEl = menuEl;
position();
// Reposition on scroll / resize while open
requestAnimationFrame(() => {
position();
menuEl.style.visibility = "";
});
window.addEventListener("scroll", position, true);
window.addEventListener("resize", position);