Take a look at this jsfiddle
http://jsfiddle.net/zB2Td/5/
Animation is triggered although .animate class is added after changing the dimensions.
If you uncomment the second line from the end transition won’t start as it should.
Why does this code work like that?
What is a proper way to add .animate and not trigger transition on the previous changes.
Thanks!
To my understanding, what’s happening is that the call to
box.width()counts as a “Read” operation, as defined by this post. It forces the browser (webkit anyway) to re-layout (aka reflow) the DOM. Without this call, the browser never “knows” that the box was 200×200 prior to.animatebeing added, and it assumes the box started out at 100×100.