Skip to content

Instantly share code, notes, and snippets.

@davekiss
Forked from tannerlinsley/RouteTransition.jsx
Created May 18, 2017 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davekiss/bf93c965caf9b75f57181a1b6ca85466 to your computer and use it in GitHub Desktop.
Save davekiss/bf93c965caf9b75f57181a1b6ca85466 to your computer and use it in GitHub Desktop.
Using react-move with react-router
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