Last active
April 25, 2016 10:35
-
-
Save WebMaestroFr/9316374 to your computer and use it in GitHub Desktop.
jQuery Plugin to fade in and out with a vertical slide
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
(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