feat: transitions animations without direction
This commit is contained in:
parent
0cd14ba398
commit
68050fd4ba
1 changed files with 18 additions and 1 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
import Fade from '@material-ui/core/Fade'
|
||||||
|
import Slide from '@material-ui/core/Slide'
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import React, { useContext } from 'react'
|
import React, { useContext } from 'react'
|
||||||
import {
|
import {
|
||||||
|
|
@ -244,6 +246,8 @@ const getParent = route =>
|
||||||
const Routes = () => {
|
const Routes = () => {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
const action = history.action
|
||||||
|
|
||||||
const { wizardTested } = useContext(AppContext)
|
const { wizardTested } = useContext(AppContext)
|
||||||
|
|
||||||
const dontTriggerPages = ['/404', '/register', '/wizard']
|
const dontTriggerPages = ['/404', '/register', '/wizard']
|
||||||
|
|
@ -252,6 +256,11 @@ const Routes = () => {
|
||||||
history.push('/wizard')
|
history.push('/wizard')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Transition =
|
||||||
|
action === 'PUSH' && location.pathname !== '/transactions' ? Slide : Fade
|
||||||
|
|
||||||
|
// const props = Transition === Slide ? { direction: 'right' } : {}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/">
|
<Route exact path="/">
|
||||||
|
|
@ -261,7 +270,15 @@ const Routes = () => {
|
||||||
<Route path="/register" component={AuthRegister} />
|
<Route path="/register" component={AuthRegister} />
|
||||||
{flattened.map(({ route, component: Page, key }) => (
|
{flattened.map(({ route, component: Page, key }) => (
|
||||||
<Route path={route} key={key}>
|
<Route path={route} key={key}>
|
||||||
<Page name={key} />
|
<Transition
|
||||||
|
direction="left"
|
||||||
|
in={location.pathname === route}
|
||||||
|
mountOnEnter
|
||||||
|
unmountOnExit>
|
||||||
|
<div>
|
||||||
|
<Page name={key} action={action} />
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
</Route>
|
</Route>
|
||||||
))}
|
))}
|
||||||
<Route path="/404" />
|
<Route path="/404" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue