Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android not triggering onLoadEnd if image width and height is 0 #355

Open
compojoom opened this issue Nov 27, 2018 · 3 comments
Open

Android not triggering onLoadEnd if image width and height is 0 #355

compojoom opened this issue Nov 27, 2018 · 3 comments

Comments

@compojoom
Copy link

I was displaying a placeholder when the image is not yet loaded.

I'm doing something like this

{!this.state.loaded ? this.renderPlaceholder() : null}
<FastImage
            source={{uri: uri, cache: 'immutable'}}
            style={[{...size, borderRadius: 5}, this.state.loaded ? {} : {width: 0, height: 0}]}
            onLoadEnd={this.onLoadEnd.bind(this)}
          />
```

onLoadEnd I set the state of loaded to true. This works perfectly fine on iOS, but on Android the onLoadEnd event is never triggered when we have width and height of 0. So you end up with hacks to make it work on both Platform. I ended up ditching the 0 width and height and absolutely positioning the image behind the placeholder. This way you don't see a jump in the UI when the image gets loaded and the placeholder is destroyed.
@romk1n
Copy link

romk1n commented Jan 17, 2019

same issue

@empiteranga
Copy link

remove {width: 0, height: 0}
works fine for me, use overlay view using position absolute

@samih-dev
Copy link

trying to use display: none, also faced this, onLoadEnd didn't get triggered.

so switching to opacity: <condition> ? 1 : 0 on my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants