51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
// ===============================
|
|
// BOTTOM SHEET (Google Photos Web)
|
|
// ===============================
|
|
|
|
const bottomSheet = document.getElementById("bottomSheet");
|
|
const sheetGallery = document.getElementById("sheetGallery");
|
|
|
|
// Apri il bottom sheet con una lista di foto
|
|
function openBottomSheet(photoList) {
|
|
sheetGallery.innerHTML = "";
|
|
|
|
photoList.forEach(photo => {
|
|
const div = document.createElement("div");
|
|
div.className = "sheet-item";
|
|
|
|
div.innerHTML = `
|
|
<img src="https://prova.patachina.it/${photo.thub1}">
|
|
`;
|
|
|
|
div.addEventListener("click", () => {
|
|
openModal(
|
|
`https://prova.patachina.it/${photo.path}`,
|
|
photo.thub2
|
|
? `https://prova.patachina.it/${photo.thub2}`
|
|
: `https://prova.patachina.it/${photo.thub1}`,
|
|
photo
|
|
);
|
|
});
|
|
|
|
sheetGallery.appendChild(div);
|
|
});
|
|
|
|
bottomSheet.classList.add("open");
|
|
}
|
|
|
|
// Chiudi il bottom sheet
|
|
function closeBottomSheet() {
|
|
bottomSheet.classList.remove("open");
|
|
}
|
|
|
|
// Chiudi cliccando fuori dal bottom sheet
|
|
document.addEventListener("click", (e) => {
|
|
if (!bottomSheet.classList.contains("open")) return;
|
|
|
|
const clickedInside = bottomSheet.contains(e.target);
|
|
const clickedMarker = e.target.closest(".photo-marker, .photo-cluster");
|
|
|
|
if (!clickedInside && !clickedMarker) {
|
|
closeBottomSheet();
|
|
}
|
|
});
|