From 76ba8eee43695a9c0a74c47793221f7b669d123d Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 1 Jul 2024 15:26:54 +0400 Subject: [PATCH] Optimization --- css/style.scss | 4 ++++ js/main.js | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/css/style.scss b/css/style.scss index aa5f77d..fc1fd9f 100644 --- a/css/style.scss +++ b/css/style.scss @@ -305,6 +305,10 @@ span.hu { top: 2rem; transform: scale(10); opacity: 0.2; + + &.active { + transition: 0.15s linear transform; + } } } } diff --git a/js/main.js b/js/main.js index b095f9c..aa5dc5e 100644 --- a/js/main.js +++ b/js/main.js @@ -224,10 +224,14 @@ 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 } } @@ -235,8 +239,14 @@ ready(() => { 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") + } }) } }); \ No newline at end of file