3

I want add animation class continuously on clicking for that I have written below code

My Code

My problem is when I click first time then only first time animation works on second click animation not working. Please help.

1

1 Answer 1

9

You can add setTimeout for delay to add add class

Stackblitz Demo

rotate(event){
    event.srcElement.classList.remove("rotate");
    setTimeout(()=>{
      event.srcElement.classList.add("rotate");
    },0)
  }
Sign up to request clarification or add additional context in comments.

1 Comment

This is brilliant! With this you do not need to create any state-tracking variables ❤

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.