-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
78 lines (53 loc) · 2.02 KB
/
script.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
const toggleButton = document.querySelector('.toggle-btn');
const menu = document.querySelector('.smaller-screen-navbar');
toggleButton.addEventListener('click' ,() =>{
menu.classList.toggle('show');
})
//Meet biom vertical text scroll
const verticalText = document.getElementById('vertical-meet-biom-text');
const meetBiom = document.querySelector('.meet-biom__container');
const verticalScroll = () => {
let meetBiomTopSection = meetBiom.getBoundingClientRect().top;
if(meetBiomTopSection < 1){
verticalText.classList.add('active');
}
else{
verticalText.classList.remove('active');
} console.log(meetBiomTopSection)
}
window.addEventListener('scroll',verticalScroll);
//Reviews slider
const reviews = document.querySelectorAll('.single-review');
const dots = document.querySelectorAll('.dot');
const current = 0;
function init(n) {
reviews.forEach((review, index) => {
review.style.display = 'none';
dots.forEach((dot, index) => {
dot.classList.remove('active');
});
});
reviews[n].style.display = 'block';
dots[n].classList.add('active');
}
dots.forEach((dot,index) =>{
dot.addEventListener('click', () => {
init(index)
current = i;
})
})
const horizontalSection = document.querySelector('.horizontal-scroll');
const horizontalScroll = document.querySelector('.horizontal-scroll__container');
let distance = 0;
distance = horizontalScroll.scrollWidth;
horizontalSection.style.height = `${distance}px`;
window.addEventListener('scroll', () =>{
let vwTop = horizontalSection.getBoundingClientRect().top;
if(vwTop < 0 && vwTop > -distance + horizontalSection.getBoundingClientRect().width){
horizontalScroll.style.transform = `translateX(${vwTop}px)`;
}
})
window.addEventListener('resize', () => {
distance = horizontalScroll.scrollWidth;
horizontalSection.style.height = `${distance}px`;
});