I have an element that I've changed the style of (Either through changing the class or modifying the style).
I then wish to add a transition so that later changes will be animated.
For some reason, when I set the style before the transition, the style is still animated. This is happening in the latest versions of Firefox, Chrome, and Safari.
Example: http://codepen.io/DavidBradbury/pen/IxfmF
JS Snippet [Library is jQuery but it shouldn't matter]:
$(function() {
$("#toggle").on({
click: function(e) {
// ## Change the class / style
// At this point, it shouldn't know that
// a transition will be added
$("#badidname").toggleClass('newclass');
// Then add the transition
$("#badidname").css({
"transition": "all 600ms"
});
// For some reason, it animates
// the class being added
}
})
})