Skip to content

Instantly share code, notes, and snippets.

@WebMaestroFr
Last active April 25, 2016 10:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WebMaestroFr/9316374 to your computer and use it in GitHub Desktop.
Save WebMaestroFr/9316374 to your computer and use it in GitHub Desktop.
jQuery Plugin to fade in and out with a vertical slide
(function ($) {
'use strict';
var getUnqueuedOpts = function (opts) {
return {
queue: false,
duration: opts.duration,
easing: opts.easing
};
};
$.fn.showDown = function (opts) {
opts = opts || {};
$(this).hide().slideDown(opts).animate({ opacity: 1 }, getUnqueuedOpts(opts));
};
$.fn.hideUp = function (opts) {
opts = opts || {};
$(this).show().slideUp(opts).animate({ opacity: 0 }, getUnqueuedOpts(opts));
};
$.fn.verticalFade = function (opts) {
opts = opts || {};
if ($(this).is(':visible')) {
$(this).hideUp(opts);
} else {
$(this).showDown(opts);
}
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment