Skip to content

Conversation

jacobtoye
Copy link
Member

In certain situations you don't want the map to pan when you invalidate the size (usually after the maps container is resized).

Take Google maps as an example. The sidebar can be contracted and expanded. When this happens the map does not maintain the center (by panning).

I wasn't quire sure on the naming of the variable. It needed to be falsey by default to not break the API.

Let me know if you are happy with this change and I will update the docs as well.

@mourner
Copy link
Member

mourner commented Jun 21, 2013

That's a very useful addition! I'll probably change the method signature though, so that it's in line with changes to other methods like setView. E.g. map.invalidateSize({pan: false}) or map.invalidateSize({animate: true});

mourner added a commit that referenced this pull request Jun 21, 2013
…ing-center

Add parameter to invalidateSize for changing the center.
@mourner mourner merged commit 38b2f0a into Leaflet:master Jun 21, 2013
@jacobtoye jacobtoye deleted the invalidate-size-without-changing-center branch June 21, 2013 03:18
@jacobtoye
Copy link
Member Author

Awesome, thanks @mourner. I think it would be much nicer as you describe, however I wanted to be sure it didn't break any existing applications. I.e. if people already use map.invalidateSize(true).

@yohanboniface
Copy link
Member

Great small change, guys, thanks! Will use it right now :)

yohanboniface added a commit to umap-project/Leaflet.Storage that referenced this pull request Jun 21, 2013
@mourner
Copy link
Member

mourner commented Jun 24, 2013

@yohanboniface method signature changed, please update it once again :) #1767

@mourner
Copy link
Member

mourner commented Jun 24, 2013

@jacobtoye in the change above, I made sure the old signature (passing true) also works.

@yohanboniface
Copy link
Member

@mourner, thanks! Done :)

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.

3 participants