forked from Suchitra-Sahoo/AgriLearnNetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Cursor Lag Resolved""
- Loading branch information
1 parent
d484796
commit 28d9463
Showing
2 changed files
with
23 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
const cursor = document.querySelector('.cursor'); | ||
const cursor2 = document.querySelector('.cursor2'); | ||
let mouseX = 0, mouseY = 0, cursorX = 0, cursorY = 0, cursor2X = 0, cursor2Y = 0; | ||
|
||
var cursor = document.querySelector(".cursor"); | ||
var cursor2 = document.querySelector(".cursor2"); | ||
document.addEventListener("mousemove", function (e) { | ||
cursor.style.cssText = cursor2.style.cssText = "left: " + e.clientX + "px; top: " + e.clientY + "px;"; | ||
document.addEventListener('mousemove', (e) => { | ||
mouseX = e.clientX; | ||
mouseY = e.clientY; | ||
}); | ||
|
||
function animate() { | ||
cursorX += (mouseX - cursorX) * 0.1; | ||
cursorY += (mouseY - cursorY) * 0.1; | ||
cursor2X += (mouseX - cursor2X) * 0.15; | ||
cursor2Y += (mouseY - cursor2Y) * 0.15; | ||
|
||
cursor.style.transform = `translate(${cursorX - 25}px, ${cursorY - 25}px)`; | ||
cursor2.style.transform = `translate(${cursor2X - 7.5}px, ${cursor2Y - 7.5}px)`; | ||
|
||
requestAnimationFrame(animate); | ||
} | ||
|
||
animate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters