ScrollView 和 PanGestureHandler 之间的交叉处理程序交互

时间:2021-01-25 08:34:49

标签: android ios react-native react-native-navigation

我有一张底纸包裹在 PanGestureHandlerreact-native-gesture-handler 中。在里面,有一个标题和一个 ScrollView,从上面提到的同一个库中导入。我希望 PanGestureHandler 在 Scrollview 中的内容偏移量小于或等于 0(即在顶部)时接管。我尝试使用 simulatenousHandlers 属性,但它似乎不适用于 iOS。

我的代码供参考:

<PanGestureHandler
        ref={panRef}
        onGestureEvent={onGestureEvent}
        onHandlerStateChange={onHandlerStateChange}
        simultaneousHandlers={scrollRef}
      >
        <Animated.View
          style={{
            position: "absolute",
            bottom: 0,
            width: "100%",
            height: height * 0.7,
            transform: [
              {
                translateY: bottomSheetY.interpolate({
                  inputRange: [0, height],
                  outputRange: [0, height],
                  extrapolate: "clamp",
                }),
              },
            ],
          }}
        >
          <HandleHeader imageSource={"https://picsum.photos/300"} />
          <ScrollView
            bounces={false}
            ref={scrollRef}
            scrollEventThrottle={16}
            simultaneousHandlers={panRef}
          >
            <MoreInfo />
          </ScrollView>
        </Animated.View>
      </PanGestureHandler>

我可以做什么来实现我的目标?

0 个答案:

没有答案