Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS3 - Adding dynamic content triggers animation
    primarykey
    data
    text
    <p>I have animation defined in CSS3 for specific class which runs only one time when that class is added to a element. The problem is when I add dynamic content to their parent the animation runs for one more time. Everytime, content is added the animation triggers. A list element which is to be animated is automatically added to <code>ul</code> and it animates one time (expected behaviour) whereas, the non-animable elements are added on JS Event.</p> <p>HTML:</p> <pre><code>&lt;ul&gt; &lt;li class="m"&gt;&lt;div class="animable"&gt;&lt;/div&gt;&lt;/li&gt; &lt;li class="m"&gt;&lt;div class="animable animateNow"&gt;&lt;/div&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>When JS event occurs, a list element is added dynamically.</p> <pre><code>&lt;ul&gt; &lt;li class="m"&gt;&lt;div class="animable"&gt;&lt;/div&gt;&lt;/li&gt; &lt;li class="m"&gt;&lt;div class="animable animateNow"&gt;&lt;/div&gt;&lt;/li&gt; &lt;li class="m"&gt;&lt;div class="animable"&gt;&lt;/div&gt;&lt;/li&gt; // &lt;- Sir! I am innocent. I am newly added by JS. IDK, what is happening :/ &lt;/ul&gt; </code></pre> <p>and the moment it is appended , the animable div triggers its animation for one more time and so on for each added element.</p> <p>Is this a bug ? How can I prevent it? I am using pure JS.</p> <p>CSS:</p> <pre><code>.animable { position:absolute; top:0; left:0; right:0; bottom:0; width:100%; height:100%; background:#ecf7d2; } .animateNow { opacity:0; animation-duration: 2s; animation-name: animTrans; -webkit-animation-duration: 2s; -webkit-animation-name: animTrans; } </code></pre> <p><img src="https://i.stack.imgur.com/iWAoP.jpg" alt="The Big Image"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload