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

Placeholder if child is responsible for the progress #30

Closed
deadcoder0904 opened this issue Nov 17, 2017 · 6 comments
Closed

Placeholder if child is responsible for the progress #30

deadcoder0904 opened this issue Nov 17, 2017 · 6 comments
Labels

Comments

@deadcoder0904
Copy link

deadcoder0904 commented Nov 17, 2017

If I am using an Image wih rn-placeholder like

<Placeholder.Media 
    size={60} 
    onReady={this.state.imageReady}
    >
       <Image source={img} onLoadEnd={() => this.setState({ imageReady: true })} />
</Placeholder.Media>

then the onLoadEnd method doesn't fire as Image is not rendered yet. So how do we achieve something like this with the component inside is the one which is responsible for the fetching of the Image. I think this can be its own issue.

I did find a workaround though by using {position: 'absolute'}

<Placeholder.Media 
    size={60} 
    onReady={this.state.imageReady}
    style={{position: 'absolute'}} 
    />
<Image source={img} onLoadEnd={() => this.setState({ imageReady: true })} />

but the above mentioned looks like a hack. Not really, but still it would be helpful if this library rather than not rendering it must be just not showing like {display: 'none'}. I didn't check the source code but as onLoadEnd is not firing I think its not rendering

@mfrachet
Copy link
Owner

Thank you for providing these issue and information. I'm going to make some experiments and give you some feedbacks.

For now, I think the only solution is to do what you're actually doing.

@deadcoder0904
Copy link
Author

Cool no problem

@mfrachet
Copy link
Owner

To encounter this problem, I though that relying on styles instead of conditional element rendering would have been a good solution. I had in mind :

  • Use height and width with 0 on the parent
  • Using display: none property

Because relying on height and width to 0 would have moved the element (top left corner would have been placed at the center of the expected image position, see the video), I wanted to make some modification to use display style property.

My problem is that it seems that display property breaks component lifecycle. This way, I never reach the onLoadEnd callback method. Here's a snack of the display problem, take a look at this snack

To be honest, I'm a bit stuck with this usecase ^^'...

@mfrachet mfrachet added the bug label Nov 27, 2017
@mfrachet
Copy link
Owner

mfrachet commented Feb 4, 2018

I will close this since it's not active from a while, but keep in mind the problem.

If I find anything to help you solve this issue, I'll give you some feedbacks 😄

@mfrachet mfrachet closed this as completed Feb 4, 2018
@EdwardOwusuAdjei
Copy link

Has this been fixed so far?

@mfrachet
Copy link
Owner

mfrachet commented Oct 2, 2018

Nop 😞

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

No branches or pull requests

3 participants