Skip to content

Instantly share code, notes, and snippets.

@BigglesZX
Created September 10, 2013 10:42
Show Gist options
  • Save BigglesZX/6507717 to your computer and use it in GitHub Desktop.
Save BigglesZX/6507717 to your computer and use it in GitHub Desktop.
Combine fading and sliding in a neat little jQuery animation
;(function($, undefined) {
$.fn.fadeOutSlideUp = function(speed, cb) {
speed || (speed = 'medium');
cb || (cb = function() {});
var self = $(this);
self.animate({ opacity: 0 }, speed, function() {
self.slideUp(speed, cb);
});
};
$.fn.slideDownFadeIn = function(speed, cb) {
speed || (speed = 'medium');
cb || (cb = function() {});
var self = $(this);
self.css({ opacity: 0 }).slideDown(speed, function() {
self.animate({ opacity: 1 }, speed, cb);
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment