Skip to content

Commit 483a8b7

Browse files
committed
added back some functions, made sure redundant do not happen
1 parent 9e178e2 commit 483a8b7

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/components/ImageView/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ class ImageView extends PureComponent {
225225
}
226226

227227
imageLoadingStart() {
228+
if (this.state.isLoading) {
229+
return;
230+
}
228231
this.setState({isLoading: true, zoomScale: 0, isZoomed: false});
229232
}
230233

@@ -248,6 +251,7 @@ class ImageView extends PureComponent {
248251
// When Image dimensions are lower than the container boundary(zoomscale <= 1), use `contain` to render the image with natural dimensions.
249252
// Both `center` and `contain` keeps the image centered on both x and y axis.
250253
resizeMode={this.state.zoomScale > 1 ? Image.resizeMode.center : Image.resizeMode.contain}
254+
onLoadStart={this.imageLoadingStart}
251255
onLoad={this.imageLoad}
252256
/>
253257
{this.state.isLoading && (
@@ -286,6 +290,7 @@ class ImageView extends PureComponent {
286290
styles.w100,
287291
]} // Hide image until finished loading to prevent showing preview with wrong dimensions.
288292
resizeMode={Image.resizeMode.contain}
293+
onLoadStart={this.imageLoadingStart}
289294
onLoad={this.imageLoad}
290295
/>
291296
</Pressable>

src/components/ImageView/index.native.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ class ImageView extends PureComponent {
6464
return;
6565
}
6666

67+
this.imageLoadingStart();
68+
6769
if (this.interactionPromise) {
6870
this.state.interactionPromise.cancel();
6971
}
70-
71-
if (!this.state.isLoading) {
72-
this.imageLoadingStart();
73-
}
7472
}
7573

7674
componentWillUnmount() {
@@ -147,6 +145,9 @@ class ImageView extends PureComponent {
147145
}
148146

149147
imageLoadingStart() {
148+
if (this.state.isLoading) {
149+
return;
150+
}
150151
this.resetImageZoom();
151152
this.setState({imageHeight: 0, imageWidth: 0, isLoading: true});
152153
}

0 commit comments

Comments
 (0)