I currently have a scroll event which changes the background when scrolled downwards. However, I'd like the background to revert to its original color once the page is scrolled or positioned to the top. How do I do this? Here is some of my code:
class Nav extends Component {
state = {
background: "skyblue",
navSize: "130px",
activeItem: '',
options : [
{key: 'logout', text: 'logout'}
]
}
handleItemClick = (e) => this.setState({activeItem: e})
componentDidMount() {
window.addEventListener('scroll', this.handleScroll);
}
componentWillUnmount() {
window.removeEventListener('scroll', this.handleScroll);
}