Giter Club home page Giter Club logo

react-native-transitiongroup's Introduction

react-native-transitiongroup

Works similar to ReactTransitionGroup found in react, but reimplemented in seperate library to work better with react-native

reactjs/react-transition-group#6

General usage

important to always give your Transition components a unique key.

import TransitionGroup, { FadeInOutTransition } from 'react-native-transitiongroup';
<TransitionGroup>
  <FadeInOutTransition key="loader">
     {this.state.isLoading ? <Loader /> : null}
  </FadeInOutTransition>
</TransitionGroup>

Custom Transitions

You can easily create your own transitions, by creating your own Transition component. TransitionGroup will look for the following methods to be called on its child components to animate enter and leave

componentWillEnter(callback)
componentWillLeave(callback)

example of scale in/out

class ScaleInOutTransition extends Component {
  constructor() {
    super();

    this.state = {
      progress: new Animated.Value(0),
    };
  }

  componentWillEnter(callback) {
    Animated.timing(this.state.progress, {
      toValue: 1,
      delay: this.props.inDelay,
      easing: this.props.easing,
      duration: this.props.inDuration,
    }).start(callback);
  }

  componentWillLeave(callback) {
    Animated.timing(this.state.progress, {
      toValue: 0,
      delay: this.props.outDelay,
      easing: this.props.easing,
      duration: this.props.outDuration,
    }).start(callback);
  }

  render() {
    const animation = {
      transform: [
        { scale: this.state.progress },
      ]
    };

    return (
      <Animated.View
        style={[this.props.style, animation]}>
        {this.props.children}
      </Animated.View>
    );
  }
}

react-native-transitiongroup's People

Contributors

madsleejensen avatar tiagoengel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.