blob: 2d265bfc56f0a2d5f670e0b4b9f31085042b32ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
;(function($) {
$.effects.fade = function(o) {
return this.queue(function() {
// Create element
var el = $(this), props = ['opacity'];
// Set options
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
var opacity = o.options.opacity || 0; // Default fade opacity
var original_opacity = el.css('opacity');
// Adjust
$.effects.save(el, props); el.show(); // Save & Show
if(mode == 'show') el.css({opacity: 0}); // Shift
// Animation
var animation = {opacity: mode == 'show' ? original_opacity : opacity};
// Animate
el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
if(mode == 'hide') el.hide(); // Hide
if(mode == 'hide') $.effects.restore(el, props); // Restore
if(o.callback) o.callback.apply(this, arguments); // Callback
el.dequeue();
}});
});
};
})(jQuery);
|