Share Posted April 17, 2016 Hi everyone, in simple words here is what I'm trying to achieve: Start an infinite animation when the user hover a div Pause the animation when the user leave, but after the animation is completed. I recreated a codepen as you can see, when I go out of the svg, the animation goes to the end but after it doesn't start anymore. ps: I tried to add play(0) but it will play once (probably because of the callback onRepeat) EDIT: while posting I had an idea and looks like it works I just remove the onRepeat callback on the mouseEnter in this way: $("svg").hover(function() { hoverDog.play(); hoverDog.eventCallback("onRepeat", function(){}); }, function() { hoverDog.eventCallback("onRepeat", function(){ hoverDog.pause();}); }); See the Pen NNMaeK by anon (@anon) on CodePen 2 Link to post Share on other sites
Solution Share Posted April 18, 2016 Thanks for the demo. I have to congratulate you on a very clever solution! The only thing I would add is that you can just pass in null instead of an empty function. $("svg").hover(function() { hoverDog.play(); hoverDog.eventCallback("onRepeat", null); }, function() { hoverDog.eventCallback("onRepeat", function(){ hoverDog.pause();}); }); Great job! 3 Link to post Share on other sites