From 0f060e81a409409ba85081268daa8ffa0268a6b7 Mon Sep 17 00:00:00 2001 From: Verox001 Date: Wed, 14 Feb 2024 10:50:23 +0100 Subject: [PATCH] Fixed animation and color change of habit progress bar --- templates/index.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/index.html b/templates/index.html index 793795f..81c5a0e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -177,11 +177,14 @@ var habitBlock = document.getElementById("habit-" + habitId); if (percentage == 100) { - progressBar.style.backgroundColor = "green"; habitBlock.classList.add("animate-bounce"); setTimeout(function () { habitBlock.classList.remove("animate-bounce"); }, 2000); + } + + if (percentage >= 100) { + progressBar.style.backgroundColor = "green"; } else { progressBar.style.backgroundColor = ""; habitBlock.classList.remove("animate-bounce"); @@ -209,7 +212,9 @@ var percentage = response.data.percentage; var progressBar = document.getElementById("progress-bar-" + habitId); progressBar.style.width = percentage + "%"; - checkCompletionAndAnimate(habitId, percentage); + if (response.data.unchecked) { + checkCompletionAndAnimate(habitId, percentage); + } }).catch(function (error) { // Handle the error if needed console.error('Error:', error);