On Jan 21, 1:39 am, Daniel Friesen <[email protected]> wrote:
> Then what do you think of the proposal of allowing an object style input
> to .show, .hide, and .toggle?
> The simple animation could be given a name, slideUp and the other
> existing animations could be turned into calls to .show({animate:...});
> etc, ... And basically the different types of showing or hiding
> something could be made into something extensible:
>
> $('#foo').show(); // Plain display set as current.
> $('#foo').show('slow'); // Default animation using slow speed.
> $('#foo').show({animate:'fade'}); // Show using a fade animation at
> default speed.
> $('#foo').show({animate:'slidedown', speed:'fast'}); // Show using a
> slidedown animation
> $('#foo').show({animate:function() {...}); // show using a custom
> animation. (Not quite the same as using .animate; using it though .show
> makes sure that the kind of cleanups and bug tweaks that .show and .hide
> use are applied so the custom function doesn't need to)

Why complicate? That's way too much repetition. It's already happening
in the opposite direction, hide/show() makes calls to animate().
Everything you want is already available
$('#foo').show() // display
    .show('slow') // animated fade/resize
    .fadeIn() // ...
    .slideDown('fast') // ...

You have to loosen your current js mindset to work with jQuery. It's
made to be extensible, so you could well write your 'partingSea' as a
plugin (as it involves dealing with ancestors and descendants it's not
a simple element animation) without any trouble.

$('#foo').partSea('show');
or
$('#foo').myAnimationHandler('partingSea','show');

As Brandon Aaron mentioned, take a look at jQuery UI, it has many
other animation effects, and it also allows you to extend the effects
in a similar fashion to what you posted.

http://code.google.com/p/jquery-ui/source/browse/trunk/ui/effects.blind.js

cheers,
- ricardo



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to