Last active
February 28, 2018 00:44
Click to spin JS
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
$('body').prepend('<style>@keyframes spin {from {transform:rotate(0deg);} to {transform:rotate(359deg);} } @keyframes spinrev {from {transform:rotate(0deg);} to {transform:rotate(-359deg);} }</style>'); | |
$('body').click(function(event) { | |
event.preventDefault(); | |
//use event.target with firefox | |
var target = event.toElement || event.target; | |
var spin = (Math.random() < 0.5) ? 'spin' : 'spinrev'; | |
$(target).css('animation', spin + ' 4s infinite linear'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment