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: { });
top: crop.left, this.setCrop({
left: crop.bottom, top: crop.left,
bottom: crop.right, left: crop.bottom,
right: crop.top, bottom: crop.right,
}, 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: { });
top: crop.right, this.setCrop({
right: crop.bottom, top: crop.right,
bottom: crop.left, right: crop.bottom,
left: crop.top, bottom: crop.left,
}, left: crop.top,
}); });
}; };