-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Don't delay moveend event on invalidateSize #2181
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
Conversation
This causes unnecessary nondeterminism in the sequence of events emitted. Instead, the caller should be responsible for throttling, as e.g. Map#_onResize does.
|
osmlab/openstreetmap-website@9ed8664 is the relevant OSM commit. |
|
Hmm, that one needs some thought... Some internal Leaflet stuff is happening on |
|
@jfirebaugh can you clarify the problem with the 200ms delay on OSM.org? Perhaps we could explore alternative ways to fix this. |
|
Yes, the problem is that the OSM.org code keeps track of the map state via history APIs -- there's a moveend event binding that updates the state via replaceState. Meanwhile, when the sidebar is shown or hidden in response to navigation events, we need to invalidateSize. But because invalidateSize fires moveend asynchronously, we have no proper control over which history entry is updated with the new state. It ends up being the wrong one if you click the back or forward button too quickly. Simply put, this use cases depends on invalidateSize firing moveend synchronously. |
FWIW, a 200ms timeout doesn't really accomplish that either -- you'll still get intermittent moveend when pausing for more than 200ms while resizing. |
|
If the hash depends on |
|
Yeah, |
|
But then you would fire lots of
It's at least an approximation, which is much better. I'm sure there's a better solution to this problem, lets think more about other options... |
|
@jfirebaugh what do you think about this: fire |
|
Lets solve this before 0.7 release so that the redesigned OSM.org can use the stable version. |
|
👍, added a |
|
Thanks, merged! |
This causes unnecessary nondeterminism in the sequence of events emitted. Instead, the caller should be responsible for throttling, as e.g. Map#_onResize does.
@mourner Does this make sense? The setTimeout is causing a problem for OSM.org -- sometimes the moveend triggers stuff 200ms later that should have happened synchronously with invalidateSize.