cleanup and refactor

This commit is contained in:
th committed 2026-04-09 19:39:56 +02:00
1 parent 5f9db690a4
commit 73da8fb849
10 files changed
+91 -97

No files matched your search

+9 -10
View File
@@ -29,25 +29,24 @@ const FS_MAX_SCALE = 8;
// ── Zoom ──
const ZOOM_KEY = 'hyprcrd-detail-zoom';
let zoom = parseFloat(localStorage.getItem(ZOOM_KEY) || '1') || 1;
function applyZoom() {
if (!titleEl) return;
titleEl.style.fontSize = `${(1.125 * zoom).toFixed(3)}rem`;
bodyEl.style.fontSize = `${(0.875 * zoom).toFixed(3)}rem`;
metaEl.style.fontSize = `${Math.max(0.625, 0.6875 * zoom).toFixed(3)}rem`;
titleEl.style.lineHeight = `${Math.max(1.35, 1.55 + (zoom - 1) * 0.3).toFixed(3)}`;
bodyEl.style.lineHeight = `${Math.max(1.5, 1.7 + (zoom - 1) * 0.35).toFixed(3)}`;
metaEl.style.lineHeight = `${Math.max(1.2, 1.35 + (zoom - 1) * 0.25).toFixed(3)}`;
titleEl.style.fontSize = `${(1.125 * state.zoom).toFixed(3)}rem`;
bodyEl.style.fontSize = `${(0.875 * state.zoom).toFixed(3)}rem`;
metaEl.style.fontSize = `${Math.max(0.625, 0.6875 * state.zoom).toFixed(3)}rem`;
titleEl.style.lineHeight = `${Math.max(1.35, 1.55 + (state.zoom - 1) * 0.3).toFixed(3)}`;
bodyEl.style.lineHeight = `${Math.max(1.5, 1.7 + (state.zoom - 1) * 0.35).toFixed(3)}`;
metaEl.style.lineHeight = `${Math.max(1.2, 1.35 + (state.zoom - 1) * 0.25).toFixed(3)}`;
}
applyZoom();
scroll?.addEventListener('wheel', e => {
if (!detail.classList.contains('open') || !e.shiftKey || Math.abs(e.deltaY) < Math.abs(e.deltaX)) return;
e.preventDefault();
zoom = Math.min(2.2, Math.max(0.75, zoom + (e.deltaY < 0 ? 0.08 : -0.08)));
zoom = Math.round(zoom * 100) / 100;
localStorage.setItem(ZOOM_KEY, String(zoom));
state.zoom = Math.min(2.2, Math.max(0.75, state.zoom + (e.deltaY < 0 ? 0.08 : -0.08)));
state.zoom = Math.round(state.zoom * 100) / 100;
localStorage.setItem(ZOOM_KEY, String(state.zoom));
applyZoom();
}, { passive: false });