Skip to content

Instantly share code, notes, and snippets.

@joewright
Last active June 11, 2026 15:49
Show Gist options
  • Select an option

  • Save joewright/16ca1fa997f72922e4c4f3b6cac3e70b to your computer and use it in GitHub Desktop.

Select an option

Save joewright/16ca1fa997f72922e4c4f3b6cac3e70b to your computer and use it in GitHub Desktop.
Click to spin JS.
// paste this in your browser's JS console for a better viewing and clicking experience
var style = document.createElement('style');
style.innerHTML = '@keyframes spin {from {transform:rotate(0deg);} to {transform:rotate(359deg);} } @keyframes spinrev {from {transform:rotate(0deg);} to {transform:rotate(-359deg);} }';
document.head.appendChild(style);
document.body.addEventListener('click', function(event) {
event.preventDefault();
var target = event.target;
var spin = (Math.random() < 0.5) ? 'spin' : 'spinrev';
target.style.animation = spin + ' 4s infinite linear';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment