Skip to content

Commit 8fa97f6

Browse files
committed
added scroll animation in timeline
1 parent 2980441 commit 8fa97f6

File tree

4 files changed

+51
-15
lines changed

4 files changed

+51
-15
lines changed

monthly_stats.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
"topTrack": {
33
"name": "One More Dance",
44
"artist": "d4vd",
5-
"plays": 154,
5+
"plays": 137,
66
"image": "https://lastfm.freetls.fastly.net/i/u/174s/1b1d95c32cf8508b25eb44072be69ad7.jpg"
77
},
88
"topArtist": {
99
"name": "d4vd",
10-
"plays": 325,
10+
"plays": 308,
1111
"image": "https://lastfm.freetls.fastly.net/i/u/174s/04abd50f999854510c83b9a8c88f92a5.png"
1212
},
1313
"topAlbum": {
1414
"name": "One More Dance",
1515
"artist": "d4vd",
16-
"plays": 154,
16+
"plays": 137,
1717
"image": "https://lastfm.freetls.fastly.net/i/u/174s/1b1d95c32cf8508b25eb44072be69ad7.jpg"
1818
}
1919
}

script.js

+34
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,40 @@ document.addEventListener('DOMContentLoaded', () => {
7878
document.querySelectorAll('.content-section').forEach((section) => {
7979
observer.observe(section);
8080
});
81+
82+
// Timeline color transition
83+
const timelineItems = document.querySelectorAll('.timeline-item');
84+
const aboutSection = document.querySelector('#about-section');
85+
86+
window.addEventListener('scroll', () => {
87+
if (!aboutSection) return;
88+
89+
const viewportHeight = window.innerHeight;
90+
const scrollPosition = window.scrollY;
91+
92+
timelineItems.forEach((item) => {
93+
const itemRect = item.getBoundingClientRect();
94+
const itemTop = itemRect.top;
95+
const startTrigger = viewportHeight * 1; // Start transition earlier
96+
const endTrigger = viewportHeight * 0.75; // End transition later
97+
98+
if (itemTop <= startTrigger && itemTop >= endTrigger) {
99+
// Calculate progress (0 to 1) based on item's position between start and end points
100+
const progress = (startTrigger - itemTop) / (startTrigger - endTrigger);
101+
102+
// Interpolate from transparent to purple (#8E8DBE)
103+
const opacity = progress;
104+
item.style.setProperty('--timeline-color', `rgba(142, 141, 190, ${opacity})`);
105+
item.style.setProperty('--timeline-opacity', opacity);
106+
} else if (itemTop < endTrigger) {
107+
item.style.setProperty('--timeline-color', '#8E8DBE'); // Fully purple
108+
item.style.setProperty('--timeline-opacity', '1');
109+
} else {
110+
item.style.setProperty('--timeline-color', 'rgba(142, 141, 190, 0)'); // Fully transparent
111+
item.style.setProperty('--timeline-opacity', '0');
112+
}
113+
});
114+
});
81115
});
82116

83117
// Artist image mapping with working image URL for d4vd

styles.css

+13-11
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ body::-webkit-scrollbar {
575575

576576
.tech-stack {
577577
display: grid;
578-
grid-template-columns: repeat(2, 60px);
579-
grid-template-rows: repeat(4, 60px);
578+
grid-template-columns: repeat(2, 50px);
579+
grid-template-rows: repeat(4, 50px);
580580
gap: 1.5rem;
581581
position: absolute;
582582
bottom: 1.5rem;
@@ -585,13 +585,13 @@ body::-webkit-scrollbar {
585585

586586
.tech-stack a {
587587
display: block;
588-
width: 60px;
589-
height: 60px;
588+
width: 50px;
589+
height: 50px;
590590
}
591591

592592
.tech-stack img {
593-
width: 60px;
594-
height: 60px;
593+
width: 50px;
594+
height: 50px;
595595
filter: grayscale(100%);
596596
transition: filter 0.3s ease, transform 0.2s ease;
597597
}
@@ -714,22 +714,24 @@ body::-webkit-scrollbar {
714714
content: '';
715715
position: absolute;
716716
left: 0;
717-
top: 6px; /* Adjust this to align with the title text */
717+
top: 6px;
718718
width: 12px;
719719
height: 12px;
720720
border-radius: 50%;
721-
background: #8E8DBE;
721+
background: var(--timeline-color, rgba(142, 141, 190, 0));
722+
transition: background-color 0.3s ease;
722723
}
723724

724725
.timeline-item::after {
725726
content: '';
726727
position: absolute;
727728
left: 5px;
728-
top: 18px; /* Adjust this (12px + 6px) to match the new dot position */
729+
top: 20px;
729730
width: 2px;
730731
height: calc(100% + 1.5rem);
731-
background: #8E8DBE;
732-
opacity: 0.3;
732+
background: var(--timeline-color, rgba(142, 141, 190, 0));
733+
opacity: var(--timeline-opacity, 0);
734+
transition: background-color 0.3s ease, opacity 0.3s ease;
733735
}
734736

735737
.timeline-item:last-child::after {

weekly_chart.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
{
2828
"day": "Sun",
29-
"count": 30
29+
"count": 33
3030
}
3131
]
3232
}

0 commit comments

Comments
 (0)