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

NestedScrollView 嵌套 PullToRefresh, 在滚动高度为0的时候开始下拉刷新不会生效, #27

Open
d03keep opened this issue Mar 2, 2024 · 3 comments

Comments

@d03keep
Copy link

d03keep commented Mar 2, 2024

"react-native": "0.73.4",
"@sdcx/nested-scroll": "^0.14.0",
"@sdcx/pull-to-refresh": "^0.21.0",

        <PullToRefresh
            refreshing={refreshing}
            onRefresh={() => {
                setRefreshing(true)
               setTimeout(() => setRefreshing(false), 2000)
            }}
        >
            <ScrollView>
               .....
            </ScrollView>
        </PullToRefresh>
    </NestedScrollView>
   然后吸顶或吸顶发生改变希望能 emit 一个事件出来。希望作者留一个打赏通道
@listenzz
Copy link
Collaborator

listenzz commented Mar 4, 2024

@d03keep 滚动高度为 0 是指什么?

是否吸顶可以监听 Header 的 onScroll 来实现

@d03keep
Copy link
Author

d03keep commented Mar 4, 2024

在IOS 模拟器中 ScrollView 的 contentOffset.y 为0 的时候再下拉 ScrollView 执行下拉刷新PullToRefresh的默认效果没有执行, 而在 PullToRefresh 的外层套一个 PageView 之后可以下拉刷新。 这个情况在Android 模拟器和真机没有发现

@listenzz
Copy link
Collaborator

listenzz commented Mar 4, 2024

是的,这种情况下,iOS 确实有这个问题。可以再套个 Horizontal ScrollView 或 PagerView 来解决。

<NestedScrollView style={styles.coordinator}>
  <NestedScrollViewHeader stickyHeaderBeginIndex={1}>
    <Image source={require('assets/cover.webp')} style={styles.image} resizeMode="cover" />
    <View style={[styles.text]}>
      <Text>anchor</Text>
    </View>
  </NestedScrollViewHeader>
  <ScrollView
    horizontal
    contentContainerStyle={{ width: '100%' }}
    alwaysBounceHorizontal={false}>
    <PullToRefresh
      style={{ flex: 1 }}
      refreshing={refreshing}
      onRefresh={beginRefresh}
      footer={
        <LottiePullToRefreshFooter manual refreshing={loadingMore} onRefresh={loadMore} />
      }>
      <FlatListPage data={flatlistData} />
    </PullToRefresh>
  </ScrollView>
</NestedScrollView>

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

No branches or pull requests

2 participants