react-native-gesture-handler#FlingGestureHandler JavaScript Examples

The following examples show how to use react-native-gesture-handler#FlingGestureHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CardView1.js    From rn-animation with MIT License 5 votes vote down vote up
render() {
    const backgroundColor = this.animated.interpolate({
      inputRange: DummyDataDateALive.map((_, index) => index),
      outputRange: DummyDataDateALive.map((item) => item.color),
    });

    return (
      <FlingGestureHandler
        key={'UP'}
        direction={Directions.UP}
        onHandlerStateChange={(ev) => {
          if (
            ev.nativeEvent.state === State.END &&
            this.state.activeIndex !== DummyDataDateALive.length - 1
          ) {
            this._setCardActive(this.state.activeIndex + 1);
          }
        }}>
        <FlingGestureHandler
          key={'DOWN'}
          direction={Directions.DOWN}
          onHandlerStateChange={(ev) => {
            if (
              ev.nativeEvent.state === State.END &&
              this.state.activeIndex !== 0
            ) {
              this._setCardActive(this.state.activeIndex - 1);
            }
          }}>
          <View style={styles.container}>
            <Animated.View style={[{flex: 1, backgroundColor}]}>
              <FlatList
                keyExtractor={(item, index) => item + index}
                scrollEnabled={false}
                CellRendererComponent={this._renderCenter}
                data={DummyDataDateALive}
                renderItem={this._renderItem}
                contentContainerStyle={{
                  flex: 1,
                  justifyContent: 'center',
                  alignItems: 'center',
                }}
              />
            </Animated.View>
          </View>
        </FlingGestureHandler>
      </FlingGestureHandler>
    );
  }