I have used the slideUp/Down functions in Jquery to animate a div on my page, but it runs poorly on iPhones, so I decided to write a Webkit equivalent to solve the performance problem, but you cannot apply a callback to the jQuery .css, or .addclass.
I have this function:
$('#collapse').css('height','0');
But I need to fake a callback essentially make this work:
$('#collapse').css('height','0', function() {
//do something after
});
Anyone know how to do this?
The Webkit animation is set to 1 sec.
Just use setTimeout
; jQuery has no way of telling whether an inbuilt browser animation has completed:
$('#collapse').css('height', 0);
setTimeout(function() {
// code will happen after the timeout has completed
}, 1000); // 1 second
The downside of this is that you have to set the time for the animation in two places.