mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-18 06:27:19 +08:00
Don't allow translation when zoomed out
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
722178e26e
commit
429c945bbf
@ -191,6 +191,12 @@ export default class ImageView extends React.Component {
|
|||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
|
// Zoom in if we are completely zoomed out
|
||||||
|
if (this.state.zoom === MIN_ZOOM) {
|
||||||
|
this.setState({zoom: MAX_ZOOM});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({moving: true});
|
this.setState({moving: true});
|
||||||
this.previousX = this.state.translationX;
|
this.previousX = this.state.translationX;
|
||||||
this.previousY = this.state.translationY;
|
this.previousY = this.state.translationY;
|
||||||
@ -213,21 +219,17 @@ export default class ImageView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onEndMoving = () => {
|
onEndMoving = () => {
|
||||||
// Zoom in or out if we haven't moved much
|
// Zoom out if we haven't moved much
|
||||||
if (
|
if (
|
||||||
this.state.moving === true &&
|
this.state.moving === true &&
|
||||||
Math.abs(this.state.translationX - this.previousX) < 10 &&
|
Math.abs(this.state.translationX - this.previousX) < 10 &&
|
||||||
Math.abs(this.state.translationY - this.previousY) < 10
|
Math.abs(this.state.translationY - this.previousY) < 10
|
||||||
) {
|
) {
|
||||||
if (this.state.zoom === MIN_ZOOM) {
|
this.setState({
|
||||||
this.setState({zoom: MAX_ZOOM});
|
zoom: MIN_ZOOM,
|
||||||
} else {
|
translationX: 0,
|
||||||
this.setState({
|
translationY: 0,
|
||||||
zoom: MIN_ZOOM,
|
});
|
||||||
translationX: 0,
|
|
||||||
translationY: 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.setState({moving: false});
|
this.setState({moving: false});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user