-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
69 lines (52 loc) · 1.84 KB
/
index.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
const header = document.querySelector('.header')
const firstItem = document.getElementById('first-item')
const secondItem = document.getElementById('second-item')
const thirdItem = document.getElementById('third-item')
const firstList = document.getElementById('first-list')
const secondList = document.getElementById('second-list')
const thirdList = document.querySelector('.underline')
const search = document.querySelector('.search-container')
window.addEventListener('scroll', function() {
if (window.scrollY > 0){
header.classList.add('color')
search.classList.add('active')
} else {
header.classList.remove('color')
search.classList.remove('active')
}
})
firstItem.addEventListener('mouseover', () => {
firstList.classList.add('active')
})
firstItem.addEventListener('mouseleave', () => {
firstList.classList.remove('active')
})
secondItem.addEventListener('mouseover', () => {
secondList.classList.add('active')
})
secondItem.addEventListener('mouseleave', () => {
secondList.classList.remove('active')
})
thirdItem.addEventListener('mouseover', () => {
thirdList.classList.add('active')
})
thirdItem.addEventListener('mouseleave', () => {
thirdList.classList.remove('active')
})
//carrosel
const carrossel = document.querySelector(".carrossel");
const leftArrow = document.querySelector(".left-arrow")
const rightArrow = document.querySelector(".right-arrow")
leftArrow.addEventListener("click", () => {
console.log("esquerda");
carrossel.scrollLeft -= carrossel.offsetWidth;
})
rightArrow.addEventListener("click", () => {
console.log("direita");
carrossel.scrollLeft += carrossel.offsetWidth;
})
//scroll para o top
const scrollButton = document.getElementById('topButton');
scrollButton.addEventListener("click", () => {
document.documentElement.scrollTop = 0;
})