Are you any good with js yourself?
You want this:
your anchor (<a>) needs display block or a float, an id attribute (must be unique, for instance id=âmodel1â) and give it a width + height. Give it a background image (first image of the model). What youâll do is change the background image of the anchor after a few seconds (for instance 1 sec / image, then next).
To be able to successfully animate this, weâll need to know how many images the current model has. This may be dynamic (might as well right?). That means weâll need to keep track of the models.
First, lets create an object that holds the info (put this between the <head></head>):
<script type=âtext/javascriptâ>
var models = new Object;
</script>
After each anchor, weâd need to put a piece of script that holds the information about the model.
<script type=âtext/javascriptâ>
models[âmodel1â] = new Object;
models[âmodel1â].images = new Array(âimage1.jpgâ,âimage2.jpgâ,âetcâ);
</script>
You can continue this for each model.
Next we need the animation. This also goes in the head, in the same <script> tag as we created before:
<script type=âtext/javascriptâ>
var models = new Object;
function animate_anchor(anchor_id, image_key){
if (!image_key){ image_key = 1; }
var the_anchor = document.getElementById(anchor_id);
if (!models[anchor_id].images[image_key]){
image_key = 0;
}
the_anchor.style.backgroundImage = âurl(â+models[anchor_id].images[image_key]+â)â;
var next_image_key = image_key + 1;
models[anchor_id].timeout = setTimeout(âanimate_anchor("â+anchor_id+â", â+next_image_key+â)â, 1000);
}
function animate_anchor_stop(anchor_id){
document.getElementById(anchor_id).style.backgroundImage = âurl(â+models[anchor_id].images[0]+â)â;
clearTimeout(models[anchor_id].timeout);
}
</script>
Next, weâll need to make sure the anchor does itâs job when hovering over it, and stopping it when hovering out. We use onmouseover and onmouseout:
onmouseover=âanimate_anchor(âmodel1â);â onmouseout=âanimate_anchor_stop(âmodel1â);â
Of course for each model you increase the model number.
Now let me post this for you, and in the meantime Iâll see if it actually works and debug afterwards
[edit]
seems to work allright now, one adjustment required. Make sure you put the original image in the object array, else it wonât cycle along.