Javascript Module of jQuery extensions, example: animateRotate

/* ---------  Start jquery.extensions.module.js  --------- */

// jquery extensions Module

(function ( $ ) {

	$.fn.animateRotate = function(angle, duration, easing, complete) {
		var args = $.speed(duration, easing, complete);
		var step = args.step;
		return $(this).each(function(i, e) {
		   	args.complete = $.proxy(args.complete, e);
		    args.step = function(now) {
		    	$.style(e, 'transform', 'rotate(' + now + 'deg)');
		    	if (step) return step.apply(e, arguments);
		    };

		    $({deg: 0}).animate({deg: angle}, args);
		});
	}

// method/extension #2 goes here, and so on...

})( window.jQuery );

/* ---------  End jquery.extensions.module.js --------- */

Leave a Reply

You must be logged in to post a comment.