Skip to content

Instantly share code, notes, and snippets.

@nanlabsweb
Created March 19, 2018 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanlabsweb/f2dd1c81606b1df1f42e56b6dd9cca90 to your computer and use it in GitHub Desktop.
Save nanlabsweb/f2dd1c81606b1df1f42e56b6dd9cca90 to your computer and use it in GitHub Desktop.
setImageSize(width, height){
if (this.props.width && !this.props.height) {
this.setState({
width: this.props.width,
height: height * (this.props.width / width)
});
} else if (!this.props.width && this.props.height) {
this.setState({
width: width * (this.props.height / height),
height: this.props.height
});
} else {
this.setState({
width: width,
height: height
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment