forked from Lunar-Simulations/lunar-simulations.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
133 lines (111 loc) · 4.14 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
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
131
132
133
if (
navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/iPhone/i)
) { } else {
// Get the elements
const coverImage = document.querySelector(".cover-image");
const parallaxText = document.getElementById("title");
const paraImage1 = document.querySelector(".image-bg-1");
function parallax() {
// Get the scroll position
let scrollPos = window.pageYOffset;
// console.log(110 + (paraImage1.offsetHeight + (scrollPos - paraImage1.offsetTop) * 0.7) * 0.1)
// Update the translateY value
parallaxText.style.transform = `translateY(${scrollPos * 0.5}px)`;
coverImage.style.backgroundPositionY = `${scrollPos * 0.7}px`;
// paraImage1.style.backgroundSize = `${Math.max(100, 115 * 1300 / window.innerWidth + (paraImage1.offsetHeight + (scrollPos - paraImage1.offsetTop) * 0.7) * 0.05)}%`;
// paraImage1.style.backgroundSize = `calc(cover+${(paraImage1.offsetHeight + (scrollPos - paraImage1.offsetTop) * 0.7) * 0.05}%)`;
requestAnimationFrame(parallax);
// parallax()
// Listen for scroll event
// window.addEventListener("scroll", function () {
// parallax()
// requestAnimationFrame(parallax);
// });
}
requestAnimationFrame(parallax);
}
const gallery = document.getElementById("gallery");
const alt_cover = document.querySelector(".alt-cover")
window.addEventListener("scroll", function () {
if (gallery.offsetTop < window.scrollY) {
alt_cover.style.opacity = 0
} else {
alt_cover.style.opacity = 1
}
});
const featuresGridCards = document.querySelectorAll('#features-grid .card');
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
setTimeout(() => {
entry.target.classList.add('visible');
}, index * 250);
observer.unobserve(entry.target);
} else {
entry.target.classList.remove('visible');
}
});
});
featuresGridCards.forEach(card => {
observer.observe(card);
});
const images = gallery.querySelectorAll("img");
const prev = document.getElementById("prev");
const next = document.getElementById("next");
let current = 0;
images[current].classList.add("active");
let galleryInterval;
let progressBar = document.getElementById("progress-bar");
function restart() {
progressBar.style.animation = "none";
progressBar.offsetWidth;
progressBar.style.animation = "progress-bar 4s linear forwards";
}
function startGalleryInterval() {
galleryInterval = setInterval(() => {
restart()
images[current].classList.remove("active");
current = (current + 1) % images.length;
images[current].classList.add("active");
}, 4000);
}
function stopGalleryInterval() {
restart()
clearInterval(galleryInterval);
}
prev.addEventListener("click", () => {
stopGalleryInterval();
images[current].classList.remove("active");
current = (current - 1 + images.length) % images.length;
images[current].classList.add("active");
startGalleryInterval();
});
next.addEventListener("click", () => {
stopGalleryInterval();
images[current].classList.remove("active");
current = (current + 1) % images.length;
images[current].classList.add("active");
startGalleryInterval();
});
startGalleryInterval();
const ul = document.querySelector(".tech-list");
const observer_tech = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const liElements = entry.target.querySelectorAll("li");
// liElements.forEach((li, index) => {
// setTimeout(() => {
// console.log(index * 100)
// li.classList.add("show");
// }, index * 400);
// });
liElements.forEach((li, index) => {
li.classList.add("show");
li.style.transitionDelay = `${index * 0.07}s`;
});
observer_tech.unobserve(entry.target);
}
});
}, { threshold: 0.3 });
observer_tech.observe(ul);