RN gesture response system usage and access to the basic coordinate direction determined user gesture

1. The basic use,
pay attention to two points

(1) The function of gesture system on "componentWillMount" life-cycle function inside, there was a warning, a warning for yourself

(2) a method using extended operator deployed ES6

React from Import 'REACT' ; 
 Import {View, from the Text} 'Native-REACT' ; 

 Export default class the extends React.Component {My 
     constructor (The props) { 
         Super (The props); 
        
     } 
     UNSAFE_componentWillMount () { 
         the this .gestureHandlers = { 

            onMoveShouldSetResponder : (EVT) => { 
                the console.log ( 'onMoveShouldSetResponder' );
                 return  to true ; 
            }, 
            // now start in response to the touch event. It also needs to be done to highlight the time, so the user knows where to point him in the end. 
            onResponderGrant: (event) => {
                console.log ( 'onResponderGrant' ); 
                console.log (Event); 
                console.log (event.nativeEvent); 
            }, 
            
            // specific response to events: (1) the user is moving your finger on the screen, "pay attention to" the number of times the trigger too frequent 
            onResponderMove: (EVT) => { 
                the console.log ( 'the user is moving the finger, and did not leave' ); 
            }, 
            onResponderRelease: (Event) => { 
                the console.log ( 'after movement of the finger, releasing' ); 
                Console. log (Event); 
                the console.log (event.nativeEvent); 
            } 
        } 
     } 
     the render () { 
         return (
            <View 
                style={{flex:1,backgroundColor:"yellow"}}
                {...this.gestureHandlers}
            >
            </View>
         )
     }
 }

*** Of course, I omitted some gesture function, which you can see the effect in the console

Guess you like

Origin www.cnblogs.com/tengyuxin/p/12067058.html