bolan9999 / react-native-largelist

The best large list component for React Native.
https://bolan9999.github.io/react-native-largelist/
MIT License
2.32k stars 261 forks source link

WaterfallList嵌套react-native-gesture-handler使用 手势识别不了,使用原生ScrollView可以识别 #444

Closed z3season closed 3 years ago

z3season commented 3 years ago

代码如下:

<FlingGestureHandler ref={this.upFlingRef} simultaneousHandlers={this.nativeGestureRef} direction={Directions.UP} onHandlerStateChange={({nativeEvent}: any) => {

      }}
    >
      <FlingGestureHandler
        ref={this.downFlingRef}
        simultaneousHandlers={this.nativeGestureRef}
        direction={Directions.DOWN}
        onHandlerStateChange={({nativeEvent}: any) => {

        }}
      >
          <NativeViewGestureHandler
            shouldActivateOnStart
            disallowInterruption
            ref={this.nativeGestureRef}
            simultaneousHandlers={[this.upFlingRef, this.downFlingRef]}
          >
            <WaterfallList
              ref={ref => this.waterfallListRef = ref}
              style={{width: SCREEN_WIDTH, backgroundColor: listType === 4 ? '#f3f3f3' : '#fff'}}
              showsVerticalScrollIndicator={false}
              data={isEmptyArray(dataArray) ? [1] : dataArray}
              // onScroll={(e: any) => this.onScrollMethod(e)}
              // onContentSizeChange={({width, height}) => {
              //   this.contentSizeHeight = height;
              // }}
              heightForItem={(item: any) => {
                if (isEmptyArray(dataArray)) {
                  return EmptyHeight;
                }
                return item.height;
              }}
              numColumns={(listType === 4 ? 2 : 1)}
              renderItem={this.renderItemBind}
              renderHeader={() => this._subTradeContent(paddingTop)}
              // @ts-ignore
              loadingFooter={WaterfallLoadingFooter}
              allLoaded={!canLoadMore}
              onLoading={() => {
                this.currentPage += 1;
                this.loadGoodsListData(this.currentPage);
              }}
              renderFooter={() => <View style={{height: px2dp(30)}}/>}
            />
          </NativeViewGestureHandler>
      </FlingGestureHandler>
    </FlingGestureHandler>
bolan9999 commented 3 years ago

RN这个事件比你想象的复杂,安卓上这个问题目前来看解决不来。SpringScrollView在安卓上相当于是截获了触摸事件的。RN在原生不处理任何触摸事件,全都放到js层处理的。