Giter Club home page Giter Club logo

Comments (10)

felipethome avatar felipethome commented on June 3, 2024

Thanks @richardgorman, I will work on this as soon as possible! TransitionHooks (the underlying component of InlineTransitionGroup) should be the one removing components so the transitions can finish.

from react-inline-transition-group.

richardgorman avatar richardgorman commented on June 3, 2024

@felipethome Is there an actual issue with one of the plugins or is it just a matter of implementing it correctly?

from react-inline-transition-group.

felipethome avatar felipethome commented on June 3, 2024

@richardgorman it is perfectly possible to have animations with ReactRouter, but there was a bug in ReactTransitionHooks that would make things not work as expected, but it is now fixed in version 1.0.10.

If you just uninstall your current version of ReactInlineTransitionGroup and then install the last version, 2.1.4, you must also get the last version of ReactTransitionHooks.

You can find the official example from the ReactRouter repo here:
https://github.com/ReactTraining/react-router/tree/master/examples/animations

from react-inline-transition-group.

felipethome avatar felipethome commented on June 3, 2024

The same example adapted to ReactInlineTransitionGroup:

import React from 'react'
import Transition from 'react-inline-transition-group'
import { render } from 'react-dom'
import { browserHistory, Router, Route, IndexRoute, Link } from 'react-router'

import withExampleBasename from '../withExampleBasename'

const styles = {
  Image: {
    position: 'absolute',
    height: '400px',
    width: '400px'
  },

  base: {
    opacity: 0,
    transition: 'all 1000ms'
  },

  appear: {
    opacity: 1
  },

  leave: {
    opacity: 0
  }
}

const App = ({ children, location }) => (
  <div>
    <ul>
      <li><Link to="/page1">Page 1</Link></li>
      <li><Link to="/page2">Page 2</Link></li>
    </ul>

    <Transition
      component="div"
      childrenStyles={{
        base: styles.base,
        appear: styles.appear,
        enter: styles.appear,
        leave: styles.leave
      }}
    >
      {React.cloneElement(children, {
        key: location.pathname
      })}
    </Transition>
  </div>
)

const Index = (props) => (
  <div style={Object.assign({}, styles.Image, props.style)}>
    <h1>Index</h1>
    <p>Animations with React Router are not different than any other animation.</p>
  </div>
)

const Page1 = (props) => (
  <div style={Object.assign({}, styles.Image, props.style)}>
    <h1>Page 1</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  </div>
)

const Page2 = (props) => (
  <div style={Object.assign({}, styles.Image, props.style)}>
    <h1>Page 2</h1>
    <p>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  </div>
)

render((
  <Router history={withExampleBasename(browserHistory, __dirname)}>
    <Route path="/" component={App}>
      <IndexRoute component={Index}/>
      <Route path="page1" component={Page1} />
      <Route path="page2" component={Page2} />
    </Route>
  </Router>
), document.getElementById('example'))

from react-inline-transition-group.

richardgorman avatar richardgorman commented on June 3, 2024

I updated my package and now it's working as expected.
Thanks!

from react-inline-transition-group.

richardgorman avatar richardgorman commented on June 3, 2024

I have the situation where I need each Route to slide left or right depending on whether or not the user is navigating 'forward' or 'backward' inside my application. Right now I cannot figure out how to change the transition styles that are applied to the route after is has been mounted (one Route might need to leave by sliding left OR right depending on the navigation direction). Is this possible to do? @felipethome

from react-inline-transition-group.

felipethome avatar felipethome commented on June 3, 2024

I believe it is. You can try to check if the user is going backward or forward by any means that ReactRouter provides you (I know they pass parameters for the components so you can check the URL). Now that you know if you are going backward or forward you can apply the leaving styles conditionally.

Another thing that maybe is important for you to know is that my policy to update the styles when they change after the component is mounted is to update each of the children already inside the group.

from react-inline-transition-group.

richardgorman avatar richardgorman commented on June 3, 2024

I have tried to do this unsuccessfully. Could you please update your example from above to reflect what you mean?

from react-inline-transition-group.

felipethome avatar felipethome commented on June 3, 2024

Sure, I will try to give you an example soon!
In the meantime can you please open another issue for this? Applying the styles conditionally is a question that maybe other people will have so this way it is easier for them to find the answer in the future.

from react-inline-transition-group.

richardgorman avatar richardgorman commented on June 3, 2024

Sure, no problem.

from react-inline-transition-group.

Related Issues (10)

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.