calculateZoomAndRotate -> setZoomAndRotation
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
5880cb3b5f
commit
0918ebad0a
1 changed files with 7 additions and 7 deletions
|
@ -104,18 +104,18 @@ export default class ImageView extends React.Component<IProps, IState> {
|
||||||
// needs to be passive in order to work with Chromium
|
// needs to be passive in order to work with Chromium
|
||||||
this.focusLock.current.addEventListener('wheel', this.onWheel, { passive: false });
|
this.focusLock.current.addEventListener('wheel', this.onWheel, { passive: false });
|
||||||
// We want to recalculate zoom whenever the window's size changes
|
// We want to recalculate zoom whenever the window's size changes
|
||||||
window.addEventListener("resize", this.calculateZoomAndRotate);
|
window.addEventListener("resize", this.setZoomAndRotation);
|
||||||
// After the image loads for the first time we want to calculate the zoom
|
// After the image loads for the first time we want to calculate the zoom
|
||||||
this.image.current.addEventListener("load", this.calculateZoomAndRotate);
|
this.image.current.addEventListener("load", this.setZoomAndRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.focusLock.current.removeEventListener('wheel', this.onWheel);
|
this.focusLock.current.removeEventListener('wheel', this.onWheel);
|
||||||
window.removeEventListener("resize", this.calculateZoomAndRotate);
|
window.removeEventListener("resize", this.setZoomAndRotation);
|
||||||
this.image.current.removeEventListener("load", this.calculateZoomAndRotate);
|
this.image.current.removeEventListener("load", this.setZoomAndRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private calculateZoomAndRotate = () => {
|
private setZoomAndRotation = () => {
|
||||||
const image = this.image.current;
|
const image = this.image.current;
|
||||||
const imageWrapper = this.imageWrapper.current;
|
const imageWrapper = this.imageWrapper.current;
|
||||||
|
|
||||||
|
@ -203,13 +203,13 @@ export default class ImageView extends React.Component<IProps, IState> {
|
||||||
private onRotateCounterClockwiseClick = () => {
|
private onRotateCounterClockwiseClick = () => {
|
||||||
const cur = this.state.rotation;
|
const cur = this.state.rotation;
|
||||||
this.rotation = cur - 90;
|
this.rotation = cur - 90;
|
||||||
this.calculateZoomAndRotate();
|
this.setZoomAndRotation();
|
||||||
};
|
};
|
||||||
|
|
||||||
private onRotateClockwiseClick = () => {
|
private onRotateClockwiseClick = () => {
|
||||||
const cur = this.state.rotation;
|
const cur = this.state.rotation;
|
||||||
this.rotation = cur + 90;
|
this.rotation = cur + 90;
|
||||||
this.calculateZoomAndRotate();
|
this.setZoomAndRotation();
|
||||||
};
|
};
|
||||||
|
|
||||||
private onDownloadClick = () => {
|
private onDownloadClick = () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue