A Pen by Paul Langton on CodePen.
Created
September 23, 2019 10:48
-
-
Save busyevolving/c98643b1ce5a4221d87a3dcbba9ea3ab to your computer and use it in GitHub Desktop.
Circle Follow Cursor
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
<span id="circle" class="circle"></span> |
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
jQuery(document).ready(function() { | |
var mouseX = 0, mouseY = 0; | |
var xp = 0, yp = 0; | |
$(document).mousemove(function(e){ | |
mouseX = e.pageX - 30; | |
mouseY = e.pageY - 30; | |
}); | |
setInterval(function(){ | |
xp += ((mouseX - xp)/6); | |
yp += ((mouseY - yp)/6); | |
$("#circle").css({left: xp +'px', top: yp +'px'}); | |
}, 20); | |
}); |
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
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
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
@import url(https://fonts.googleapis.com/css?family=Roboto:400,900); | |
body, html { | |
position: relative; | |
height: 100%; | |
width : 100%; | |
margin: 0; | |
background-color: #000000; | |
} | |
.circle { | |
position: absolute; | |
border: solid 1px #ccc; | |
width: 60px; | |
height: 60px; | |
border-radius: 50%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment