szym
szym

Reputation: 3198

Transitions are triggerd for changes made befor adding transition specific css properties. Why?

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!

Upvotes: 3

Views: 80

Answers (1)

meetamit
meetamit

Reputation: 25167

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 200x200 prior to .animate being added, and it assumes the box started out at 100x100.

Upvotes: 1

Related Questions