fix rotate crop adjustment

This commit is contained in:
Jason Miller
2020-12-14 16:45:15 -05:00
parent 82914f9cde
commit 588ec61543

View File

@@ -263,6 +263,8 @@ export default class Transform extends Component<Props, State> {
crop.left += crop.right; crop.left += crop.right;
crop.right = 0; crop.right = 0;
} }
if (crop.left < 0 || crop.right < 0) crop.left = crop.right = 0;
if (crop.top < 0 || crop.bottom < 0) crop.top = crop.bottom = 0;
this.setState({ crop }); this.setState({ crop });
} }
@@ -271,12 +273,12 @@ export default class Transform extends Component<Props, State> {
let { rotate, crop } = this.state; let { rotate, crop } = this.state;
this.setState({ this.setState({
rotate: ((rotate + 90) % 360) as typeof ROTATE_ORIENTATIONS[number], rotate: ((rotate + 90) % 360) as typeof ROTATE_ORIENTATIONS[number],
crop: { });
this.setCrop({
top: crop.left, top: crop.left,
left: crop.bottom, left: crop.bottom,
bottom: crop.right, bottom: crop.right,
right: crop.top, right: crop.top,
},
}); });
}; };
@@ -286,12 +288,12 @@ export default class Transform extends Component<Props, State> {
rotate: (rotate rotate: (rotate
? rotate - 90 ? rotate - 90
: 270) as typeof ROTATE_ORIENTATIONS[number], : 270) as typeof ROTATE_ORIENTATIONS[number],
crop: { });
this.setCrop({
top: crop.right, top: crop.right,
right: crop.bottom, right: crop.bottom,
bottom: crop.left, bottom: crop.left,
left: crop.top, left: crop.top,
},
}); });
}; };