-
Notifications
You must be signed in to change notification settings - Fork 53
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
offsetFn with zoom #60
base: master
Are you sure you want to change the base?
Conversation
94f4cd1
to
2bb444f
Compare
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.
@jjimenezshaw thanks for the pull, I've added some suggestions;
} | ||
return {center: result, zoom: zoom}; | ||
} | ||
options.offsetFn = wrapFn; |
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.
This is nice to retain backwards compatibility, but I think I prefer introducing a breaking change and require the return value to always be an object.
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.
I prefer not breaking compatibility, specially if it is easy in the code. Changing the zoom is a rare scenario.
Maybe you can deprecate it, and remove in a later release (with other breaking changes?)
Co-authored-by: Jan Pieter Waagmeester <[email protected]>
Co-authored-by: Jan Pieter Waagmeester <[email protected]>
Co-authored-by: Jan Pieter Waagmeester <[email protected]>
Co-authored-by: Jan Pieter Waagmeester <[email protected]>
@jieter I had implemented almost all the suggestions. Any more comments? |
@jieter what about this PR? |
I tried running your fork, however I get the following error
This is the code I use for syncing
|
In response to #59 and #41 (thanks for the code suggestions; many are included here), this PR lets the user to return an object like
{center, zoom}
in the callbackoffsetFn
.To not break backwards compatibility, there is a wrapper function to add the zoom if only the center is returned. So both things can be returned in
offsetFn
: just the center, or an object withcenter
andzoom
.This is WIP. Still some tests and documentation to be added.
There is one example, examples/multiple_offset_zoom.html, in case you want to have a look.
There is a problem detected. In case of a.sync(b) and b.sync(a) where the zoom changes are not properly correlated, it enters in an infinite loop. Leaflet detects a zoom change, and fires an update in the other.