Skip to content

Commit 7adcc52

Browse files
committed
menambahkan animasi
1 parent 3e177d0 commit 7adcc52

File tree

2 files changed

+60
-16
lines changed

2 files changed

+60
-16
lines changed

index.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ <h2>Skill Bahasa Pemrograman</h2>
4343
<img src="javascript.png" alt="Java">
4444
<p>JavaScript (menambahkan interaktivitas dan fungsi dinamis ke halaman web).</p>
4545
</div>
46-
<div class="skill-item">
47-
<img src="php.png" alt="PHP">
48-
<p>PHP (Backend Development)</p>
49-
</div>
50-
<div class="skill-item">
51-
<img src="cpp.png" alt="C++">
52-
<p>C++ (Algoritma dan Struktur Data)</p>
53-
</div>
5446
</div>
5547
</section>
5648

script.js

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,63 @@
1-
document.addEventListener("DOMContentLoaded", function() {
2-
let elements = document.querySelectorAll(".slide-up");
3-
let observer = new IntersectionObserver(entries => {
4-
entries.forEach(entry => {
5-
if (entry.isIntersecting) {
6-
entry.target.classList.add("visible");
1+
document.addEventListener("DOMContentLoaded", () => {
2+
// Animasi scroll (fade-in saat di-scroll)
3+
const sections = document.querySelectorAll(".slide-up");
4+
5+
const scrollAnimation = () => {
6+
sections.forEach(section => {
7+
const sectionTop = section.getBoundingClientRect().top;
8+
const triggerPoint = window.innerHeight * 0.8;
9+
10+
if (sectionTop < triggerPoint) {
11+
section.classList.add("visible");
712
}
813
});
9-
}, { threshold: 0.5 });
10-
elements.forEach(el => observer.observe(el));
14+
};
15+
16+
window.addEventListener("scroll", scrollAnimation);
17+
scrollAnimation(); // Jalankan sekali di awal untuk memeriksa posisi awal
18+
19+
// Animasi hover di navigasi
20+
const navLinks = document.querySelectorAll("nav ul li a");
21+
22+
navLinks.forEach(link => {
23+
link.addEventListener("mouseover", () => {
24+
link.style.transform = "scale(1.2)";
25+
link.style.transition = "transform 0.3s ease";
26+
});
27+
28+
link.addEventListener("mouseout", () => {
29+
link.style.transform = "scale(1)";
30+
});
31+
});
32+
33+
// Efek ketik otomatis di header
34+
const typingText = document.querySelector("header p");
35+
const words = ["Mahasiswa Teknik Informatika", "Web Developer", "Tech Enthusiast"];
36+
37+
let wordIndex = 0;
38+
let charIndex = 0;
39+
40+
const typeEffect = () => {
41+
if (charIndex < words[wordIndex].length) {
42+
typingText.textContent += words[wordIndex].charAt(charIndex);
43+
charIndex++;
44+
setTimeout(typeEffect, 100);
45+
} else {
46+
setTimeout(() => eraseEffect(), 1500);
47+
}
48+
};
49+
50+
const eraseEffect = () => {
51+
if (charIndex > 0) {
52+
typingText.textContent = words[wordIndex].substring(0, charIndex - 1);
53+
charIndex--;
54+
setTimeout(eraseEffect, 50);
55+
} else {
56+
wordIndex = (wordIndex + 1) % words.length;
57+
setTimeout(typeEffect, 500);
58+
}
59+
};
60+
61+
typeEffect();
1162
});
63+

0 commit comments

Comments
 (0)