Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse transition effect #3101

Merged
merged 3 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions assets/css/cursor_transition.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.cursor {
z-index: 999;
position: fixed;
background: #23bdf5;
width: 20px;
height: 20px;
border-radius: 50%;
pointer-events: none;
box-shadow: 0 0 20px #23bdf5,
0 0 60px #23bdf5,
0 0 100px #23bdf5;
animation: colors 1s infinite;
transform: translate(-50%, -50%);
display: none;
}

@keyframes colors {
0% {
filter: hue-rotate(0deg);
}

100% {
filter: hue-rotate(360deg);
}
}

.cursor:before {
content: '';
position: absolute;
background: #23bdf5;
width: 50px;
height: 50px;
opacity: 0.2;
transform: translate(-30%, -30%);
border-radius: 50%;
}
28 changes: 28 additions & 0 deletions assets/js/cursor_transition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
document.addEventListener("DOMContentLoaded", function () {
const cursor = document.querySelector(".cursor");
var timeout;

document.addEventListener("mousemove", (e) => {
let x = e.clientX;
let y = e.clientY;

cursor.style.top = y + "px";
cursor.style.left = x + "px";
cursor.style.display = "block";

function mouseStopped() {
cursor.style.display = "none";
}

clearTimeout(timeout);
timeout = setTimeout(mouseStopped, 1000);
});

document.addEventListener("scroll", () => {
cursor.style.display = "none";
});

document.addEventListener("mouseout", () => {
cursor.style.display = "none";
});
});
7 changes: 5 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<link rel="stylesheet" href="./assets/css/gameCard.css">
<link rel="stylesheet" href="./assets/css/navbar.css">
<link rel="stylesheet" href="./assets/css/gameCard.css">
<link rel="stylesheet" href="./assets/css/cursor_transition.css">

<!--
- google font link
Expand All @@ -75,7 +76,7 @@
</label> -->

<body>

<div class="cursor"></div>
<!-- BACKGROUND PARTICLES -->
<!-- <div class="page-bg"></div> -->
<!-- <div class="animation-wrapper"> -->
Expand Down Expand Up @@ -233,6 +234,8 @@ <h1>Our Valuable Contributors</h1>
<script src="./assets/js/script.js"></script>
<script src="./assets/js/scroll.js"></script>
<script src="./assets/js/contributors.js"></script>
<script src="./assets/js/cursor_transition.js"></script>



<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
Expand All @@ -251,4 +254,4 @@ <h1>Our Valuable Contributors</h1>

</body>

</html>
</html>
Loading