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

Increase/decrease speed during animation with button click #12

Closed cassiamani closed 4 years ago

cassiamani commented 4 years ago

Hello, i would like change speed option during animation, I tried change option speed and call function 'motionSpeed()', but it's just work if called before animation.

I saw the issue #2 wich was explained how to use the option easing to move the marker more fast, but if i change the value during animation, the marker jump ahead instead of increase speed:

sample: `var speed = 2;

easing: function(durationRatio, elapsedTime, x, y, durationTime) { return durationRatio * speed; }

function increaseSpeed() { speed = 4; } ` When a call the function increaseSpeed() the marker jump ahead.

Example of how it should work: https://jsfiddle.net/wg1pxash/7/

Sorry my bad english, and thanks so much at moment.

Igor-Vladyka commented 4 years ago

Hi,

I extended motionSpeed function to work nicelly during animation. Now you can dynamically change animation speed and/or duration.

Please test it and let me know if any.

Regards, Igor

cassiamani commented 4 years ago

Hi Igor, I would like ask apologize, because i had already tested the function motionSpeed, but it's wasn't working, after you response i was verify, and the problem was in the version of lib, i used a old version, heheh, anyway, thanks so much and sorry for my inattention.

PeterPan73 commented 2 years ago

@cassiamani Hi, I want to do the same, but I'm having a hard time. Can you help me by sharing a code of how you did it. I will be very grateful to you. Thanks.