Created
February 9, 2015 09:49
-
-
Save Bellfalasch/f8c730ac6a38d7b2ecef to your computer and use it in GitHub Desktop.
Rotate an image on click (nice "load" animation)
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
// Rotate image | |
// http://stackoverflow.com/questions/15191058/css-rotation-cross-browser-with-jquery-animate | |
// Call: $('#loadmore span').animateRotate( 360, 500, 'swing', null ); | |
$.fn.animateRotate = function(angle, duration, easing, complete) { | |
var args = $.speed(duration, easing, complete); | |
var step = args.step; | |
return this.each(function(i, e) { | |
args.step = function(now) { | |
$.style(e, 'transform', 'rotate(' + now + 'deg)'); | |
if (step) return step.apply(this, arguments); | |
}; | |
$({deg: 0}).animate({deg: angle}, args); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment