Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. import React, { useEffect } from 'react';
  2. import './css/bootstrap.min.css'
  3. import './css/style.min.css'
  4. import { Route, Switch } from "react-router-dom";
  5.  
  6. import history from "./components/history/history";
  7.  
  8. import Header from './components/Header/Header';
  9. import Main from './components/page/Main/Main';
  10. import Services from './components/page/Services/Services';
  11. import Microfinance from './components/page/Microfinance/Microfinance';
  12. import Agents from './components/page/Agents/Agents';
  13. import Bonuses from './components/page/Bonuses/Bonuses';
  14. import Advantages from './components/page/Advantages/Advantages';
  15. import Devices from './components/page/Devices/Devices';
  16. import Contact from './components/page/Contact/Contact';
  17. import Become from './components/page/Become/Become';
  18. import Choise from './components/page/Choise/Choise';
  19. import {
  20. CSSTransition,
  21. TransitionGroup,
  22. } from 'react-transition-group';
  23.  
  24. const routes = ["/", "/services", "/microfinance", "/agents", "/bonuses", "/advantages"];
  25. var i = 0;
  26.  
  27. const handleScroll = (e, count, setCount) => {
  28. if (e.wheelDelta / 120 > 0) {
  29. if (i>0) {
  30. i=i-1;
  31. }
  32. history.push(routes[i]);
  33. }
  34. else {
  35. if (i<6) {
  36. i=i+1;
  37. }
  38. history.push(routes[i]);
  39. }
  40. };
  41.  
  42. function App() {
  43.  
  44. useEffect(e => {
  45. window.addEventListener("mousewheel", e => handleScroll(e));
  46.  
  47. return () => {
  48. window.removeEventListener("mousewheel", handleScroll(e));
  49. };
  50. }, []);
  51. return (
  52. <div className="App">
  53. <Header />
  54. <Route history={history} render={({location}) => (
  55. <TransitionGroup>
  56. <CSSTransition
  57. key={location.key}
  58. timeout={300}
  59. classNames="fade"
  60. >
  61. <Switch location={location}>
  62. <Route exact path="/" component={Main} />
  63. <Route path="/services" render={() => <Services />} />
  64. <Route path="/microfinance" component={Microfinance} />
  65. <Route path="/agents" component={Agents} />
  66. <Route path="/bonuses" component={Bonuses} />
  67. <Route path="/advantages" component={Advantages} />
  68. <Route path="/devices" component={Devices} />
  69. <Route path="/contact" component={Contact} />
  70. <Route path="/become" component={Become} />
  71. <Route path="/choise" component={Choise} />
  72. </Switch>
  73. </CSSTransition>
  74. </TransitionGroup>
  75. )} />
  76. </div>
  77. );
  78. }
  79.  
  80. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement