feat: add fullscreen download action

This commit is contained in:
br0tkasten committed 2026-06-14 11:19:46 +02:00
1 parent 4ae6e09388
commit 99f9f648ba
3 files changed
+60 -4

No files matched your search

+17
View File
@@ -75,6 +75,7 @@ const overlayLoadingText = mustGet("overlay-loading-text");
const overlayMedia = mustGet("overlay-media");
const overlayPrev = mustGet("overlay-prev");
const overlayNext = mustGet("overlay-next");
const overlayDownload = mustGet("overlay-download");
const closeOverlay = mustGet("close-overlay");
const routeToggle = mustGet("route-toggle");
const routeToggleIcon = mustGet("route-toggle-icon");
@@ -274,6 +275,20 @@ function syncPhotoNameInLocation(photoName) {
}
}
function syncOverlayDownload(photo) {
if (!photo) {
overlayDownload.setAttribute("href", "#");
overlayDownload.setAttribute("aria-disabled", "true");
overlayDownload.removeAttribute("download");
return;
}
overlayDownload.href = photo.fullUrl;
overlayDownload.download = photo.name;
overlayDownload.setAttribute("aria-label", "Download photo");
overlayDownload.setAttribute("aria-disabled", "false");
}
function getOverlayPhotos() {
if (!state.visiblePhotos.length) {
return state.photos;
@@ -566,6 +581,7 @@ function openOverlay(photo) {
overlay.setAttribute("aria-hidden", "false");
overlayTitle.textContent = photo.name;
overlayImage.alt = photo.name;
syncOverlayDownload(photo);
overlay.classList.add("loading");
overlayLoading.classList.add("active");
overlayLoading.classList.remove("error");
@@ -600,6 +616,7 @@ function closeOverlayView() {
overlayLoading.classList.remove("error");
overlayLoadingText.textContent = "Loading full-size image...";
overlayImage.removeAttribute("src");
syncOverlayDownload(null);
syncPhotoNameInLocation("");
overlaySwipeState = null;
}