Of course there is. There’s always a way to do things but the question is – which way is simpler/cleaner to do.
What hills suggested is a simple way but if you want to make your life harder you can always use JS to do it. In which the JS route would take several lines of code.
Add an id to the element then use the getElementById method JS provides. based on your condition you hide that element using the style.display = ‘none’ and then add animation using .style.animation.
btw you’re still adding css to that element via JS this is just the longer route.