forked from Melon-tree/ProjectFlowchart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scroll-animations.js
65 lines (58 loc) · 3.82 KB
/
scroll-animations.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
document.addEventListener("DOMContentLoaded", function () {
const commentsContainer = document.querySelector(".comments-container");
const comments = [
//need more data!!!
{ text: "UTD has been a transformative experience for me. The courses were challenging but rewarding.", name: "Alumni A", img: "assets/utd_png.png" },
{ text: "The faculty at UTD are exceptional. They are always willing to help and provide valuable insights.", name: "Alumni B", img: "assets/utd_png.png" },
{ text: "I made lifelong friends and connections at UTD. It was an amazing journey.", name: "Alumni C", img: "assets/utd_png.png" },
{ text: "The campus facilities are top-notch and provide everything a student could need.", name: "Alumni D", img: "assets/utd_png.png" },
{ text: "UTD's focus on research and innovation helped me in my career.", name: "Alumni E", img: "assets/utd_png.png" },
{ text: "The diverse student body made my experience at UTD enriching.", name: "Alumni F", img: "assets/utd_png.png" },
{ text: "UTD's career services were invaluable in helping me secure my first job.", name: "Alumni G", img: "assets/utd_png.png" },
{ text: "The projects and hands-on learning experiences at UTD are unparalleled.", name: "Alumni H", img: "assets/utd_png.png" },
{ text: "UTD's focus on technology and innovation is impressive.", name: "Alumni I", img: "assets/utd_png.png" },
{ text: "The support from faculty and staff at UTD was amazing.", name: "Alumni J", img: "assets/utd_png.png" },
{ text: "UTD offers a great balance between academics and extracurricular activities.", name: "Alumni K", img: "assets/utd_png.png" },
{ text: "I appreciated the opportunities for networking and professional growth at UTD.", name: "Alumni L", img: "assets/utd_png.png" },
{ text: "The collaborative environment at UTD helped me grow both personally and professionally.", name: "Alumni M", img: "assets/utd_png.png" },
{ text: "UTD's state-of-the-art labs and facilities are incredible.", name: "Alumni N", img: "assets/utd_png.png" },
{ text: "The community at UTD is very supportive and encouraging.", name: "Alumni O", img: "assets/utd_png.png" }
];
comments.forEach((comment, index) => {
const commentDiv = document.createElement("div");
commentDiv.classList.add("comment");
commentDiv.innerHTML = `
<img src="${comment.img}" alt="${comment.name}" class="profile-pic">
<div class="comment-text">
<p>"${comment.text}"</p>
<p>- ${comment.name}</p>
</div>
`;
commentsContainer.appendChild(commentDiv);
});
let currentComment = 0;
function showNextComment() {
const commentElements = document.querySelectorAll(".comment");
if (currentComment < commentElements.length) {
commentElements.forEach(comment => comment.classList.remove("comment-visible"));
commentElements[currentComment].classList.add("comment-visible");
currentComment++;
} else {
currentComment = 0;
commentElements.forEach(comment => comment.classList.remove("comment-visible"));
commentElements[currentComment].classList.add("comment-visible");
currentComment++;
}
}
setInterval(showNextComment, 5000); // Change comment every 5 seconds
// Ensure comments are centered and responsive on resize
window.addEventListener('resize', () => {
const commentElements = document.querySelectorAll(".comment");
commentElements.forEach(comment => {
comment.style.width = "90%";
comment.style.maxWidth = "800px";
});
});
// Initial resize call to set sizes correctly
window.dispatchEvent(new Event('resize'));
});