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
Map.panInsideBounds: lookahead and center view #1946
Conversation
Please fix the build errors. |
Thanks! Looks like a good way to approach this, will probably be merged. |
It would also be great to add some tests to cover the maxBounds behavior along with these changes so that we don't accidentally regress in future. |
May i mention that i think enforcing minzoom is not the right behavior ? Giving a way to calculate minzoom easily is nice, though. I won't bother patching this because doing |
Is there something wrong with that pull request ? |
Sorry, no, it's just that I'm on vacation atm, coming back on Tuesday. :) |
Antibump : i'll add another commit on top of this, to disable automatic _boundsMinZoom which gets in the way of this new panInsideBounds. |
Ooops, somehow I missed notifications of this being worked on. Looks pretty good! Will do some testing and then merge. Thanks Jérémy! |
About zoom limiting... If we do remove it and then rely on users setting minZoom explicitly in case they need it, it won't work exactly the same, as the minZoom adjusts depending on the size of the map which can be fluid. Should we make this behavior an option instead of removing it? |
I don't think it's that useful an option, but am ok with changing the PR to make it one. |
@danzel @tmcw @jfirebaugh should we add an option, or ditch the dynamic minZoom, what do guys you think? |
Did anyone request it in the first place or did we add it because we thought it'd be cool? |
I think I added it because I thought it made sense, but I could be wrong. |
OK, tested the interaction on the |
I've tested with only square-ish bounds... i'll push fixes asap. |
Deltas are calculated on x, y pixel coordinates separately. Options are propagated from setMaxBounds to panBy. No panBy loops. Fixes Leaflet#1908.
It still jumps, but it does calculate it on each direction independently. About the "jumps": panBy is useful to make the user realize it's out of bounds. |
Going to wrap up with 0.7 during next week and this will get merged, maybe with some tweaks, fixing a big bunch of maxBounds-related issues. Thanks a lot for working on this @kapouer! |
Made a new pull based on your work, with proper zoom anchoring and code cleanup. |
This avoids loops and provides a sensible fix
for #1908.