-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNav.js
30 lines (26 loc) · 789 Bytes
/
Nav.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React,{useState,useEffect} from 'react';
import "./Nav.css";
import Logo from './OIP.jfif';
import avatar from './avatar.png';
function Nav() {
const [show,handleShow]= useState(false);
useEffect(() => {
window.addEventListener("scroll",() => {
if(window.scrollY>100){
handleShow(true);
}else
handleShow(false);
});
return () =>{
window.removeEventListener("scroll");
};
}, []);
return (
<div className={`nav ${show && "nav_black"}`}>
<img className="nav_logo" src={Logo} alt="netflix logo" />
<img className="nav_avatar" src={avatar}
alt="avatar" />
</div>
)
}
export default Nav;