louisremi / jquery.transition.js

Upgrade jQuery's .animate() method to use CSS3 Transitions in modern browsers.
435 stars 81 forks source link

Timer keeps running (timerId is never cleared) #4

Closed dbeard closed 13 years ago

dbeard commented 13 years ago

After doing an animation using the traditional animation function (In my case, I was using a non-DOM object), the tick timer continues to run continually. This causes css transitions to halt as soon as the next tick hits (pretty much instantaneously).

I've been able to fix it by adding:

if(timerId){
    clearInterval( timerId );
    timerId = null;
}

inside the if(done) statement in the custom function. I can do a pull request if you would like.

dbeard commented 13 years ago

Thinking about this more - there's a bigger problem here I think. There is no way to run a css transition and traditional animation at the same time. The example I've used for testing:

$("div").click(function(){
    $this = $(this);

targetTop = 300;
if(parseFloat($this.css('top')) > 0)
                targetTop = 0;

            $this.animate({top:targetTop},{duration:500});
            $({test:0}).animate({test:100},{complete:function(){
                console.log("Object animation complete")
            }});
        });

If I run this, the first "css" transition stops and/or completes immediately since the second animate function on the non-DOM object causes the tick to fire and stops it.

louisremi commented 13 years ago

hmm, this is worth investigating

dbeard commented 13 years ago

So, I've actually gone through the code, and it looks like the main problem was that the base of your code seems to be based off of an older version of jquery. I was using the newest 1.6.1 release, and while it generally appears to work on the surface, there are definitely some problems as described above. The new version has some key changes that is causing issues. I have gone through and merged the changes into your code, and it all appears to be working correctly now. I will fork and do a pull request for you to look at it

louisremi commented 13 years ago

Thanks, I am aware of the changes that happened in jQuery but just never took the time to rewrite the plugin based on the newest version.

louisremi commented 13 years ago

pushing a solution, tell me if that solves your problem