aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2009-11-16 02:49:36 +0000
committerScott González <scott.gonzalez@gmail.com>2009-11-16 02:49:36 +0000
commit31a5ee94a9ac8cfb2a7194aba130481abe9c9f22 (patch)
tree0120d800c52a2e7b1c2258ddf1a93f7c498c7657
parent6fdc4b5d32224d6c5a534257fa90787590e50a92 (diff)
downloadjquery-ui-31a5ee94a9ac8cfb2a7194aba130481abe9c9f22.tar.gz
jquery-ui-31a5ee94a9ac8cfb2a7194aba130481abe9c9f22.zip
Pulsate: Rewrote pulsate effect.
Fixes #4718 - pulsate pulses one extra time.
-rw-r--r--ui/jquery.effects.pulsate.js59
1 files changed, 27 insertions, 32 deletions
diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js
index 8ce9e529a..6a19497af 100644
--- a/ui/jquery.effects.pulsate.js
+++ b/ui/jquery.effects.pulsate.js
@@ -13,44 +13,39 @@
(function($) {
$.effects.pulsate = function(o) {
-
return this.queue(function() {
+ var elem = $(this),
+ mode = $.effects.setMode(elem, o.options.mode || 'show');
+ times = ((o.options.times || 5) * 2) - 1;
+ duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2,
+ isVisible = elem.is(':visible'),
+ animateTo = 0;
+
+ if (!isVisible) {
+ elem.css('opacity', 0).show();
+ animateTo = 1;
+ }
- // Create element
- var el = $(this);
-
- // Set options
- var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
- var times = o.options.times || 5; // Default # of times
- var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2;
+ if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) {
+ times--;
+ }
- // Adjust
- if (mode == 'hide') times--;
- if (el.is(':hidden')) { // Show fadeIn
- el.css('opacity', 0);
- el.show(); // Show
- el.animate({opacity: 1}, duration, o.options.easing);
- times = times-2;
+ for (var i = 0; i < times; i++) {
+ elem.animate({ opacity: animateTo }, duration, o.options.easing);
+ animateTo = (animateTo + 1) % 2;
}
- // Animate
- for (var i = 0; i < times; i++) { // Pulsate
- el.animate({opacity: 0}, duration, o.options.easing).animate({opacity: 1}, duration, o.options.easing);
- };
- if (mode == 'hide') { // Last Pulse
- el.animate({opacity: 0}, duration, o.options.easing, function(){
- el.hide(); // Hide
- if(o.callback) o.callback.apply(this, arguments); // Callback
- });
- } else {
- el.animate({opacity: 0}, duration, o.options.easing).animate({opacity: 1}, duration, o.options.easing, function(){
- if(o.callback) o.callback.apply(this, arguments); // Callback
- });
- };
- el.queue('fx', function() { el.dequeue(); });
- el.dequeue();
- });
+ elem.animate({ opacity: animateTo }, duration, o.options.easing, function() {
+ if (animateTo == 0) {
+ elem.hide();
+ }
+ (o.callback && o.callback.apply(this, arguments));
+ });
+ elem
+ .queue('fx', function() { elem.dequeue(); })
+ .dequeue();
+ });
};
})(jQuery);