Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fade out old element, fade in new

I am new to react and have tried react animations. They work great when elements are added or removed in a TransitionGroup. But if I replace a single element with a similar one, react detects that the content of that element has changed and does not trigger an animation.

How can I fade out a single element and fade in a new one in the same place? For example fade out login-div, fade in dashboard-div.

like image 369
bara Avatar asked Feb 19 '14 08:02

bara


People also ask

What is the difference between fadeIn and fadeOut?

A fade-in effect begins with a solid color (Movie Maker supports both black and white) and then fades into your video. A fade-out effect begins with the video and then fades into the solid color, again either black or white.

How do I fadeIn and fadeOut in CSS?

The jQuery fadeToggle() method toggles between the fadeIn() and fadeOut() methods. If the elements are faded out, fadeToggle() will fade them in.

What is fadeIn and fadeOut in animation?

The Fade In/Fade Out behavior lets you dissolve into and out of any object by ramping the opacity of the object from 0 percent to 100 percent at the start, and then back to 0 percent at the end. You can eliminate the fade-in or fade-out effect by setting the duration of the Fade In Time or Fade Out Time to 0 frames.

How do I fadeOut an element in HTML?

In the CSS, use the @keyframes rule paired with fadeIn. At 0%, set the opacity to 0. At 100%, set the opacity to 1. This creates the fade-in effect.


1 Answers

If your elements have different key attributes, TransitionGroup will unmount one and mount the other.

You can read more about keys here: Composition vs Inheritance.

like image 93
Sophie Alpert Avatar answered Sep 21 '22 21:09

Sophie Alpert