-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
120 lines (102 loc) · 3.57 KB
/
main.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
const navMenu = document.getElementById("nav-menu"),
navToggle = document.getElementById("nav-toggle"),
navItem = document.querySelectorAll(".nav__item"),
header = document.getElementById("header");
// open and close menu
navToggle.addEventListener("click", () => {
navMenu.classList.toggle("nav__menu--open");
changeIcon();
});
// close the menu when the user clicks the nav links
navItem.forEach((item) => {
item.addEventListener("click", () => {
if (navMenu.classList.contains("nav__menu--open")) {
navMenu.classList.remove("nav__menu--open");
}
changeIcon();
});
});
// Change nav toggle icon
function changeIcon() {
if (navMenu.classList.contains("nav__menu--open")) {
navToggle.classList.replace("ri-menu-3-line", "ri-close-line");
} else {
navToggle.classList.replace("ri-close-line", "ri-menu-3-line");
}
}
// Downloading Resume
// document.getElementsByClassName("btn btn--primary").addEventListener("click", function() {
// window.location.href = "../../assets/Calvin Mwangi.pdf"
// })
// Testimonial Slide
const testimonialSlide = new Swiper(".testimonial__wrapper", {
loop: true,
spaceBetween: 30,
centeredSlides: true,
effect: "coverflow",
grabCursor: true,
slidesPerView: 1,
coverflowEffect: {
rotate: 50,
stretch: 0,
depth: 100,
modifier: 1,
slideShadows: true,
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
breakpoints: {
520: {
slidesPerView: "auto",
},
},
});
// ScrollReveal animations
const sr = ScrollReveal({
duration: 600,
distance: "100px",
delay: 0,
reset: false,
});
sr.reveal(".hero__content, .about__content");
sr.reveal(".hero__img", { origin: "top" });
sr.reveal(
".posts, .hero__info-wrapper, .about__title, about__description, .skills__content, .github__link__shell, .qualification__name, .qualification__main_description, .resume-link, .qualification__item, .qualication__main, .education__content, .timeline-left-side, .timeline-right-side, .project__header_content, .project__content, .research__header__title, .research__header__description, .research, .footer__content, .contact-header, .contact-socials, .form-field, .contact-submit-button, .footer-logo-shell, .footer-message, .footer-links-item, .footer-copyright, .transition, .transition_end, .react-logo-shell",
{
delay: 0,
interval: 100,
}
);
sr.reveal(".qualification__footer-text, .contact__content", {
origin: "left",
});
sr.reveal(".qualification__footer .btn, .contact__btn", { origin: "right" });
// Wait for the page to load
window.addEventListener("DOMContentLoaded", (event) => {
// Get the element with the "hero__title" class
const titleElement = document.querySelector(".hero_top_title");
// Set the desired text for the typing effect
const text = "Hello, Welcome! I am...";
// Set the initial text content of the element to an empty string
titleElement.textContent = "";
// Start the typing effect
let index = 0;
const typingEffect = setInterval(() => {
titleElement.textContent += text[index];
index++;
// Check if the typing effect is finished
if (index >= text.length) {
clearInterval(typingEffect);
titleElement.classList.add("custom-font");
}
}, 100); // Adjust the typing speed by changing the interval time (in milliseconds)
});
// Add fade-in class to timeline items when the page is loaded
document.addEventListener("DOMContentLoaded", function () {
const timelineItems = document.querySelectorAll(".timeline .timeline-item");
timelineItems.forEach(function (item) {
item.classList.add("fade-in");
});
});