Avoid multiple setState() calls

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-06-06 08:56:12 +02:00
parent 28be581af1
commit c3fdd73357
No known key found for this signature in database
GPG Key ID: 9760693FDD98A790
1 changed files with 4 additions and 1 deletions

View File

@ -144,11 +144,14 @@ export default class ImageView extends React.Component<IProps, IState> {
// image by default
const minZoom = Math.min(zoomX, zoomY) * MAX_SCALE;
if (this.state.zoom <= this.state.minZoom) this.setState({zoom: minZoom});
// If zoom is smaller than minZoom don't go beneath that value
const zoom = (this.state.zoom <= this.state.minZoom) ? minZoom : this.state.zoom;
this.setState({
minZoom: minZoom,
maxZoom: 1,
rotation: this.rotation,
zoom: zoom,
});
}