Get rid of onWindowResize()

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-04-24 08:37:51 +02:00 committed by J. Ryan Stinnett
parent 6a405fa8e8
commit 464ebe900d
1 changed files with 2 additions and 6 deletions

View File

@ -104,7 +104,7 @@ export default class ImageView extends React.Component<IProps, IState> {
// We have to use addEventListener() because the listener
// needs to be passive in order to work with Chromium
this.focusLock.current.addEventListener('wheel', this.onWheel, { passive: false });
window.addEventListener("resize", this.onWindowResize);
window.addEventListener("resize", this.calculateZoom);
this.calculateZoom();
}
@ -112,11 +112,7 @@ export default class ImageView extends React.Component<IProps, IState> {
this.focusLock.current.removeEventListener('wheel', this.onWheel);
}
private onWindowResize = (ev) => {
this.calculateZoom();
}
private calculateZoom() {
private calculateZoom = () => {
// TODO: What if we don't have width and height props?
const imageWrapper = document.getElementsByClassName(IMAGE_WRAPPER_CLASS)[0];