Original Question... updated working code below:
Here is a simplified test case:
div {
background: blue;
opacity: 0;
transition: opacity 2s ease-in-out;
}
div.loading {
opacity: 1;
background: red;
transition: opacity 2s ease-in-out, background 1s ease-in;
}
Notice how the opacity
fades the same in and out, but the background
only fades in, and immediately turns blue on fade out.
I used :hover
as an example, but it should work the same when adding and removing classes with JavaScript.
If you'd like a more specific example please provide a reduced test case on dabblet or Jsfiddle.