Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker animation mostly fixed #1257

Merged
merged 5 commits into from
Nov 7, 2024
Merged

Marker animation mostly fixed #1257

merged 5 commits into from
Nov 7, 2024

Conversation

bobular
Copy link
Member

@bobular bobular commented Nov 1, 2024

Fixes #1227

The only problem I see is that when zooming in, it would be nice to have the old aggregated marker on top, and have the new disaggregated markers animate out from underneath it. I couldn't make this happen :-( (see the comments in updateMarkers.tsx) It's not a deal-breaker for me.

Needs a lot more heavy testing though.

@bobular bobular requested a review from dmfalke November 1, 2024 15:29
consolidatedMarkers = updateMarkers(markers, prevMarkers, hashDif);
// Get array of new markers with old positions
const cloneArray = updateMarkers(markers, prevMarkers, hashDif);
consolidatedMarkers = [...prevMarkers, ...cloneArray];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reversing the order of the spreads here does not fix the "old marker hidden under new markers" problem.

@dmfalke
Copy link
Member

dmfalke commented Nov 4, 2024

it would be nice to have the old aggregated marker on top

Did you try setting a higher z-index value for the old markers?

Copy link
Member

@dmfalke dmfalke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems to work! I don't really understand how your change fixed things. Can you provide a brief explanation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain how removing enqueueZoom fixes the issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, not entirely sure. I suspect React 18-related timing changes messed something up. There was nothing else to "blame" as far as I could see in the animation-related source files.

Although there's a remaining niggle with the z-index ordering of old vs new markers during animation, I am happy to remove code.

The enqueued setTimeout isn't necessary because on the next render (which is now debounced to the same milliseconds as animation (300ms)) the animation function will basically be a no-op because the geohash level is the same for prevRecenteredMarkers and recenteredMarkers - so it returns recenteredMarkers which will replace the previous concatenated old+new markers.

@bobular
Copy link
Member Author

bobular commented Nov 5, 2024

it would be nice to have the old aggregated marker on top

Did you try setting a higher z-index value for the old markers?

Yes, I tried zIndexOffset and setting CSS z-index via classes. Neither made any difference, in either direction. Nor did the ordering in the spread operators making the combined array of markers. I tested it with a very slow animation time and adding an offset to the marker's position.lng so that I could see both old and new side by side.

@dmfalke
Copy link
Member

dmfalke commented Nov 5, 2024

it would be nice to have the old aggregated marker on top

Did you try setting a higher z-index value for the old markers?

Yes, I tried zIndexOffset and setting CSS z-index via classes. Neither made any difference, in either direction. Nor did the ordering in the spread operators making the combined array of markers. I tested it with a very slow animation time and adding an offset to the marker's position.lng so that I could see both old and new side by side.

That surprising. If the markers are in the same stacking context, z-index should work. Might look into it later 🙂

@bobular
Copy link
Member Author

bobular commented Nov 7, 2024

Hi @dmfalke - I snuck in a new fix. Looks harmless to me*, so I'm merging.

(* the worst that could happen is that some animation is broken, which it already was before this PR! - though it all looks good to me)

@bobular bobular merged commit 217fbd5 into main Nov 7, 2024
1 check passed
@bobular bobular deleted the 1227-marker-animation-fix branch November 7, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Map: semantic marker animation is broken on zoom in (but not zoom out)
2 participants