rubenspgcavalcante/leaflet-ant-path

no aniation when zoom<=0

ValkA opened this issue · 2 comments

ValkA commented

Type:

  • bug
  • feature
  • enhancement
  • question

Environment:

I'm going to open a PR:

  • yes
  • no

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.

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());

const zoomLevel = _map.getZoom();
const animatedPolyElements = document.getElementsByClassName(_animatedPathId);
//Get the animation duration (in seconds) based on the given delay and the current zoom level
const animationDuration = 1 + options.delay / 3 / zoomLevel + "s";