Created
June 21, 2014 01:01
-
-
Save jongacnik/5187382bee80bd53cc87 to your computer and use it in GitHub Desktop.
Aspect Ratio Helpers
This file contains hidden or 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
// assumes jQuery or applicable DOM library | |
function getAspectByEle(ele){ | |
var width = ele.width(); | |
var height = ele.height(); | |
return getAspectByVal(width,height); | |
} | |
function getAspectByEleAttr(ele){ | |
var width = ele.attr('width'); | |
var height = ele.attr('height'); | |
return getAspectByVal(width,height); | |
} | |
function getAspectByVal(width,height){ | |
return height/width; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment