-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
119 lines (105 loc) · 3.28 KB
/
main.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
// Loading
let load = document.getElementById('load')
let body = document.querySelector('body')
let mobileMenu = document.getElementById('hamburger')
let navBar = document.querySelector('.nav-bar')
let mobileMenuCancel = document.getElementById('cancel')
const slide1 = document.querySelector('.slide-1')
const slide2 = document.querySelector('.slide-2')
const slide3 = document.querySelector('.slide-3')
const arrowLeft = document.querySelector('.arr-l')
const arrowRight = document.querySelector('.arr-2')
// mobileMenu.style.display = 'none';
body.style.display = 'none';
window.scrollTo(0, 0)
load.style.visibility = 'visible';
setTimeout(() => {
load.style.display = 'none';
body.style.visibility = 'visible';
}, 3000);
body.style.display = 'block';
mobileMenu.addEventListener('click', () => {
navBar.style.visibility = 'visible';
navBar.style.animation = 'enter 5s';
})
mobileMenuCancel.addEventListener('click', () => {
navBar.style.visibility = 'hidden';
})
// slide1.style.display = 'none';
// slide2.style.display = 'none';
// slide3.style.display = 'none';
// let currentClick = 0
// scrollArr.forEach(currentClick+= scrollArr[currentClick])
// let initialClick = 0
let slides = [slide1, slide2, slide3]
console.log(arrowLeft)
console.log(arrowRight)
// arrowLeft.addEventListener('click', () => {
// // scroll(currentClick)
// slide1.style.display = 'none';
// slide2.style.display = 'grid';
// })
// function clickAdder(initialClick){
// initialClick + 1
// }
// function showNextSlide(n, i){
// n.forEach((i) => {
// i++
// n = n[i]
// })
// }
// console.log(showNextSlide(slides, 0))
arrowLeft.addEventListener('click', () => {
// let currentClick = showNextSlide(slides, 0)
let i = 0
i--
slides = slides[i]
if (slides == slides[0]){
slide2.style.display = 'none';
slide3.style.display = 'none';
slide1.style.display = 'grid';
}
else if (slides == slides[1]){
slide3.style.display = 'none';
slide1.style.display = 'none';
slide2.style.display = 'grid';
}
else{
slide1.style.display = 'none';
slide2.style.display = 'none';
slide3.style.display = 'grid';
}
})
arrowRight.addEventListener('click', (slide) => {
// let currentClick = showNextSlide(slides, 0)
// console.log('Event listener it self is working')
// slides = [slide1, slide2, slide3]
let i = [...Array(3).keys()]
// slide = slides[i]
for ( num of i ){
if (num === 0){
slide2.style.display = 'none';
slide3.style.display = 'none';
slide1.style.display = 'grid';
console.log('slide-1')
}
else if (num === 1){
slide3.style.display = 'none';
slide1.style.display = 'none';
slide2.style.display = 'grid';
console.log('slide-2')
}
// else if (num === 3){
// slide1.style.display = 'none';
// slide2.style.display = 'none';
// slide3.style.display = 'grid';
// console.log('slide-3')
// }
else{
slide1.style.display = 'none';
slide2.style.display = 'none';
slide3.style.display = 'grid';
console.log('slide-3')
}
}
})