done mousefollwer

pull/222/head
anuj 8 months ago
parent 5cb1e01669
commit c4e1425a8e

@ -7,6 +7,8 @@
<title>Sticky Navigation</title> <title>Sticky Navigation</title>
</head> </head>
<body> <body>
<div id="mousefollower"></div>
<nav class="nav"> <nav class="nav">
<div class="container"> <div class="container">
<h1 class="logo"><a href="/index.html">My Website</a></h1> <h1 class="logo"><a href="/index.html">My Website</a></h1>

@ -8,3 +8,20 @@ function fixNav() {
nav.classList.remove('active') nav.classList.remove('active')
} }
} }
var mouse = document.querySelector('#mousefollower');
document.body.addEventListener('mousemove',(details)=>{
var x = details.pageX;
var y = details.pageY;
console.log(y)
mouse.style.transform = `translate(${x}px,${y}px)`
})
document.body.addEventListener('mouseenter',(details)=>{
mouse.style.opacity = '1'
})
document.body.addEventListener('mouseleave',(details)=>{
mouse.style.opacity = '0'
})

@ -115,3 +115,15 @@ body {
line-height: 30px; line-height: 30px;
letter-spacing: 1.2px; letter-spacing: 1.2px;
} }
#mousefollower{
height: 20px;
width: 20px;
position: absolute;
z-index: 999;
mix-blend-mode: difference;
border-radius: 50%;
opacity: 0;
transition: 0.1s;
background-color: white;
}
Loading…
Cancel
Save