Create script.js
Browse files
script.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 2 |
+
const items = document.querySelectorAll('.timeline-item');
|
| 3 |
+
|
| 4 |
+
const revealItems = () => {
|
| 5 |
+
const triggerBottom = window.innerHeight * 0.85;
|
| 6 |
+
|
| 7 |
+
items.forEach(item => {
|
| 8 |
+
const itemTop = item.getBoundingClientRect().top;
|
| 9 |
+
|
| 10 |
+
if (itemTop < triggerBottom) {
|
| 11 |
+
item.classList.add('active');
|
| 12 |
+
} else {
|
| 13 |
+
item.classList.remove('active');
|
| 14 |
+
}
|
| 15 |
+
});
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
window.addEventListener('scroll', revealItems);
|
| 19 |
+
revealItems(); // Initial check
|
| 20 |
+
});
|