Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q718 How can one tell when an animation has finished running?

You are here: irt.org | FAQ | JavaScript | Image | Q718 [ previous next ]

If its an animated gif, then it might be possible. IIRC one browser triggers an onLoad event for the image for every image "frame" loaded. You could trap the onLoad event using the onLoad event handler, count them and work out when the image has finished animating:

<SCRIPT LANGUAGE="JavaScript"><!--
var myCount = 0;
var maxCount = 10;

function counter() {
    myCount++;
    if (myCount > maxCount)
        alert('Finished');
}
//-->

<IMG SRC="animated.gif" onLoad="counter()" WIDTH="100" HEIGHT="100">

Feedback on 'Q718 How can one tell when an animation has finished running?'

©2018 Martin Webb