diff --git a/src/pages/workouts/components/WorkoutItem.vue b/src/pages/workouts/components/WorkoutItem.vue
index 9338ad6..00d4461 100644
--- a/src/pages/workouts/components/WorkoutItem.vue
+++ b/src/pages/workouts/components/WorkoutItem.vue
@@ -380,7 +380,7 @@
@@ -401,9 +401,9 @@
- {{ lightboxIndex + 1 }} / {{ photos.length }}
+ {{ lightboxIndex + 1 }} / {{ lightboxSet.length }}
@@ -1206,9 +1206,11 @@ const photosWithCoords = computed(() =>
);
const showLightbox = ref(false);
const lightboxIndex = ref(0);
+const lightboxSet = ref>([]);
const openPhoto = (photo: WorkoutPhoto) => {
const idx = photos.value.findIndex((p) => p.id === photo.id);
if (idx >= 0) {
+ lightboxSet.value = photos.value;
lightboxIndex.value = idx;
showLightbox.value = true;
}
@@ -1237,15 +1239,16 @@ function isSamePointCluster(c: ClustererInfo): boolean {
function openClusterPhotos(c: ClustererInfo) {
if (!c.features || c.features.length === 0) return;
const [lng, lat] = c.lnglat as [number, number];
- const idx = photos.value.findIndex(
+ const set = photos.value.filter(
(p) =>
p.latitude !== null &&
p.longitude !== null &&
Math.abs(p.longitude - lng) < CLUSTER_SAME_POINT_EPS &&
Math.abs(p.latitude - lat) < CLUSTER_SAME_POINT_EPS,
);
- if (idx >= 0) {
- lightboxIndex.value = idx;
+ if (set.length > 0) {
+ lightboxSet.value = set;
+ lightboxIndex.value = 0;
showLightbox.value = true;
}
}
@@ -1286,11 +1289,14 @@ function focusPhotoOnMap(photo: WorkoutPhoto) {
});
}
const prevPhoto = () => {
- lightboxIndex.value =
- (lightboxIndex.value - 1 + photos.value.length) % photos.value.length;
+ const len = lightboxSet.value.length;
+ if (len === 0) return;
+ lightboxIndex.value = (lightboxIndex.value - 1 + len) % len;
};
const nextPhoto = () => {
- lightboxIndex.value = (lightboxIndex.value + 1) % photos.value.length;
+ const len = lightboxSet.value.length;
+ if (len === 0) return;
+ lightboxIndex.value = (lightboxIndex.value + 1) % len;
};
const onLightboxKeydown = (event: KeyboardEvent) => {
if (!showLightbox.value) {