views:

43

answers:

2

Here is my animation:

  $(".ImageRoller ul").animate({
    'marginLeft' : "-"+ScrollWidth+"px"
    },Speed 
    );

Now i want to make an alert or something when the animation ends. Is that even possible?

Chears Vali

+4  A: 

According to the documentation you could define a callback function which will be called once the animation ends:

animate( params, [duration], [easing], [callback] )

$(".ImageRoller ul").animate(
    {'marginLeft' : "-"+ScrollWidth+"px"},
    Speed, 
    'linear', 
    function() {
        alert('animation end');
    }
);
Darin Dimitrov
thank's for the fast answer, it works great
ValiL
i think K Prime's answer is even more correct.
joetsuihk
It's actually (or should be, internally) the same - jQuery `animate` accepts both types of calls
K Prime
+3  A: 
$(".ImageRoller ul").animate (
    {
        'marginLeft' : "-"+ScrollWidth+"px"
    },
    {
        duration: Speed,
        complete: function () { doSomething (); }
    }
);
K Prime