React native realizes the monitoring gesture up and down pull effect

React native realizes the monitoring gesture up and down pull effect

React native implements the monitoring gesture to pull up and down. The detailed core code is as follows:

Code:

import {PanResponder} from 'react-native';


var Dimensions = require('Dimensions');
const deviceHeight = Dimensions.get("window").height;
const deviceWidth = Dimensions.get("window").width;

class TaskfinishedPage extends Component {
  constructor(props) {
    super(props);
    console.disableYellowBox = true;
    this.state = {
      silderMargin: deviceHeight-230,
    };
      this.lastY1 = this.state.silderMargin;
  }
 
  componentWillMount() {

    this._panResponder = PanResponder.create({
      onStartShouldSetPanResponder:(evt, gestureState) => {
          return true;
      },
      onMoveShouldSetPanResponder: (evt, gestureState) => {
          return true;
      },
      onPanResponderGrant: (evt, gestureState) => {
          this._highlight();
      },
      onPanResponderMove: (evt, gestureState) => {
          console.log(`gestureState.dx : ${gestureState.dx} gestureState.dy : ${gestureState.dy}`);
          if (50 < this.lastY1 + gestureState.dy && this.lastY1 + gestureState.dy < deviceHeight - 230) {
             this.setState({
              // marginLeft1: this.lastX1 + gestureState.dx,
              silderMargin: this.lastY1 + gestureState.dy,
          });
          }
         
      },
      onPanResponderRelease: (evt, gestureState) => {
          this._unhighlight();
        
          this.lastY1 = this.state.silderMargin;
      },
      onPanResponderTerminate: (evt, gestureState) => {
      },
  });
  }


//These two methods are triggered when the hand touches and leaves;
  _unhighlight(){
    this.setState({
        sliderBackgroundcolor: 'transparent',
    });
}

_highlight(){
    this.setState({
        sliderBackgroundcolor: 'transparent',
    });
}


 render() {
    return (
      <Container}>

        <Header>
          <Left>
            <Button transparent onPress={() => {    
                NavigationUtil.resetGoBack(this.props.navigation);
            }}>
              <Icon name='arrow-back' style={{color:'#000'}}/>
            </Button>
          </Left>
          <Body>
          <Text style={{color:'#000'}}>Finshed mission details</Text>
          </Body>
          <Right />
        </Header>
        <View style={{ flex: 1 }}>
          <View style={
                [styles.panelView,
                {
                    backgroundColor: this.state.sliderBackgroundcolor,
                    marginTop: this.state.silderMargin,
                    zIndex:100
                
                }
                ]}
                  {...this._panResponder.panHandlers}
          >
       
            
          </View>
          
 
          </View>
      </Container>
    );
    }


const styles = {
  panelView: {
    width: deviceWidth-20,
    height: 410,
    marginLeft:10,
    marginRight:10,
    borderRadius:6,  
 }
}

export default TaskfinishedPage;

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • VSCode builds React Native environment
  • Solve the problem of react-native soft keyboard popping up and blocking the input box
  • Detailed explanation of react-native WebView return processing (non-callback method can be solved)
  • React-native bridge Android native development detailed explanation
  • A brief discussion on React Native Flexbox layout (summary)
  • React Native react-navigation navigation usage details
  • Specific usage of FlatList in ReactNative
  • ReactNative FlatList usage and pitfalls package summary
  • Making a simple game engine with React Native

<<:  MySQL FAQ series: When to use temporary tables

>>:  How to configure nginx to limit the access frequency of the same IP

Recommend

Steps to use ORM to add data in MySQL

【Foreword】 If you want to use ORM to operate data...

HTML adaptive table method

<body style="scroll:no"> <tabl...

Tutorial on installing Elasticsearch 7.6.2 in Docker

Install Docker You have to install Docker, no fur...

Detailed explanation of MySQL slow log query

Slow log query function The main function of slow...

Detailed explanation of how to use WeChat mini program map

This article example shares the specific implemen...

jQuery implements a simple carousel effect

Hello everyone, today I will share with you the i...

Implementation of mysql configuration SSL certificate login

Table of contents Preface 1. MySQL enables SSL co...

Use of Linux crontab command

1. Command Introduction The contab (cron table) c...

JavaScript imitates Jingdong carousel effect

This article shares the specific code for JavaScr...

Vue implements mobile phone verification code login

This article shares the specific code of Vue to i...

Detailed explanation of Zabbix installation and deployment practices

Preface Zabbix is ​​one of the most mainstream op...

View the dependent libraries of so or executable programs under linux

View the dependent libraries of so or executable ...

The One-Hand Rule of WEB2.0

<br />My previous article about CSS was not ...