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

[ScollView/ListView] contentOffsets, contentInsets strange behavior #1641

Closed
marcshilling opened this issue Jun 16, 2015 · 10 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@marcshilling
Copy link

I am trying to make a simple ListView which has a search bar header that is hidden behind the nav bar by default, but upon scrolling you can reveal it (a pretty standard iOS interaction). Has anyone had success with this? I am seeing some pretty strange behavior.

Here is my ListView setup. The list view is behind both a nav bar and a tab bar (hence the content insets):

<ListView
   ref='listView'
   style={styles.listView}
   dataSource={this.state.dataSource}
   renderHeader={::this.renderHeader}
   renderRow={::this.renderRow}
   contentOffset={{x: 0, y: -20}}
   contentInset={{top: 64, bottom: 49}}
   automaticallyAdjustContentInsets={false}
/>

The "strange behavior" I mention is that the "contentOffset" prop (which I believe is how this should be accomplished) seems to have no effect upon this view first appearing. I can set that Y value to anything and the view looks the same when it is presented (the search bar is displayed at the top). However, if I change that Y value and save, the simulator live reloads and seems to adjust the offset properly.

UPDATE:
I've found a really dumb, hacky way of getting around this:

If in componentDidMount I do this:

 setTimeout(() => {
   this.setState({      
      contentOffsetY: -20
   });
 }, 16);

And render ListView's contentOffset like so:

contentOffset={{x: 0, y: this.state.contentOffsetY}}

Then, the search bar is correctly hidden upon the view appearing.

Because of that ^, I'm lead to believe there HAS to be a bug here.

@jtremback
Copy link
Contributor

Would it be possible to replicate this on https://rnplay.org?

@marcshilling
Copy link
Author

@jtremback SUPER frustratingly, this seems to work just the way I'd expect (https://rnplay.org/apps/nWGxtw)

However, in my project, of course it does not work that way.

See my updated first post.

@jtremback
Copy link
Contributor

@marcshilling What version of react-native are you running?
@brentvatne What version of react-native is the simulator running?

@marcshilling
Copy link
Author

@jtremback I'm on the master branch...0.6.0

@brentvatne
Copy link
Collaborator

@jtremback - that simulator is on 0.5.0 (see the header bar)

@PhilippKrone
Copy link
Contributor

Is this related to my issue? #1779

@jaygarcia
Copy link
Contributor

Seems like #2151 might be related.

@felixakiragreen
Copy link
Contributor

👍

1 similar comment
@aleclarson
Copy link
Contributor

👍

@christopherdro
Copy link
Contributor

Related #1779 or #2151.

@ide @brentvatne Can be closed. Solution provided in related issues.

@ide ide closed this as completed Sep 14, 2015
@facebook facebook locked as resolved and limited conversation to collaborators Jul 22, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

10 participants