rubenspgcavalcante / leaflet-ant-path

🌿🐜 Creates a leaflet polyline with a 'ant-path' animated flux
http://rubenspgcavalcante.github.io/leaflet-ant-path
MIT License
467 stars 80 forks source link

no aniation when zoom<=0 #90

Open ValkA opened 5 years ago

ValkA commented 5 years ago

Type:

Environment:

I'm going to open a PR:

Description: When zooming out to <= 0 the animation freezes. Zooming back to >0 the animation unfreezes.

Zoom <= 0 is useful especially when using an ImageOverlay map together with CRS.Simple coordinates.

jontay81 commented 5 years ago

Looks like animationDuration becomes negative or results in divide/0 as zoomLevel decreases. I don't have time for a PR now, but if you wrap zoomLevel like this it should fix: const zoomLevel = Math.max(4, _map.getZoom());

https://github.com/rubenspgcavalcante/leaflet-ant-path/blob/aebf3213a7de5cb647853db0539e485dc958257a/src/plugin/components/ant-path.component.js#L110-L114

April-lemonade commented 6 months ago

It works for me to simply add the attribution of animation-duration to the polyline elements

let temp = document.getElementsByClassName("leaflet-interactive");
for (let i = 0; i < temp.length; i++) {
  temp[i].style["animation-duration"] = '1s';
}