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
parent f8af9831a9
commit 57b34f8dbc
No known key found for this signature in database
GPG Key ID: 9760693FDD98A790
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];