Simple fade entrance in VueJS with CSS transition - css

It looks so simple but I can handle to make it work.
When a new element is added to my list, I want the others elements to move to let the space for the new one and then the new one has to appear with a fade transition.
I can't make this simple animation. I can make the others elements to move but my new element does not have any fade transition. It just appears! BIM.
Here's a codepen : https://codepen.io/MuyBien/pen/OEqNEQ
.fade-enter-active {
transition: opacity .3s ease-out;
transition-delay: .3s;
}
.fade-enter {
opacity: 0;
}
.fade-enter-to {
opacity: 1;
}
.fade-move {
transition: transform .3s;
}

.fade-enter-active {
transition: opacity 1s ease-out;
transition-delay: 1s;
}
.fade-enter {
opacity: 0;
}
.fade-enter-to {
opacity: 1;
}
.fade-move {
transition: transform 1s;
}
You can just delay the entry.

Related

Css transition from opacity 0 to 1 back to 0

I have a div element, which I have initially kept at Zero '0' opacity.
On certain event I add a class with transition 0.3s and opacity '1'.
But I want transition to to end on out immediately (set 0 opacity without transition when class is removed).
div{
opacity: 0;
transition: opacity 0.3s ease-in;
}
div:hover{
opacity: 1;
}
Tried only with ease-in, and also cubic-bezier(), but somehow I can't do it.
Just move your transition to 'hover' state.
div{
opacity: .5;
}
div:hover{
opacity: 1;
transition: opacity 0.3s ease-in;
}
<div>hello world!</div>
try
div {
height:150px; width:150px; background:red;
opacity: 0;
}
div:hover {
opacity: 1;
transition: opacity 0.3s ease-in;
}
Put cursor below
<div></div>

CSS animation forwards is preventing css transitions

I am setting my CSS animation type to forwards so that the finished frame of the animation is the default state when finished.
But now, the transition that animates the same property (transform) is not working anymore...
I have to use forwards because otherwise the opacity resets to 0 after animating.
How can I enable a transition as soon as an animation has finished? I am looking for a CSS-only option without javascript.
CSS
album {
opacity: 0;
animation:movein 0.6s forwards;
transition: all 0.3s ease-in-out;
}
album:hover {
transform:scale(1.05); // this doesn't work
box-shadow: 0px 0px 45px rgba(0,0,0,0.5); // this works
}
#keyframes movein {
from {
opacity:0;
transform: translateX(-100px);
}
to {
opacity:1;
transform: translateX(0px);
}
}
album:nth-child(2) {
animation-delay: 0.2s; // delay keeps opacity 0 for a while
}
album:nth-child(3) {
animation-delay: 0.4s; // delay keeps opacity 0 for a while
}
One solution could be to split up your animation. Only the fadein animation has animation forwards.
album {
opacity: 0;
animation:movein 0.6s, fadein 0.6s forwards;
transition: all 0.3s ease-in-out;
}
#keyframes movein {
from {
transform: translateX(-100px);
}
to {
transform: translateX(0);
}
}
#keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}

how do i make opacity transition after transform

I'm trying to make something like fullpage.js. I have an active element and previous element. When I'm scrolling I have transform property on the both blocks, one like
.active {
transform: translateY(0);
opacity: 1;
transition: all 1s ease;
}
And another is
.previous {
transform: translateY(100vh);
opacity: 0;
transition: all 1s ease;
}
Without transition they appear in a moment without any delay. But when I add transition they starting to blink because of the opacity. How can I make the block first to transform and then to lose it's opacity
You can simply define multiple transitions:
div {
width: 200px;
height: 200px;
background: orange;
opacity: 0.5;
transition: transform 0.5s ease 0s, opacity 0.5s ease 0.5s;
}
body:hover div {
transform: rotate(45deg);
opacity: 1;
}
<div></div>

transition opacity with delay

I want to fade out an element after 3 seconds. I'm currently using an animation to do this but I've just learned of transition-delay, so I believe I may be able to remove the animation and do it through a transition. Is this possible?
My original code is:
.foo {
animation: fadeOut 3s cubic-bezier(0.645, 0.045, 0.355, 1.000)
}
#keyframes fadeOut {
80%{
opacity: 1
}
100% {
opacity: 0
}
}
Here is my attempt at a transition:
.announcement {
display: block;
font-size:22px;
transition: opacity 0.4s cubic-bezier(0.645, 0.045, 0.355, 1.000);
transition-delay :3s;
opacity:0;
}
<div class="announcement">asdasd</div>
http://jsbin.com/vejewukusi/edit?html,css,output
Is this possible without adding another CSS class?
Just to make things more clear, I want to append a div with a class, wait 3 seconds, and then fade it out, and do this without using keyframes.
Does this solve your problem: JSFiddle? I have added an animation and a little function to animate the opacity:
.test {
animation: opacity 1s;
}
#keyframes opacity {
from { opacity: 0.5; }
to { opacity: 1; }
}

css attribute selector not matching dynamically added class names

I am using react's CSS animations add-on and everything works fine when I use their provided classnames.
.quote-enter {
opacity: 0.01;
transition: opacity .25s ease-in;
}
.quote-enter.quote-enter-active {
opacity: 1;
}
.quote-leave {
opacity: 1;
transition: opacity .25s ease-in;
}
.quote-leave.quote-leave-active {
opacity: 0.01;
}
but when I try to convert that to an attribute selector method to catch each instance of component that should animate, it doesn't work, no selector matches.
[class$='-enter'] {
opacity: 0.01;
transition: opacity .25s ease-in;
}
[class$='-enter'][class$='-enter-active'] {
opacity: 1;
}
[class$='-leave'] {
opacity: 1;
transition: opacity .25s ease-in;
}
[class$='-leave'][class$='-leave-active'] {
opacity: 0.01;
}
The $= operator matches the end of the whole attribute, so if the class you're targeting isn't the last one of the element (say class="whatever-enter other-class"), the selector won't match.
You can try this:
[class$='-enter'], [class*='-enter '] {
opacity: 0.01;
transition: opacity .25s ease-in;
}
[class$='-leave'], [class*='-leave '] {
opacity: 1;
transition: opacity .25s ease-in;
}
It will become more complex when combining two classes (2*2 = 4 selectors), so maybe you'll be better off sticking to the *=operator alone:
[class*='-enter'] {
opacity: 0.01;
transition: opacity .25s ease-in;
}
[class*='-enter'][class*='-enter-active'] {
opacity: 1;
}
[class*='-leave'] {
opacity: 1;
transition: opacity .25s ease-in;
}
[class*='-leave'][class*='-leave-active'] {
opacity: 0.01;
}
This will work as long as you don't have any other classes ending with these suffixes.

Resources