Created
January 8, 2010 12:30
-
-
Save martinogden/272023 to your computer and use it in GitHub Desktop.
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
// Requires jQuery Rotate Plugin - http://wilq32.googlepages.com/wilq32.rollimage222 | |
$(function() | |
{ | |
var angle; | |
function begin_rotation(override_angle) | |
{ | |
// Generate random number between 15 and 35 for rotation distance | |
amount = Math.floor(Math.random()*36); | |
while(amount < 15) | |
{ | |
amount = Math.floor(Math.random()*36); | |
} | |
angle = override_angle? override_angle : 0; | |
rotate = setInterval(function(){do_rotation();}, 100); | |
} | |
// Initial Angle to rotate by | |
function do_rotation() | |
{ | |
if(amount < 1) | |
{ | |
// Stop rotation | |
clearInterval(rotate); | |
} | |
// Slow down rotation | |
angle+=amount; | |
amount = amount - 0.5; | |
$('#cog').rotateAnimation(angle); | |
} | |
// begin_rotation(); | |
// Rotate when button / link is pressed | |
$("#fortune").click(function() | |
{ | |
begin_rotation(20); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment