Chris W. Parker wrote:
> Hello,
>
> I've got a loading animation that appears each time a request is made
> through AJAX but I'm thinking about getting rid of it altogether because
> the loading happens so quickly. The animation is actually just kind of
> annoying.
>
> But I was thinking that instead of getting rid of it entirely I could
> just make it appear if the loading takes longer than n-seconds. I'm
> using ajaxStart() and ajaxStop() to show the animation.
Hi Chris,
This may work (untested):
(function() {
var id;
$('select-your-anim-element')
.ajaxStart(function() {
id = window.setTimeout(function() {
// do your anim here
}, 2000);
})
.ajaxStop(function() {
window.clearTimeout(id);
id = null;
// stop your anim
});
})();
ajaxStart delays the animation by 2 seconds using setTimeout,
and ajaxStop cancels the timeout function (if it hasn't already
been trigger) and stops the anim.
Regards
- Mark Gibson
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/