Skip to content

Commit

Permalink
Invert props order check on update (#17)
Browse files Browse the repository at this point in the history
This fixes an issue that prevents updating at the same time zoom and aspect ratio. Because `computeSizes` also recomputes crop position, if aspect ratio and/or zoom are changed, both values will be updated
  • Loading branch information
tafelito authored and ValentinH committed Oct 22, 2018
1 parent 194327d commit 578fb0e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class Cropper extends React.Component {
}

componentDidUpdate(prevProps) {
if (prevProps.zoom !== this.props.zoom) {
this.recomputeCropPosition()
} else if (prevProps.aspect !== this.props.aspect) {
if (prevProps.aspect !== this.props.aspect) {
this.computeSizes()
} else if (prevProps.zoom !== this.props.zoom) {
this.recomputeCropPosition()
}
}

Expand Down

0 comments on commit 578fb0e

Please sign in to comment.