Skip to content

Commit

Permalink
add mouse and hover animation
Browse files Browse the repository at this point in the history
  • Loading branch information
bailey authored Feb 25, 2024
1 parent aa35f13 commit 44b08ba
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lilita+One">
<link rel="icon" type="image/x-icon" href="assets/planet.png">

<div id="cursorCircle"></div>

<head>
<script async src="https://us.umami.is/script.js" data-website-id="2905a2ba-9957-46f5-9196-a53624d26687"></script>
</head>
Expand Down
16 changes: 15 additions & 1 deletion index_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,18 @@ body {
width: 60%;
margin: 0 18%;
}
}
}
#cursorCircle {
width: 20px;
height: 20px;
fill: black;
background-color:#9193ff;
opacity: 50%;
border-radius: 50%;
position: fixed;
pointer-events: none;
transform: translate(-50%, -50%);
transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
z-index: 9999;
display: none;
}
3 changes: 3 additions & 0 deletions resume.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<link rel="stylesheet" href="resume_style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lilita+One">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Karla">
<script src="script.js"></script>

<div id="cursorCircle"></div>

<header>
recently...
Expand Down
13 changes: 13 additions & 0 deletions resume_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,17 @@ body {
font-size: 50px;
margin-top: -6vh;
margin-left: -32%;
}
#cursorCircle {
width: 20px;
height: 20px;
background-color:#9193ff;
opacity: 50%;
border-radius: 50%;
position: fixed;
pointer-events: none;
transform: translate(-50%, -50%);
transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
z-index: 9999;
display: none;
}
26 changes: 26 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
document.addEventListener('DOMContentLoaded', function() {
const cursorCircle = document.getElementById('cursorCircle');
document.addEventListener('mousemove', function(e) {
cursorCircle.style.left = e.pageX + 'px';
cursorCircle.style.top = e.pageY + 'px';
cursorCircle.style.display = 'block';
});

const links = document.querySelectorAll('a');
document.addEventListener('mousemove', function(e) {
let closestDistance = Infinity;
links.forEach(link => {
const rect = link.getBoundingClientRect();
const linkX = rect.left + rect.width / 2;
const linkY = rect.top + rect.height / 2;
const distance = Math.sqrt(Math.pow(linkX - e.pageX, 2) + Math.pow(linkY - e.pageY, 2));
if (distance < closestDistance) {
closestDistance = distance;
}
});
const size = Math.max(20, Math.min(100, 100 - closestDistance));
cursorCircle.style.width = size + 'px';
cursorCircle.style.height = size + 'px';
});
});

0 comments on commit 44b08ba

Please sign in to comment.