-
-
Save davekiss/bf93c965caf9b75f57181a1b6ca85466 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