hosuaby / Leaflet.SmoothMarkerBouncing

Smooth animation of marker bouncing for Leaflet.
BSD 2-Clause "Simplified" License
146 stars 28 forks source link

Bouncing breaks if it is toggled quickly #9

Closed ghost closed 6 years ago

ghost commented 6 years ago

I am toggling the bouncing when user hovers above linked element on the page. I have noticed that when the hover is fast the marker starts to bounce very quickly and weirdly(sorry I don't have video). I think this is caused by the fact that there is no .stop() method like it is for jQuery animate.

Seems like if the bouncing is not finished(reset) after it has been stoped and is triggered again, the bouncing calculations break because they think the bouncing has started from 0(ground) but in reality the previous bouncing has not finished yet so the marker is above the ground already.

hosuaby commented 6 years ago

Hello, @ivanjaros Thank for this report. You are right. In fact when you call .stop() on bouncing marker, animation doesn't stop immediately. I executes until its end. But if you are quick enough, you can restart animation before it actually ends. I am looking how to fix it

HugoHeneault commented 6 years ago

Same problem here. We should wait for the animation to end before removing the isBouncing state. I've done a quick read of your code and I don't know how to achieve this. :(

ghost commented 6 years ago

imho css animation would be better solution via css class instead of doing this problematically.

hosuaby commented 6 years ago

Sorry for delayed solution. You can try v1.1.5. It must not have such a problem