Skip to content

Instantly share code, notes, and snippets.

@benfarahmand

benfarahmand/gist:4612183

Last active Dec 11, 2015
Embed
What would you like to do?
JQuery Image Grid. Example of working code is here: http://www.ragtimelolcat.com/
var imageWidth = 800;
var imageHeight = 450;
var gridWidth = imageWidth/10;
var gridHeight = imageHeight/10;
var halfGWidth = gridWidth/2;
var halfGHeight = gridHeight/2;
$(document).mousemove(function(e){
if(e.pageX for(var i = 0; i <= imageWidth ; i = i+gridWidth){
for(var j = 0; j <= imageHeight ; j = j +gridHeight){
if(Math.abs(e.pageX-(i-halfGWidth)) var tempY = new String(""+(j-gridHeight)/gridHeight);
var tempX = new String(""+(i-gridWidth)/gridWidth);
document.getElementById("image").src="image"+parseInt(tempY+tempX)+".jpg";
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.