jiasongs / react-native-stickyheader

列表上悬浮的cell
MIT License
155 stars 22 forks source link

希望大佬解决flatlist手势冲突的问题 #4

Open Zhao-qiangqiang opened 4 years ago

Zhao-qiangqiang commented 4 years ago

上拉加载没办法监听到啊?并且onscroll里面也没办法实时拿到滑动的距离

yoyo0427 commented 4 years ago

@Zhao-qiangqiang 请问你这个问题解决了吗?

Brances commented 4 years ago

@Zhao-qiangqiang @yoyo0427 我也遇到了上拉加载无法拿到滑动距离的问题,请问有解决办法了吗?

Brances commented 4 years ago

@Zhao-qiangqiang @yoyo0427 刚仔细看了API,试试这个 ,亲测有效 onScroll={Animated.event( [{ nativeEvent: { contentOffset: { y: this.state.scrollY } } }], { useNativeDriver: true, listener: (event) => console.log(event.nativeEvent.contentOffset.y) } )}

Brances commented 4 years ago

@zengfuzhou 监听的对象都拿到了,滚动的距离自然也拿到了,上拉加载应该是没问题的

Zhao-qiangqiang commented 4 years ago

@ Zhao- qiangqiang @ yoyo0427 刚仔细看了API,试试这个,亲测有效 onScroll={Animated.event( [{ nativeEvent: { contentOffset: { y: this.state.scrollY } } }], { useNativeDriver: true, listener: (event) => console.log(event.nativeEvent.contentOffset.y) } )}

这个方法是可以 但是会非常卡顿

jiasongs commented 4 years ago

两个scrollView嵌套在原生中有解决方案,我试着拿到RN里,但是效果不理想,因为RN里scrollView的onScroll回调和setContentOffset是异步的,不过也不是没有办法,https://github.com/software-mansion/react-native-gesture-handler 里有手势冲突处理的demo,可以试着看一下。

yibingxiong commented 4 years ago

楼上以及未来楼下的大佬们,吸顶效果有其他方案吗

Wxh16144 commented 4 years ago

楼上以及未来楼下的大佬们,吸顶效果有其他方案吗

朋友,你找到解决方案了吗,我也在寻找

452MJ commented 3 years ago
function Experts() {
  const [list, setList] = useState([])
  const [sectionList, setSectionList] = useState([])

  useEffect(() => {
    setList(new Array(20).fill(0))
  }, [])
  useEffect(() => {
    setSectionList([
      {
        title: 'Sticky Tab',
        data: list,
      },
    ])
  }, [list])

  return (
      <SectionList
        stickySectionHeadersEnabled
        sections={sectionList}
        keyExtractor={(item, index) => item + index}
        renderItem={({ item }) => <ItemCompoment/>}
        renderSectionHeader={({ section: { title } }) => <StickyCompoment />}
      />
  )
}

我们可以用SectionList的SectionHeader吸顶来实现。把FlatLIst的data放到SectionList的sections[0].data里面