Created
March 23, 2012 23:30
-
-
Save bbbrrriiiaaannn/2176356 to your computer and use it in GitHub Desktop.
Lazy pre-Backstretch Backstretch
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
$(window).resize(function(evt){ | |
var imgDim = [ $("img#homepage-image").width(), $("img#homepage-image").height() ]; | |
var bodyDim = [ $(document.body).width(), $(document.body).height() ]; | |
$("#homepage-image-wrapper").width(bodyDim[0]).height(bodyDim[1]); | |
var widthRatio = imgDim[0]/bodyDim[0]; | |
var heightRatio = imgDim[1]/bodyDim[1]; | |
if( widthRatio > heightRatio ) { | |
$("img#homepage-image").height(bodyDim[1]).width(imgDim[0]/heightRatio); | |
} else { | |
$("img#homepage-image").width(bodyDim[0]).height(imgDim[1]/widthRatio); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment