-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
executable file
·130 lines (116 loc) · 3.25 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import React, { Component } from 'react';
import './App.scss';
import { Switch, Route } from 'react-router-dom'
import Header from './components/common/header/Header'
import Footer from './components/common/footer/Footer'
import BottomButon from './components/common/bottomButton/BottomButton'
import HomePage from './components/homepage/HomePage'
import HeaderMobile from './components/common/header/HeaderMobile'
import Info from './components/info/Info'
import Services from './components/services/list/Services'
import Contact from './components/contact/Contact'
import Service from './components/services/detail/Service'
import NotFound from './components/common/not_found/NotFound'
import Loader from 'react-loader-spinner'
class App extends Component {
constructor(props) {
super(props)
this.state = {
sidebarActive: false,
isLoaded: false
}
}
fixedButon = () =>{
let component = document.getElementById("fixedButon")
let scroll = window.scrollY
if(scroll>=10){
component.className="seeFixedButon"
component.style.display="block"
}else{
component.className="notSeeFixedButton"
setTimeout(()=>{
component.style.display="none"
}, 300)
}
}
componentDidMount =() =>{
window.addEventListener("scroll", this.fixedButon)
setTimeout(()=>
this.setState({isLoaded: true})
, 3000)
}
componentWillUnmount = ()=>{
window.removeEventListener("scroll", this.fixedButon)
}
openSidebar = () => {
console.log("llego")
this.setState({sidebarActive: true})
}
closeSidebar = () => {
this.setState({sidebarActive: false})
}
up = () =>{
//window.scrollTo(0,0)
let top = 0
let scrollStep = 15
let counter = window.scrollY
let positionI= window.scrollY
let scrollInterval = setInterval(()=>{
if(counter>top){
//console.log(counter)
window.scrollBy(0, -scrollStep)
counter-=scrollStep
//console.log(counter)
if(counter===top+(positionI%15)){
scrollStep=positionI%15
if(scrollStep<=0){
scrollStep=1
}
}
}
else{
clearInterval(scrollInterval)
}
}, 1)
}
render() {
return (
<div>
{this.state.isLoaded ?
<div>
<Header />
<div id="anError"></div>
<HeaderMobile
sidebar={this.state.sidebarActive}
openSidebar={this.openSidebar}
closeSidebar={this.closeSidebar}
isLoaded={this.state.isLoaded}
/>
<Switch>
<Route exact path="/" component={HomePage} />
<Route exact path="/nosotros/" component={Info} />
<Route exact path="/tramites/" component={Services} />
<Route exact path="/contacto/" component={Contact} />
<Route exact path="/tramites/:slug/" component={Service} />
<Route component={NotFound} />
</Switch>
<Footer />
<BottomButon
up={this.up}
/>
</div>
:
<div className="loader">
<Loader
type="Watch"
color="#006BC7"
height="200"
width="200"
/>
</div>
}
</div>
);
}
}
export default App;