I've created a new element using jquery and then appended it to my DOM.
I then show two other elements and then finally add a css class which transitions in the newly created element.
However it doesnt transition in unless i wrap it in setTimeout of even just one millisecond.
setTimeout(function(){
$('.modal-window').addClass('modal-animate-in');
},1)
I've stepped through the code line by line in chrome and then it seems to animate in when it gets to the right line otherwise it needs some kind of delay. Whats going on?
How can i even debug this?
I could just leave it with the setTimeout but that would be bad practise, and i would like to understand whats going on.
EDIT
Firefox is the same but requires a few more milliseconds timeout