Giter Site home page Giter Site logo

iq-scm / react-transition-group-plus Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cheapsteak/react-transition-group-plus

0.0 0.0 0.0 489 KB

A more full-featured transition group for React

License: Other

JavaScript 89.89% CSS 7.33% HTML 2.78%

react-transition-group-plus's Introduction

React TransitionGroupPlus

npm npm

A drop-in replacement for the original react-addons-transition-group that allows interruptible transitions and specifying transition order.

Note that this is not API-compatible with react-transition-group v2

Installation

npm install --save react-transition-group-plus

Demo

See a comparative demo between ReactTransitionGroup and TransitionGroupPlus

Aside from being able to specify transition order, notice how a component's enter transition is aborted and the leave transition runs as soon as a component should no longer be active.

Why?

ReactTransitionGroup has a few shortcomings

  • Animation order can't be specified.
    Different components' componentWillEnter and componentWillLeave always occur simultaneously.
    It's difficult to wait for the outgoing component's componentWillLeave to finish before running the incoming component's componentWillEnter.

  • The same component's transitions can't be interrupted.
    Once a component's componentWillEnter is called, calls to the same component's componentWillLeave will be delayed until the enter animation finishes
    This problem becomes apparent for page transitions and carousels, when something that's entering might need to immediately exit.

TransitionGroupPlus builds upon ReactTransitionGroup's existing code to solve these problems.

Usage

Usage of TransitionGroupPlus is nearly identical to ReactTransitionGroup. (See the guide on react's website on how to use ReactTransitionGroup)

Additional props:

  • transitionMode (optional) can have the following values:
    • simultaneous (default)
      componentWillEnter and componentWillLeave will be run at the same time.
      The transitionMode prop can be omitted if simultaneous transitions are desired as this is the default value.
    • out-in
      Wait for the outgoing component's componentWillLeave to finish before calling the incoming component's componentWillEnter.
      Note:
      If an incoming component needs to leave while it's still waiting for its componentWillEnter to be called, its componentWillEnter will be skipped and only its componentWillLeave will be called.
    • in-out
      Wait for the incoming component's componentWillEnter to finish before calling the outgoing component's componentWillLeave.
  • deferLeavingComponentRemoval (optional, boolean, defaults to false)
    When true, children that leave will not be removed immediately after their componentWillLeave is called, but will wait for the next component's componentWillEnter to finish.
    Only affects the transition modes "simultaneous" and "out-in". Has no effect on "in-out".
sample:
<TransitionGroupPlus transitionMode="in-out">
  ...
</TransitionGroupPlus>

Browser Support

This component relies on Promises, which exists natively in most browsers, but a polyfill would be required for IE11 and below.

Other than that, this should run on all browsers where React runs.

License

Since this code was forked from React's ReactTransitionGroup, significant lines of codes still fall under React's original BSD license.

New code is licensed under MIT

Inspired by Vue's transitions

react-transition-group-plus's People

Contributors

cheapsteak avatar fortinmike avatar jebeck avatar jephuff avatar jmckinnell avatar njam3 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.