Skip to content

Instantly share code, notes, and snippets.

@pilssalgi
Last active October 14, 2018 14:54
Show Gist options
  • Save pilssalgi/703bc32726c7a03fc2d39b06da4c37a6 to your computer and use it in GitHub Desktop.
Save pilssalgi/703bc32726c7a03fc2d39b06da4c37a6 to your computer and use it in GitHub Desktop.
fitSize.js
var frameW = this.compareTargetInfo.width,
frameH = this.compareTargetInfo.height,
aspect = this.targetInfo.aspect,
targetCss = this.targetInfo.css;
if(frameW/aspect < frameH){
targetCss.width = frameH*aspect;
targetCss.height = frameH;
}else{
targetCss.width = frameW;
targetCss.height = frameW/aspect;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment