-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.js
100 lines (88 loc) · 2.82 KB
/
home.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
document.addEventListener("DOMContentLoaded", function () {
const username = localStorage.getItem('username');
if (username) {
document.getElementById('username').textContent = username;
}
});
document.addEventListener("DOMContentLoaded", function() {
const carousel = document.querySelector('.carousel');
const images = carousel.querySelectorAll('img');
const prevBtn = document.querySelector('.prev');
const nextBtn = document.querySelector('.next');
let currentIndex = 0;
function showImage(index) {
images.forEach((image, i) => {
if (i === index) {
image.style.display = 'block';
} else {
image.style.display = 'none';
}
});
}
function nextImage() {
currentIndex++;
if (currentIndex >= images.length) {
currentIndex = 0;
}
showImage(currentIndex);
}
function prevImage() {
currentIndex--;
if (currentIndex < 0) {
currentIndex = images.length - 1;
}
showImage(currentIndex);
}
showImage(currentIndex);
prevBtn.addEventListener('click', prevImage);
nextBtn.addEventListener('click', nextImage);
setInterval(nextImage, 4000);
ScrollReveal().reveal('.hide', {
duration: 1000,
distance: '50px',
origin: 'bottom',
easing: 'ease-in-out'
});
});
function ExpNow() {
var hideElements = document.getElementsByClassName('hide');
for (var i = 0; i < hideElements.length; i++) {
if (hideElements[i].style.display === 'none') {
hideElements[i].style.display = 'block';
hideElements[i].style.visibility = 'visible';
} else {
hideElements[i].style.display = 'none';
hideElements[i].style.visibility = 'hidden';
}
}
window.scrollTo(0,2520)
}
const sections = document.querySelectorAll("[data-section]");
const scrollReveal = function () {
for (let i = 0; i < sections.length; i++) {
if (
sections[i].getBoundingClientRect().top <
window.innerHeight / 1.5
) {
sections[i].classList.add("active");
} else {
sections[i].classList.remove("active");
}
}
};
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("scrollUpBtn").style.display = "block";
} else {
document.getElementById("scrollUpBtn").style.display = "none";
}
}
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: "smooth"
});
}
const scrollUpBtn = document.getElementById("scrollUpBtn");
scrollUpBtn.addEventListener("click", scrollToTop);