Larry Wieland
Larry Wieland

Reputation: 23

How to cancel an in-progress animation in Leaflet

I am working with Leafet (currently beta 2 for 1.0) and am performing some lengthy animated map moves with code like this:

    myMap.setView([someLat,someLng], myMap.getZoom(), {"pan":{"animate":true, "duration":10});

I want to be able to stop this animation while it is in progress. Searching through the leaflet API, for both the current version and for the beta I don't find any method for doing so. So how can I do it?

Upvotes: 2

Views: 1072

Answers (1)

nathansnider
nathansnider

Reputation: 2873

Calling another setView using the current map center should stop the animation in progress:

map.setView(map.getCenter(), map.getZoom(), {"animate": false});

Here is an example:

http://jsfiddle.net/nathansnider/4v2L0uze/

Upvotes: 3

Related Questions