Skip to content

Commit

Permalink
Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
alanrme committed Jul 1, 2024
1 parent 4045807 commit 76ba8ee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ span.hu {
top: 2rem;
transform: scale(10);
opacity: 0.2;

&.active {
transition: 0.15s linear transform;
}
}
}
}
Expand Down
18 changes: 14 additions & 4 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,29 @@ ready(() => {
if (header) {
// if the element is at the top of the screen
if (rect.top < 0) {
header.classList.add("sticky")
if (!header.classList.contains("sticky")) {
header.classList.add("sticky")
}
header.style.transform = `scale(10) translateX(${(rect.top) / (rect.bottom - rect.top)*70}%)`
} else {
header.classList.remove("sticky")
if (header.classList.contains("sticky")) {
header.classList.remove("sticky")
}
header.style.transform = null
}
}
})
container.querySelector("#checkpoint-fill").style.width = `${newWidth}%`
const circlesToFill = Math.floor((newWidth+1)/increment)
circles.forEach((circle, i) => {
if (i<=circlesToFill) circle.classList.add("active")
else circle.classList.remove("active")
if (i<=circlesToFill) {
if (!circle.classList.contains("active"))
circle.classList.add("active")
}
else {
if (circle.classList.contains("active"))
circle.classList.remove("active")
}
})
}
});

0 comments on commit 76ba8ee

Please sign in to comment.