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

Flatlist scrolls up a bit when item on top updates #26760

Closed
n00bm5st3r69 opened this issue Oct 8, 2019 · 1 comment
Closed

Flatlist scrolls up a bit when item on top updates #26760

n00bm5st3r69 opened this issue Oct 8, 2019 · 1 comment
Labels
Bug Component: FlatList Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@n00bm5st3r69
Copy link

n00bm5st3r69 commented Oct 8, 2019

When I scroll down to the last item in the Flatlist and an item on top updates, Flatlist scrolls up a bit. By the way, my Flatlist renders images and videos. When the videos are not visible in the viewport it turns into an image.

Sample code below (not the exact code but similar)

       Home.js


         onViewableItemsChanged = ({ viewableItems }) => {
          for(i = 0; i < viewableItems.length; i++) {
            if(this.state.videos.findIndex(x => x.id === viewableItems[i].item.id) > -1) {
                  this.timer = setTimeout(()=>  {
                    this.setState({isVideoVisible: true})
                  }, 2000);
            }
            else {
                  this.setState({isVideoVisible: false});
                  clearTimeout(this.timer);
            }
          }
        }

        <FlatList
          data={this.state.data}
          ListEmptyComponent={() => {
            return (
              <Ghost />
            )
          }}
          renderItem={({ item }) => {
            if (item.type == "Image") {
              return (<CustomImageComponent data={item}/>)
            } else {
              return (<MediaPlayer data={item} isVideoVisible={this.state.isVideoVisible}/>)
            } 
          }
          }
          onViewableItemsChanged={this.onViewableItemsChanged}
          viewabilityConfig={this.viewabilityConfig}
          keyExtractor={(item, index) => index.toString()}
        />


        MediaPlayer.js

        <Container>
          this.props.isVideoVisible ? <Video /> : <Image />
        </Container>
@react-native-bot
Copy link
Collaborator

Thanks for submitting your issue. Can you take another look at your description and make sure the issue template has been filled in its entirety?

👉 Click here if you want to take another look at the Bug Report issue template.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: Needs More Information labels Oct 8, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Oct 3, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: FlatList Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

2 participants