Как мне провести пальцем, чтобы вернуться, когда у меня есть PanResponder? - PullRequest
0 голосов
/ 11 октября 2018

Мой Компонент работает, но он переопределяет react-navigation край, чтобы вернуться назад.

Как я могу захватить «начало» моего обработчика панорамирования, чтобы жест Go-Back не был переопределен?

import React from 'react'
import { PanResponder, Animated, View } from 'react-native'

class SwipeView extends React.Component{
    translateX = new Animated.Value(0);
    panResponder = PanResponder.create({
        onMoveShouldSetPanResponderCapture: (e, gs) => {  
            return gs.dx > 0  //only allow right swipes
        },
        onPanResponderMove: (e, gs) => { 
            if(gs.dx > 0) { //only allow right swipes
                Animated.event([null, {dx: this.translateX}])(e, gs) 
            }
        },
        onPanResponderTerminationRequest: (e, gs) => {
            return false 
        },
        onPanResponderTerminate: (e, {vx, dx} ) => {
            //do nothing
        },
        onPanResponderRelease: (e, {vx, dx}) => {
            Animated.spring(this.translateX, { toValue: 0, bounciness: 8, speed:48, }).start((result) => {
                if(dx > 24){
                    if(this.props.onSwipe) this.props.onSwipe(this.props)                    
                }
            });
        },
    })
    constructor(props){
        super(props)
    }
    render(){
        return(
            <Animated.View
                style={{transform: [{translateX: this.translateX}]}}  {...this.panResponder.panHandlers}
            >
                <View>{React.cloneElement(this.props.children, this.props)}</View>
            </Animated.View>
        )
    }
}
export default SwipeView
...