Advertisement
Guest User

Untitled

a guest
Jul 28th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import PropTypes from 'prop-types';
  3. import { Animated, Easing } from 'react-native';
  4.  
  5. export default class SlideRightView extends Component {
  6.   state = {
  7.     positionX: new Animated.Value(-350)
  8.   };
  9.  
  10.   componentDidMount() {
  11.     setTimeout(() => {
  12.       Animated.timing(this.state.positionX, {
  13.         toValue: 0,
  14.         easing: Easing.bounce,
  15.         duration: 600
  16.       }).start();
  17.     }, 200);
  18.   }
  19.  
  20.   render() {
  21.     let { positionX } = this.state;
  22.  
  23.     return (
  24.       <Animated.View
  25.         style={{
  26.           ...this.props.style,
  27.           right: positionX
  28.         }}>
  29.         {this.props.children}
  30.       </Animated.View>
  31.     );
  32.   }
  33. }
  34.  
  35. SlideRightView.propTypes = {
  36.   children: PropTypes.any,
  37.   style: PropTypes.object
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement