Skip to content

Commit

Permalink
Fixed Answer Button Click Animation & Score
Browse files Browse the repository at this point in the history
  • Loading branch information
sj2245 committed Dec 11, 2023
1 parent ed281f4 commit 0cfe19f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
7 changes: 4 additions & 3 deletions questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ const printQuestionsToSite = (questions, questionsContainer) => {
// we need to calculate how many points each question is worth
let pointsEachQuestionIsWorth = 100 / questions.length;
let currentScore = parseFloat(scoreElement.innerHTML);
scoreElement.innerHTML = (currentScore + pointsEachQuestionIsWorth).toFixed(2);
let calculatedScore = (currentScore + pointsEachQuestionIsWorth).toFixed(2);
let roundedScore = Math.ceil(calculatedScore / 1) * 1;
scoreElement.innerHTML = calculatedScore >= 99.01 ? roundedScore : calculatedScore;
} else {
buttonWeClicked.classList.add(`wrong`);
setTimeout(() => buttonWeClicked.classList.remove(`wrong`), 1000);
Expand All @@ -96,8 +98,7 @@ const printQuestionsToSite = (questions, questionsContainer) => {
// setTimeout(() => {
answersContainerOfQuestion.querySelectorAll(`button`).forEach(childButton => {
childButton.disabled = true;
childButton.style.opacity = 0.75;
childButton.poinerEvents = `none`;
childButton.classList.add(`disabled`);
})
// }, 1500)

Expand Down
6 changes: 6 additions & 0 deletions styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ body.dark a {
color: white;
}

.disabled {
opacity: 0.75;
color: white;
pointer-events: none;
}

.bold {
font-weight: 900;
}
Expand Down
2 changes: 1 addition & 1 deletion styles/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ body {

// utility

.disabled {
opacity: 0.75;
color: white;
pointer-events: none;
}

// Fonts
.bold {
font-weight: 900;
Expand Down

0 comments on commit 0cfe19f

Please sign in to comment.