mobile fixes

This commit is contained in:
2026-05-17 00:01:21 -04:00
parent fbe78ae396
commit 9cd21f9568
3 changed files with 78 additions and 10 deletions

View File

@@ -11,6 +11,7 @@ export default function DoomScrollViewer({ items, onClose, onViewInLibrary }: Pr
const [index, setIndex] = useState(0);
const [fading, setFading] = useState(false);
const wheelLock = useRef(false);
const touchStartY = useRef<number | null>(null);
const item = items[index];
@@ -34,11 +35,22 @@ export default function DoomScrollViewer({ items, onClose, onViewInLibrary }: Pr
if (e.key === "ArrowUp") { e.preventDefault(); go(-1); }
if (e.key === "Escape") onClose();
};
const onTouchStart = (e: TouchEvent) => { touchStartY.current = e.touches[0].clientY; };
const onTouchEnd = (e: TouchEvent) => {
if (touchStartY.current === null) return;
const delta = touchStartY.current - e.changedTouches[0].clientY;
if (Math.abs(delta) > 50) delta > 0 ? go(1) : go(-1);
touchStartY.current = null;
};
window.addEventListener("wheel", onWheel, { passive: true });
window.addEventListener("keydown", onKey);
window.addEventListener("touchstart", onTouchStart);
window.addEventListener("touchend", onTouchEnd);
return () => {
window.removeEventListener("wheel", onWheel);
window.removeEventListener("keydown", onKey);
window.removeEventListener("touchstart", onTouchStart);
window.removeEventListener("touchend", onTouchEnd);
};
}, [index, fading]);
@@ -58,7 +70,6 @@ export default function DoomScrollViewer({ items, onClose, onViewInLibrary }: Pr
transform: fading ? "translateY(-12px)" : "translateY(0)",
}}
>
<div style={{ color: "#ccc", fontSize: 13 }}>{item?.filename}</div>
{item?.media_type === "image" && (
<img
key={item.id}