Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

button animation only runs once on multiple clicks #26

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/assets/js/button_effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ async function flash_screen(mode){
}

async function circle_expand(mode){
await new Promise(res => setTimeout(res, 10))

let button = document.querySelector(".run-button button")
if (mode == 'fail')
button.classList.add("red");
if (button.classList.contains('green') || button.classList.contains('red')) return
clear_circle_classes(button)

button.classList.remove("expand_start");
button.classList.remove("expand_end");
button.classList.remove("button_color");
if (mode == 'success')
button.classList.add("green");
else if (mode == 'fail')
button.classList.add("red");

button.classList.add("expand_start");
await new Promise(res => setTimeout(res, 1000))
Expand All @@ -54,9 +53,15 @@ async function circle_expand(mode){
await new Promise(res => setTimeout(res, 10))

button.classList.add("expand_end");
await new Promise(res => setTimeout(res, 1000))
await new Promise(res => setTimeout(res, 400))

clear_circle_classes(button)
}

function clear_circle_classes(button){
button.classList.remove("expand_start");
button.classList.remove("expand_end");
button.classList.remove("button_color");
button.classList.remove("green");
button.classList.remove("red");
}
12 changes: 9 additions & 3 deletions src/assets/style/button_effects.scss
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ $button-color: #5134E0;
}

.run-button button.expand_start {
background-image: radial-gradient(circle at center, $circle-green 10%, $button-color 11%) !important;
&.green{
background-image: radial-gradient(circle at center, $circle-green 10%, $button-color 11%) !important;
}
&.red {
background-image: radial-gradient(circle at center, $circle-red 10%, $button-color 11%) !important;
}
Expand All @@ -164,7 +166,9 @@ $button-color: #5134E0;
}

.run-button button.expand_end {
background-image: radial-gradient(circle at center, $button-color 10%, $circle-green 11%) !important;
&.green{
background-image: radial-gradient(circle at center, $button-color 10%, $circle-green 11%) !important;
}
&.red{
background-image: radial-gradient(circle at center, $button-color 10%, $circle-red 11%) !important;
}
Expand All @@ -173,7 +177,9 @@ $button-color: #5134E0;
}

.run-button button.button_color {
background-color: $circle-green !important;
&.green{
background-color: $circle-green !important;
}
&.red{
background-color: $circle-red !important;
}
Expand Down
Loading