Is there a simple way to do page transitions animations with Flow Router and React? I’ve been struggling with it for a couple of days.
My page has an admin style interface (side nav and top nav) so I’m not wanting to animate the change on the whole page, but instead apply the animation to the inner content.
If someone had an example that would be really helpful.
The only bit I’ve had issues with is if your site CSS includes absolute positions it can stop transition appearing as a crossfade, with instead the first component fading out and the second one fading in. I haven’t worked out how to solve that, I’m not great with CSS.
If anyone is using the class syntax for Layout, I figured out a simpler implementation - simply add the unique key to each mounting component when you are rendering it in the callback:
import React from 'react';
import {FlowRouter} from 'meteor/kadira:flow-router';
import {mount} from 'react-mounter';
import Layout from '../../ui/layouts/Layout.jsx';
import Home from '../../ui/pages/home/Home.jsx';
import About from '../../ui/pages/about/About.jsx';
FlowRouter.route('/', {
name: 'home',
action() {
mount(Layout, {
content: () => {
return (<Home key="home" />);
}
});
}
});
FlowRouter.route('/about', {
name: 'about',
action() {
mount(Layout, {
content: () => {
return (<About key="about" />);
}
});
}
});
And then in Layout you wrap <ReactCSSTransitionGroup> around your content call: