Created
September 30, 2018 16:14
-
-
Save zerobias/a06130e79f197d5e50238b1c79e1bc6e to your computer and use it in GitHub Desktop.
Transition cursor ball https://now-iqntlcnjeu.now.sh
This file contains hidden or 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
p{padding-left:60px;} | |
#foo{ | |
border-radius:50px; | |
width:50px; | |
height:50px; | |
background:#c00; | |
position:absolute; | |
top:0; | |
left:0; | |
transition: transform 1s; | |
} |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>transition cursor ball</title> | |
<link href="/cursorball.css" rel="stylesheet"> | |
</head> | |
<body> | |
<p>Click anywhere to move the ball</p> | |
<div id="foo"></div> | |
<script src="/cursorball.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
const f = document.getElementById('foo'); | |
document.addEventListener('click', function(ev){ | |
f.style.transform = 'translateY('+(ev.clientY-25)+'px)'; | |
f.style.transform += 'translateX('+(ev.clientX-25)+'px)'; | |
},false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment