-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
111 lines (77 loc) · 3.21 KB
/
script.js
File metadata and controls
111 lines (77 loc) · 3.21 KB
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
document.addEventListener("DOMContentLoaded", () => {
// Animasi scroll (fade-in saat di-scroll)
const sections = document.querySelectorAll(".slide-up");
const scrollAnimation = () => {
sections.forEach(section => {
const sectionTop = section.getBoundingClientRect().top;
const triggerPoint = window.innerHeight * 0.8;
if (sectionTop < triggerPoint) {
section.classList.add("visible");
}
});
};
window.addEventListener("scroll", scrollAnimation);
scrollAnimation(); // Jalankan sekali di awal untuk memeriksa posisi awal
// Animasi hover di navigasi
const navLinks = document.querySelectorAll("nav ul li a");
navLinks.forEach(link => {
link.addEventListener("mouseover", () => {
link.style.transform = "scale(1.2)";
link.style.transition = "transform 0.3s ease";
});
link.addEventListener("mouseout", () => {
link.style.transform = "scale(1)";
});
});
// Efek ketik otomatis di header
const typingText = document.querySelector("header p");
const words = ["Mahasiswa Teknik Informatika", "Web Developer", "Tech Enthusiast", "Cyber Security Analyst"];
let wordIndex = 0;
let charIndex = 0;
let isDeleting = false;
// Ubah kecepatan di sini
const typingSpeed = 150; // Kecepatan mengetik (ms)
const erasingSpeed = 50; // Kecepatan menghapus (ms)
const delayBetweenWords = 1500; // Jeda sebelum hapus teks (ms)
const typeEffect = () => {
const currentWord = words[wordIndex];
if (!isDeleting) {
typingText.textContent = currentWord.substring(0, charIndex + 1);
charIndex++;
if (charIndex === currentWord.length) {
isDeleting = true;
setTimeout(typeEffect, delayBetweenWords); // Tunggu sebelum mulai menghapus
return;
}
} else {
typingText.textContent = currentWord.substring(0, charIndex - 1);
charIndex--;
if (charIndex === 0) {
isDeleting = false;
wordIndex = (wordIndex + 1) % words.length; // Pindah ke kata berikutnya
}
}
setTimeout(typeEffect, isDeleting ? erasingSpeed : typingSpeed);
};
typeEffect();
const eraseEffect = () => {
if (charIndex > 0) {
typingText.textContent = words[wordIndex].substring(0, charIndex - 1);
charIndex--;
setTimeout(eraseEffect, 50);
} else {
wordIndex = (wordIndex + 1) % words.length;
setTimeout(typeEffect, 500);
}
};
typeEffect();
});
document.addEventListener("DOMContentLoaded", function () {
const track = document.querySelector(".carousel-track");
const items = Array.from(track.children);
// Gandakan isi slider agar tidak ada celah kosong
items.forEach(item => {
const clone = item.cloneNode(true);
track.appendChild(clone);
});
});