Skip to content

Commit

Permalink
fixed isLoading to show indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
JediWattson committed Mar 1, 2023
1 parent 6bfc8bb commit 8304865
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/ImageView/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ class ImageView extends PureComponent {
});

this.configureImageZoom = this.configureImageZoom.bind(this);
this.imageLoadingStart = this.imageLoadingStart.bind(this);
}

componentDidUpdate(prevProps) {
if (this.props.url === prevProps.url || !this.interactionPromise) {
return;
}
this.imageLoadStart();
this.state.interactionPromise.cancel();
}

Expand Down Expand Up @@ -99,6 +99,7 @@ class ImageView extends PureComponent {
configureImageZoom({nativeEvent}) {
// Wait till animations are over to prevent stutter in navigation animation
this.state.interactionPromise = InteractionManager.runAfterInteractions(() => {
this.setState({ imageHeight: 0, imageWidth: 0, isLoading: true });
if (this.imageZoomScale !== 1) {
this.imageZoomScale = 1;
}
Expand Down Expand Up @@ -133,6 +134,10 @@ class ImageView extends PureComponent {
});
}

imageLoadingStart() {
this.setState({ isLoading: true });
}

render() {
// Default windowHeight accounts for the modal header height
const windowHeight = this.props.windowHeight - variables.contentHeaderHeight;
Expand Down Expand Up @@ -205,6 +210,7 @@ class ImageView extends PureComponent {
source={{uri: this.props.url}}
isAuthTokenRequired={this.props.isAuthTokenRequired}
resizeMode={Image.resizeMode.contain}
onLoadStart={this.imageLoadingStart}
onLoad={this.configureImageZoom}
/>
{/**
Expand Down

0 comments on commit 8304865

Please sign in to comment.