π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix super cluster click zoom behavior to match timeline scroll
anandbaburajanac9df15750bd
diff --git a/web/apps/photos/src/components/TripLayout/TripMap.tsx b/web/apps/photos/src/components/TripLayout/TripMap.tsxindex 52ad05b461..f8da0c40c2 100644--- a/web/apps/photos/src/components/TripLayout/TripMap.tsx+++ b/web/apps/photos/src/components/TripLayout/TripMap.tsx@@ -157,11 +157,28 @@ export const TripMap: React.FC<TripMapProps> = ({const firstClusterIndex =superCluster.clustersInvolved[0];if (firstClusterIndex !== undefined) {- onMarkerClick(- firstClusterIndex,- superCluster.lat,- superCluster.lng,- );+ // Get the actual first cluster's coordinates+ const firstCluster =+ photoClusters[+ firstClusterIndex+ ];+ if (firstCluster) {+ const avgLat =+ firstCluster.reduce(+ (sum, p) => sum + p.lat,+ 0,+ ) / firstCluster.length;+ const avgLng =+ firstCluster.reduce(+ (sum, p) => sum + p.lng,+ 0,+ ) / firstCluster.length;+ onMarkerClick(+ firstClusterIndex,+ avgLat,+ avgLng,+ );+ }}},}}diff --git a/web/apps/photos/src/components/TripLayout/hooks/useScrollHandling.ts b/web/apps/photos/src/components/TripLayout/hooks/useScrollHandling.tsindex c549bf3877..6bc0eba7fd 100644--- a/web/apps/photos/src/components/TripLayout/hooks/useScrollHandling.ts+++ b/web/apps/photos/src/components/TripLayout/hooks/useScrollHandling.ts@@ -134,6 +134,9 @@ export const useScrollHandling = ({isTouchDevice,superClusterInfo,scrollProgress,+ setTargetZoom,+ previousSuperClusterStateRef,+ previousActiveLocationRef,});},[@@ -147,6 +150,9 @@ export const useScrollHandling = ({isTouchDevice,superClusterInfo,scrollProgress,+ setTargetZoom,+ previousSuperClusterStateRef,+ previousActiveLocationRef,],);diff --git a/web/apps/photos/src/components/TripLayout/utils/scrollUtils.ts b/web/apps/photos/src/components/TripLayout/utils/scrollUtils.tsindex 779720c50b..8258dab225 100644--- a/web/apps/photos/src/components/TripLayout/utils/scrollUtils.ts+++ b/web/apps/photos/src/components/TripLayout/utils/scrollUtils.ts@@ -498,6 +498,12 @@ export interface HandleMarkerClickParams {clusterToSuperClusterMap: Map<number, number>;};scrollProgress: number;+ setTargetZoom: (zoom: number | null) => void;+ previousSuperClusterStateRef: React.RefObject<{+ isInSuperCluster: boolean;+ superClusterIndex: number | null;+ }>;+ previousActiveLocationRef: React.RefObject<number>;}export const handleMarkerClick = ({@@ -514,6 +520,9 @@ export const handleMarkerClick = ({isTouchDevice,superClusterInfo,scrollProgress,+ setTargetZoom,+ previousSuperClusterStateRef,+ previousActiveLocationRef,}: HandleMarkerClickParams) => {const targetProgress = clusterIndex / Math.max(1, photoClusters.length - 1);@@ -525,6 +534,9 @@ export const handleMarkerClick = ({setScrollProgress(targetProgress);setHasUserScrolled(true);+ // Update the previous active location to the target cluster+ previousActiveLocationRef.current = clusterIndex;+// Calculate current active location indexlet currentActiveLocationIndex = -1;if (photoClusters.length > 0) {@@ -571,18 +583,77 @@ export const handleMarkerClick = ({duration: 0.6,easeLinearity: 0.3,});++ // Update state to maintain super cluster info+ const targetSuperClusterIndex =+ superClusterInfo?.clusterToSuperClusterMap.get(+ clusterIndex,+ );+ previousSuperClusterStateRef.current = {+ isInSuperCluster: true,+ superClusterIndex: targetSuperClusterIndex || null,+ };} else {- // Normal behavior: fly to with zoom- const [positionedLat, positionedLng] = getLocationPosition(- clusterLat,- clusterLng,- );- const targetZoom = isTouchDevice ? 8 : 10;- mapRef.flyTo([positionedLat, positionedLng], targetZoom, {- animate: true,- duration: 1.0,- easeLinearity: 0.3,- });+ // Check if the target cluster is part of a super cluster+ const targetSuperClusterIndex =+ superClusterInfo?.clusterToSuperClusterMap.get(+ clusterIndex,+ );+ const isInSuperCluster = targetSuperClusterIndex !== undefined;++ if (isInSuperCluster) {+ // Zoom to super cluster level to break it apart+ const superClusterZoom = isTouchDevice ? 15 : 14;+ const [zoomAwareLat, zoomAwareLng] =+ getLocationPositionAtZoom(+ clusterLat,+ clusterLng,+ superClusterZoom,+ );+ // Set target zoom before animation so clusters separate during zoom+ setTargetZoom(superClusterZoom);+ mapRef.flyTo(+ [zoomAwareLat, zoomAwareLng],+ superClusterZoom,+ { animate: true, duration: 1.0, easeLinearity: 0.3 },+ );++ // Update super cluster state for proper scroll behavior+ previousSuperClusterStateRef.current = {+ isInSuperCluster: true,+ superClusterIndex: targetSuperClusterIndex,+ };++ // Clear target zoom after animation completes+ setTimeout(() => {+ setTargetZoom(null);+ }, 1100);+ } else {+ // Normal behavior: fly to with standard zoom+ const [positionedLat, positionedLng] = getLocationPosition(+ clusterLat,+ clusterLng,+ );+ const targetZoomLevel = isTouchDevice ? 8 : 10;+ // Set target zoom before animation+ setTargetZoom(targetZoomLevel);+ mapRef.flyTo(+ [positionedLat, positionedLng],+ targetZoomLevel,+ { animate: true, duration: 1.0, easeLinearity: 0.3 },+ );++ // Update super cluster state+ previousSuperClusterStateRef.current = {+ isInSuperCluster: false,+ superClusterIndex: null,+ };++ // Clear target zoom after animation completes+ setTimeout(() => {+ setTargetZoom(null);+ }, 1100);+ }}} catch (error) {console.warn("Map operation failed:", error);