Ehab Yassin
Ehab Yassin

Reputation: 171

Flatlist scrollToOffset do not scroll at negative values instead it scroll to the top

I am trying to implement a custom pull to refresh indicator using a Flatlist at some point i need the list to scroll at negative position to show the indicator at the top but scrollToOffset scrolls me to the top instead to y = 0

    handleRelease() {
        if (this.state.readyToRefresh) {
            this.flatList.scrollToOffset({ offset: -130 });
        }
    }


      <FlatList
          ref={(flatList: any) => {
              this.flatList = flatList;
          }}
          data={this.props.data}
          renderItem={renderRowItem}
          onScroll={this.handleScroll}
          onResponderRelease={this.handleRelease}
          scrollEventThrottle={16}
      />

Non-negative values seems working fine

Upvotes: 1

Views: 1551

Answers (1)

Ehab Yassin
Ehab Yassin

Reputation: 171

It turns out you need to set scrollToOverflowEnabled to true to apply this behavior

ScrollView

When true, the scroll view can be programmatically scrolled beyond its content size. The default value is false.

Upvotes: 6

Related Questions