How does JS listen to the hidden state of the DOM element on the page?

I encapsulate a simple JS animation myself. I want to play the animation when the element is displayed, and hide it again and then play it again, that is, execute the animation again.
all I can think of right now is to add a special class name to this animated dom, and then use a timer to listen to whether the display of such elements is none.
is there a better way than that?

Dec.23,2021

what I want to know is the element to play the animation, and you should always know which element

add layers to determine whether if (your condition) / / this corresponding identification condition is display none , none return , that is, do not perform animation

won't achieve your effect. The condition is a logo , that is, rape or theft. so the conditions you have or the conditions you have built to judge
what is (what is) A better way?


https://developer.mozilla.org.


look for the root cause. There must be hidden events in your elements. Here is a small example that I hope can help you

.
var status = true;
clickEle.addEventListener(''function(){
    if(status){
        //
    }else{
        //
    }

},false)
Menu