How do I get the li elements to fade in one by one in React? Note, I initially have the li display on none. Then, I plan to activate them when the mouse hovers over the ul word. The initial li will have opacity 0 but then I want the li to change one by one to opacity 1. How do I do this?
import React, { Component } from 'react';
import { Image } from 'semantic-ui-react'
class SideBar extends Component {
state = {
activeItem: '',
displaying: false
};
mouseOver = () => {
this.setState({displaying: true,activeItem: 'collapsed' });
};
mouseOut = () => {
this.setState({displaying: false ,activeItem: '' });
};
render() {
const { activeItem, displaying } = this.state;
let x = {
a: {display: 'none'},
b: {display: 'block'}
}
return(
<header className="main-header">
<div className="main-header-frame">
<div className="header-wrapper">
<nav
onMouseLeave={this.mouseOut}
onMouseOver={this.mouseOver}
className="main-navigation-container">
<ul className="main-navigation">
<li>
<a
href='/test'>Test1</a>
<ul
className="t1"
style={Object.assign({},displaying && x.b, !displaying && x.a)
>
<li>t1</li>
<li>t2</li>
<li>t3</li>
<li>t4</li>
<li>t5</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</header>
)
}
};
export default SideBar;
My CSS is as follows:
.t1 > li {
opacity: .2;
transition: all .8s ease-out;
-webkit-transition: all .8s ease-out;
-moz-transition: all .8s ease-out;
-o-transition: all .8s ease-out;
transition-delay: .4s;
}
.t1 > li:hover {
opacity: 1;
}
Maybe there's a way to do it by adding a classname to each li?