]> source.dussan.org Git - jquery-ui.git/commitdiff
Refactored puff effect.
authorScott González <scott.gonzalez@gmail.com>
Mon, 15 Jun 2009 02:21:44 +0000 (02:21 +0000)
committerScott González <scott.gonzalez@gmail.com>
Mon, 15 Jun 2009 02:21:44 +0000 (02:21 +0000)
ui/effects.scale.js

index 79912791a2533551920dcf4727d2e43a27e43be7..3a2023537bb7db8493456cfdb9b419109db3f672 100644 (file)
 (function($) {
 
 $.effects.puff = function(o) {
-
        return this.queue(function() {
-
-               // Create element
-               var el = $(this);
-
-               // Set options
-               var options = $.extend(true, {}, o.options);
-               var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
-               var percent = parseInt(o.options.percent,10) || 150; // Set default puff percent
-               options.fade = true; // It's not a puff if it doesn't fade! :)
-               var original = {height: el.height(), width: el.width()}; // Save original
-
-               // Adjust
-               var factor = percent / 100;
-               el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor};
-
-               // Animation
-               options.from = el.from;
-               options.percent = (mode == 'hide') ? percent : 100;
-               options.mode = mode;
-
-               // Animate
-               el.effect('scale', options, o.duration, o.callback);
-               el.dequeue();
+               var elem = $(this),
+                       mode = $.effects.setMode(elem, o.options.mode || 'hide'),
+                       percent = parseInt(o.options.percent, 10) || 150,
+                       factor = percent / 100,
+                       original = { height: elem.height(), width: elem.width() };
+
+               $.extend(o.options, {
+                       fade: true,
+                       mode: mode,
+                       percent: mode == 'hide' ? percent : 100,
+                       from: mode == 'hide'
+                               ? original
+                               : {
+                                       height: original.height * factor,
+                                       width: original.width * factor
+                               }
+               });
+
+               elem.effect('scale', o.options, o.duration, o.callback);
+               elem.dequeue();
        });
-
 };
 
 $.effects.scale = function(o) {