Skip to content

Instantly share code, notes, and snippets.

@joshuacerbito
Last active July 15, 2016 04:13
Show Gist options
  • Save joshuacerbito/d7e34095fb9b230fd01cd84f80e32bb7 to your computer and use it in GitHub Desktop.
Save joshuacerbito/d7e34095fb9b230fd01cd84f80e32bb7 to your computer and use it in GitHub Desktop.
Get new width or height while preserving the aspect ratio
// Description: Get new width or height while preserving the aspect ratio
// TODO: Add AspectRatio related methods
var AspectRatio = {
getScaled: function ( currentW, currentH, newSize, property ) {
return ( property === 'width' )? ((currentH / currentW) * newSize) : (currentW / currentH) * newSize)
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment