Skip to content

Commit

Permalink
React animation
Browse files Browse the repository at this point in the history
  • Loading branch information
SohelRaja committed Apr 25, 2020
1 parent a1ba2fd commit c8c07ad
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
25 changes: 13 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"react-redux-form": "^1.16.8",
"react-router-dom": "^4.2.2",
"react-scripts": "3.4.1",
"react-transition-group": "^2.3.0",
"reactstrap": "^5.0.0",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
Expand Down
23 changes: 23 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,27 @@ address{
.media-image{
height: 120px;
width: 120px;
}

/* Animation */
.page-enter {
opacity: 0.01;
transform: translateX(-100%);
}

.page-enter-active {
opacity: 1;
transform: translateX(0%);
transition: all 300ms ease-in;
}

.page-exit {
opacity: 1;
transform: translateX(0%);
}

.page-exit-active {
opacity: 0.01;
transform: translateX(100%);
transition: all 300ms ease-out;
}
21 changes: 13 additions & 8 deletions src/components/MainComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import {Switch, Route, Redirect, withRouter} from 'react-router-dom';
import { connect } from 'react-redux';
import { actions } from 'react-redux-form';
import {TransitionGroup, CSSTransition} from 'react-transition-group';

import Menu from './MenuComponent';
import './../App.css';
Expand Down Expand Up @@ -77,14 +78,18 @@ class Main extends Component{
<div>
<Header />
<div>
<Switch>
<Route path='/home' component={HomePage} />
<Route exact path='/aboutus' component={() => <About leaders={this.props.leaders} />} />} />
<Route exact path='/menu' component={() => <Menu dishes={this.props.dishes} />} />
<Route path='/menu/:dishId' component={DishWithId} />
<Route exact path='/contactus' component={() => <Contact resetFeedbackForm={this.props.resetFeedbackForm} />} />} />
<Redirect to="/home" />
</Switch>
<TransitionGroup>
<CSSTransition key={this.props.location.key} classNames="page" timeout={300}>
<Switch>
<Route path='/home' component={HomePage} />
<Route exact path='/aboutus' component={() => <About leaders={this.props.leaders} />} />} />
<Route exact path='/menu' component={() => <Menu dishes={this.props.dishes} />} />
<Route path='/menu/:dishId' component={DishWithId} />
<Route exact path='/contactus' component={() => <Contact resetFeedbackForm={this.props.resetFeedbackForm} />} />} />
<Redirect to="/home" />
</Switch>
</CSSTransition>
</TransitionGroup>
</div>
<Footer />
</div>
Expand Down

0 comments on commit c8c07ad

Please sign in to comment.