It looks like you're new here. If you want to get involved, click one of these buttons!
#ui-bar.blank {
display: none;
}
<<addclass "#ui-bar" "blank">>
But, if I remove this class to put the UI back, it suddenly appearing again tends to be a bit jarring. So I want to fade it in. But unfortunately, this doesn't work:
#ui-bar.fade {
-webkit-transition: all 2s linear;
transition: all 2s linear;
}
<<removeclass "#ui-bar" "blank">>
<<addclass "#ui-bar" "fade">>
It just results in the ui bar zipping back into place and ignoring the transition commands.
Comments
display
property cannot be animated and thevisibility
property's ability to be animated is limited. If you want to fade the UI bar in/out, then you will need to useopacity
.Try the following CSS: (n.b. the use of the
visibility
property ensures that the UI bar is non-interactive while it's hidden)Note that my UI bar itself is set to be all transparent apart from the text links, so maybe it's applying to something already hidden.
If you don't use
visibility
, as well asopacity
, then the UI bar (and its contents) will still be interactive (they need to be hidden to be non-interactive, not simply invisible). If you don't animate thevisibility
change (specifically, withstep-end
or the equivalent; thestep-end
function stays at the start state until the duration is complete then switches to the end state), then it will apply immediately, meaning the bar will simply disappear and not fade out.Beyond that, changing the duration on the
visibility
animation does have an affect. By your example, the UI bar (and its contents) will become transparent in400ms
due to theopacity
animation, while the interactive elements will still be active (because they're not hidden yet) for10000ms
. The durations should be the same for both.You'll note there's no animation for
visibility
on the#ui-bar:not(.hide)
ruleset (though I could have added one usingstep-start
), which is because it would be pointless. The UI bar needs to be visible immediately when it's supposed to be fading back in, so we can actually see it fading back in.Basically, the animations work like so:
I assume you mean its background, and that's irrelevant/separate to what we're doing here. The above affects the UI bar as a whole, not simply its background.
Come to think of it I was examining the fadein interactivity, rather than the fadeout, so of course I didn't see any change. Redid my test to look at the right thing and I see what's happening now.
Thanks.