-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscripta.js
81 lines (64 loc) · 2.22 KB
/
scripta.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
document.addEventListener("DOMContentLoaded", function () {
const typingElement = document.querySelector(".typing-animation");
const text = typingElement.textContent;
typingElement.textContent = "";
let index = 0;
function type() {
if (index < text.length) {
typingElement.textContent += text.charAt(index);
index++;
setTimeout(type, 100);
}
}
type();
});
document.addEventListener("DOMContentLoaded", () => {
const images = document.querySelectorAll(".slider-container img");
setInterval(() => {
images.forEach((img) => {
const randomRotation = Math.floor(Math.random() * 360);
const randomScale = Math.random() * 0.5 + 0.75;
img.style.transform = `rotate(${randomRotation}deg) scale(${randomScale})`;
});
}, 3000);
});
document.querySelectorAll(".nav-links a").forEach((link) => {
link.addEventListener("click", function (event) {
const targetHref = this.getAttribute("href");
if (targetHref.startsWith("#")) {
event.preventDefault();
const targetSection = document.querySelector(targetHref);
if (targetSection) {
targetSection.scrollIntoView({
behavior: "smooth",
});
}
}
});
});
document.addEventListener("DOMContentLoaded", () => {
const sections = document.querySelectorAll(".section");
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("visible");
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.1,
});
sections.forEach((section) => {
observer.observe(section);
});
});
window.addEventListener('scroll', function() {
const sections = document.querySelectorAll('.section');
sections.forEach(function(section) {
const sectionTop = section.getBoundingClientRect().top;
const windowHeight = window.innerHeight;
if (sectionTop < windowHeight - 150) {
section.classList.add('visible');
}
});
});