From f505d5a230472d5bfd2c188d40ac1726f593906b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 15 Jun 2009 02:21:44 +0000 Subject: [PATCH] Refactored puff effect. --- ui/effects.scale.js | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/ui/effects.scale.js b/ui/effects.scale.js index 79912791a..3a2023537 100644 --- a/ui/effects.scale.js +++ b/ui/effects.scale.js @@ -13,33 +13,28 @@ (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) { -- 2.39.5