Igor-Vladyka / leaflet.motion

A simple tool to animate polylines and polygons in different way
https://igor-vladyka.github.io/leaflet.motion/
MIT License
207 stars 44 forks source link

Enable appending layers to motion sequences (to continue drawing a line after it's been started) #25

Closed Patabugen closed 2 years ago

Patabugen commented 2 years ago

In response to this issue: https://github.com/Igor-Vladyka/leaflet.motion/issues/16

I've refactored the Sequence group a little so we can call addLayer() to add an animation step in the sequence after initialisation.

I've also added an examples folder as a form of documentation but also so I could use it for testing/developing this feature.

A couple of things to note:

Example:

var trackPolyline = L.motion.polyline(trackRoute).motionDuration(2000);
var shipPolyline = L.motion.polyline(shipRoute).motionDuration(2000);
var carPolyline = L.motion.polyline(carRoute).motionDuration(2000);

// Build the Sequence Group:
var seqGroup = L.motion.seq([
    trackPolyline, shipPolyline
]).addTo(map);

// You can now call addLayer()            
seqGroup.addLayer(carPolyline);

If the animation hasn't started, the layer is just made ready, if the sequence has been started the new layer will either wait it's turn or start animating immediately if the existing sequence is finished.

Igor-Vladyka commented 2 years ago

Overall it's a good idea and a valid approach, but need more in-deept modification to SEQ and to the root motion module.

Please resolve conflicts, and merge it into separate branch.

Igor-Vladyka commented 2 years ago

I've integrated part of your changes into the plugin, and part of documentation for it. Please check it out, and test it.

Patabugen commented 2 years ago

Thanks @Igor-Vladyka ! I'm hoping to spend some time on the project using this in the next month or two so will have a look!

GitHub is saying some commits aren't merged, but I'm not sure how to see which they are - do you know how to? (I'm mostly curious to see which ones).