diff --git a/src/pages/workouts/components/WorkoutItem.vue b/src/pages/workouts/components/WorkoutItem.vue index 44b18ce..4c388fd 100644 --- a/src/pages/workouts/components/WorkoutItem.vue +++ b/src/pages/workouts/components/WorkoutItem.vue @@ -75,13 +75,7 @@
1
@@ -1229,6 +1223,34 @@ const openPhoto = (photo: WorkoutPhoto) => { showLightbox.value = true; } }; +const photoMarkerSettings = new Map< + string, + { coordinates: LngLat; onClick: (e: unknown, event: unknown) => void } +>(); +/** + * Stable per-photo marker settings objects. A fresh inline :settings on every + * parent re-render would patch the YandexMapMarker component, whose onUpdated() + * removes the marker DOM node (it is owned by the clusterer and is not inside + * at that moment); the clusterer then reuses the same entity without + * recreating the element, so the single marker would disappear forever. + */ +function getPhotoMarkerSettings(photo: WorkoutPhoto): { + coordinates: LngLat; + onClick: (e: unknown, event: unknown) => void; +} { + let s = photoMarkerSettings.get(photo.id); + if (!s) { + s = { + coordinates: [ + photo.longitude as number, + photo.latitude as number, + ] as LngLat, + onClick: (_: unknown, __: unknown) => openPhoto(photo), + }; + photoMarkerSettings.set(photo.id, s); + } + return s; +} type ClusterFeature = { geometry: { coordinates: [number, number, ...number[]] }; };