Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6004 from matrix-org/jryans/image-metadata-release
Browse files Browse the repository at this point in the history
[Release] Don't use the event's metadata to calc the scale of an image
  • Loading branch information
jryans authored May 10, 2021
2 parents efc8c8c + 3b97e52 commit 15035bd
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/components/views/elements/ImageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ export default class ImageView extends React.Component<IProps, IState> {
window.addEventListener("resize", this.calculateZoom);
// After the image loads for the first time we want to calculate the zoom
this.image.current.addEventListener("load", this.calculateZoom);
// Try to precalculate the zoom from width and height props
this.calculateZoom();
}

componentWillUnmount() {
Expand All @@ -120,11 +118,8 @@ export default class ImageView extends React.Component<IProps, IState> {
const image = this.image.current;
const imageWrapper = this.imageWrapper.current;

const width = this.props.width || image.naturalWidth;
const height = this.props.height || image.naturalHeight;

const zoomX = imageWrapper.clientWidth / width;
const zoomY = imageWrapper.clientHeight / height;
const zoomX = imageWrapper.clientWidth / image.naturalWidth;
const zoomY = imageWrapper.clientHeight / image.naturalHeight;

// If the image is smaller in both dimensions set its the zoom to 1 to
// display it in its original size
Expand Down

0 comments on commit 15035bd

Please sign in to comment.