Skip to content

Instantly share code, notes, and snippets.

@shaunoconnor
Created April 11, 2011 03:36
Show Gist options
  • Save shaunoconnor/913027 to your computer and use it in GitHub Desktop.
Save shaunoconnor/913027 to your computer and use it in GitHub Desktop.
/**
* Image Cycle - Prototype / Test only
*/
var imageArray = [ 'images/venice_carnival_1.jpg',
'images/venice_carnival_2.jpg',
'images/tokyo_sumo_festival_0.jpg',
'images/tokyo_sumo_festival_1.jpg',
'images/valencia_tomato_fight_0.jpg',
'images/valencia_tomato_fight_1.jpg',
'images/venice_carnival_0.jpg'];
function imageRollOver(container, imagearray) {
var target = document.getElementById(container);
var delay = 200;
var i = 0;
var imageCycle = setInterval(cycleThroughImages, delay);
target.onmouseout = onMouseOutReset;
function cycleThroughImages() {
if (i < imagearray.length - 1) {
i = i + 1;
target.src = imagearray[i];
} else {
clearInterval(imageCycle);
}
}
function onMouseOutReset() {
window.clearInterval(imageCycle);
target.src = 'images/venice_carnival_0.jpg';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment