Note that there are some explanatory texts on larger screens.

plurals
  1. POFirefox not updating DOM before CSS3 transition
    primarykey
    data
    text
    <p>I'm trying to build a really simple slider. I want to use CSS3 transitions for the animations and js to apply an animate-in and animate-out class to individual frames in sequence.</p> <p>I've written a working demo of the basic intended functionality on jsfiddle here: <a href="http://jsfiddle.net/7myKg/3/">http://jsfiddle.net/7myKg/3/</a></p> <p>It's very simple. A frame is animated in by applying the animate-in class and animated out by applying the animate-out class. For example this would display the second frame:</p> <pre><code>&lt;div class="slider" id="slider"&gt; &lt;ul&gt; &lt;li id="frame1" class="animate-out"&gt;&lt;p&gt;one&lt;/p&gt;&lt;/li&gt; &lt;li id="frame2" class="animate-in"&gt;&lt;p&gt;two&lt;/p&gt;&lt;/li&gt; &lt;li id="frame3"&gt;&lt;p&gt;three&lt;/p&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;​ </code></pre> <p>Before I can animate-in a frame I need to ensure it is reset and the frame MUST NOT transition to it's reset state. To achieve this I'm adding inline styles to the frame to set it's transition-duration to 0s before removing it's animate-out class. This currently works as intended in Chrome. The problem I am having is that Firefox seems to be applying the animate-in class before the DOM has reflected the changes to the element's style, and this causes the element/frame to transition backwards. Easier seen by running the demo in Firefox than explaining. I added a setTimeout wrap with a delay to demo how I was expecting it to behave.</p> <p>What am I missing? Why doesn't Firefox update the DOM element instantly?</p> <p>I'm building this myself from the ground up as a learning experience and because I thought it was a curious problem I would be able to solve. It is not intended for production, at least certainly not at the moment. For this reason I do not want to use one of the many existing solutions or plugins.</p> <p>Note: This is my first ever question so any constructive tips if I've done something wrong on how I can ask better questions in the future would be greatly appreciated.</p> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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