Skip to content

Commit

Permalink
reverting changes to image updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JediWattson committed Jul 20, 2022
1 parent 225fbd3 commit 5886c90
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions src/components/ImageView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ class ImageView extends PureComponent {
}

componentDidMount() {
this.updateImageSize(true);
}

componentDidUpdate() {
this.updateImageSize(false);
if (this.canUseTouchScreen) {
return;
}
Image.getSize(this.props.url, (width, height) => {
this.setImageRegion(width, height);
});
document.addEventListener('mousemove', this.trackMovement.bind(this));
}

componentWillUnmount() {
Expand Down Expand Up @@ -171,22 +173,6 @@ class ImageView extends PureComponent {
return {offsetX, offsetY};
}

/**
* ideally this is called everytime the prop url changes to update any differences in size
* @param {Boolean} isMounting
*/
updateImageSize(isMounting) {
if (this.canUseTouchScreen) {
return;
}
Image.getSize(this.props.url, (width, height) => {
this.setImageRegion(width, height);
});
if (isMounting) {
document.addEventListener('mousemove', this.trackMovement.bind(this));
}
}

trackMovement(e) {
if (!this.state.isZoomed) {
return;
Expand Down

0 comments on commit 5886c90

Please sign in to comment.