-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0bd958f
change from key to props.id - didn't fix it
bobular 48d15cf
90 percent fixed
bobular c702c1c
failed attempt to get z-index ordering of animated markers correct
bobular 0c03c58
Merge remote-tracking branch 'origin/main' into 1227-marker-animation…
bobular aa42bc8
fix fly-by problem from #628
bobular File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ export default function geohashAnimation({ | |
prevMarkers, | ||
markers, | ||
}: geoHashAnimation) { | ||
const prevGeoHash = prevMarkers[0].key as string; | ||
const currentGeohash = markers[0].key as string; | ||
const prevGeoHash = prevMarkers[0].props.id as string; | ||
const currentGeohash = markers[0].props.id as string; | ||
let zoomType, consolidatedMarkers; | ||
|
||
/** Zoom Out - Move existing markers to new position | ||
|
@@ -22,9 +22,9 @@ export default function geohashAnimation({ | |
if (prevGeoHash.length > currentGeohash.length) { | ||
zoomType = 'out'; | ||
const hashDif = prevGeoHash.length - currentGeohash.length; | ||
// Get a new array of existing markers with new position property | ||
// Get array of old markers with new positions | ||
const cloneArray = updateMarkers(prevMarkers, markers, hashDif); | ||
// Combine the new and existing markers | ||
// Combine the new and old markers | ||
consolidatedMarkers = [...markers, ...cloneArray]; | ||
} else if (prevGeoHash.length < currentGeohash.length) { | ||
/** Zoom In - New markers start at old position | ||
|
@@ -33,10 +33,9 @@ export default function geohashAnimation({ | |
**/ | ||
zoomType = 'in'; | ||
const hashDif = currentGeohash.length - prevGeoHash.length; | ||
// Get a new array of new markers with existing position property | ||
// Set final render markers to the cloneArray which holds the new markers with | ||
// their new starting location | ||
consolidatedMarkers = updateMarkers(markers, prevMarkers, hashDif); | ||
// Get array of new markers with old positions | ||
const cloneArray = updateMarkers(markers, prevMarkers, hashDif); | ||
consolidatedMarkers = [...prevMarkers, ...cloneArray]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} else { | ||
/** No difference in geohashes - Render markers as they are **/ | ||
zoomType = null; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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 forprevRecenteredMarkers
andrecenteredMarkers
- so it returnsrecenteredMarkers
which will replace the previous concatenated old+new markers.