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

Feature: add callback for animations #5350

Closed
dawadam opened this issue Feb 20, 2017 · 7 comments
Closed

Feature: add callback for animations #5350

dawadam opened this issue Feb 20, 2017 · 7 comments

Comments

@dawadam
Copy link

dawadam commented Feb 20, 2017

Hello,
I'm using version 1.0.3

You can't set the boundary and use an animation at the same time, like this:

This.map.flyToBounds (myBounds)
This.map.setMaxBounds (myBounds)

Exemple : http://playground-leaflet.rhcloud.com/yeya/1/edit

One solution is by adding "moveend" listener who will launch setMaxBounds once the animation finishes, but it's complicated and we must filter events.

Why not add a "end of the animation" callback function in parameters ?

@perliedman
Copy link
Member

It doesn't look like the linked example provides any useful information, am I missing something?

You could add a one-time moveend listener specifically for your flyTo animation:

map.flyToBounds(bounds);
map.once('moveend', function() {
    map.setMaxBounds(bounds);
});

@dawadam
Copy link
Author

dawadam commented Feb 21, 2017

I think you aremissing somthing, look at the javascript tab.
Thanks for "once", it work.

@dawadam
Copy link
Author

dawadam commented Mar 8, 2017

There is a problem.
If the move of the map is automatic, by "flyTo" method and if we stop via a drag with mouse, event is not called.

@dawadam dawadam reopened this Mar 8, 2017
@perliedman
Copy link
Member

perliedman commented Mar 8, 2017

Ok, could you provide an illustration of the issue?

I modified your previous example with a once('moveend'), and it works as I would expect if I pan the map in the middle of the fly to: the map's max bounds are correctly set and the map is locked around Paris: http://playground-leaflet.rhcloud.com/xih/edit?html,js,output

@dawadam
Copy link
Author

dawadam commented Mar 8, 2017

Ok, I've updated the example.
Now at the end of the movement, a marker is added to the center of Paris.

http://playground-leaflet.rhcloud.com/xiwi/1/edit?html,js,output

In some cases, when moving is stopped, the marker appears a little later (probably corresponding to the end of automatic movement).

In the other, it does not appear at all.
It appear if new moving on of the map.

@perliedman
Copy link
Member

I was able to reproduce this problem by just clicking (not dragging) the map while the flyTo animation was running.

My guess is that the click aborts the animation since the user begins a pan operation, but since the map is actually never dragged, no moveEnd event is fired. I would consider this a bug, so we will have to investigate further.

@dawadam
Copy link
Author

dawadam commented Mar 8, 2017

Ok,
Good news.

I repeat, sometimes the event is still launched.
Test clicking at the end of the movement to stop the map.

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

No branches or pull requests

4 participants