-
-
Save tannerlinsley/b8bf1e54515a11e5758ec36c8e4c5b59 to your computer and use it in GitHub Desktop.
Using react-move with react-router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes } from 'react' | |
import { Transition } from 'react-move' | |
const RouteTransition = React.createClass({ | |
propTypes: { | |
pathname: PropTypes.string.isRequired | |
}, | |
render() { | |
return ( | |
<Transition | |
data={React.Children.toArray(children)} | |
getKey={(d, i) => d.key || i} | |
update={d => ({ | |
opacity: 1, | |
scale: 1 | |
})} | |
enter={d => ({ | |
opacity: 0, | |
scale: 0.95 | |
})} | |
leave={d => ({ | |
opacity: 0, | |
scale: 0.95 | |
})} | |
> | |
{items => ( | |
<div> | |
{items.map(item => | |
<div | |
key={item.key} | |
style={{ | |
position: 'absolute', | |
opacity: item.state.opacity, | |
transform: `scale(${item.state.scale})` | |
}} | |
> | |
{item.data} | |
</div> | |
)} | |
</div> | |
)} | |
</Transition> | |
) | |
} | |
}) | |
module.exports = RouteTransition |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment