Skip to content

Instantly share code, notes, and snippets.

@higeorange
Created November 1, 2010 21:20
Show Gist options
  • Save higeorange/658900 to your computer and use it in GitHub Desktop.
Save higeorange/658900 to your computer and use it in GitHub Desktop.
(function($) {
$.fn.randomRotation = function(i) {
var c = 90;
var prefix = $.browser.opera ? "-o-":
$.browser.webkit ? "-webkit-":
$.browser.mozilla ? "-moz-":
"";
return this.each(function() {
var pom = Math.random() > 0.5 ? 1 : -1
var rotation = pom * Math.floor(Math.random() * c);
var origin = (pom > 0 ? "0% " : "100% ") + "100%"
$(this).css(prefix + "transform-origin", origin)
.css(prefix + "transform", "rotate(" + rotation +"deg)");
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment