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

Prevent ui.leaflet from flickering after calling flyTo() #3125

Merged
merged 1 commit into from
May 27, 2024
Merged

Conversation

falkoschindler
Copy link
Contributor

This PR attempts to solve #3035 by adding a short delay on client and server to allow both zoom and center to update without jumping back and forth. The delay of 0.02s is deliberately chosen above the lower bound of 0.016s for Windows. I hope it isn't too dependent on processor and network speed.

Can be tested with this code:

m = ui.leaflet(center=(48.1, 11.6), zoom=10)
m.on('map-moveend', lambda e: print(e.args['center'], e.args['zoom']))
ui.button('Berlin', on_click=lambda: m.run_map_method('flyTo', [52.5, 13.4], 9, {'duration': 1.0}))

There might still be glitches with multiple tabs connected to the auto-index page. But maybe it's good enough for now.

@falkoschindler falkoschindler added the bug Something isn't working label May 25, 2024
@falkoschindler falkoschindler added this to the 1.4.26 milestone May 25, 2024
@afullerx
Copy link
Contributor

This fix works well on Windows. I did my best to break it by opening the UI in multiple tabs, maxing out the CPU, and throttling the network to "slow 3G". In all cases it continued to function nicely. 👍

@falkoschindler falkoschindler marked this pull request as ready for review May 27, 2024 08:29
@falkoschindler falkoschindler linked an issue May 27, 2024 that may be closed by this pull request
@rodja rodja self-requested a review May 27, 2024 08:32
@rodja rodja merged commit 81db6d7 into main May 27, 2024
7 checks passed
@rodja rodja deleted the leaflet-flicker branch May 27, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Leaflet: map flickers between centers after flyTo
3 participants