Last active
December 11, 2015 14:08
-
-
Save benfarahmand/4612183 to your computer and use it in GitHub Desktop.
JQuery Image Grid. Example of working code is here: http://www.ragtimelolcat.com/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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