YUI recommends YUI3.

YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.

This documentation is no longer maintained.

YUI Library Examples: Container Family: Using ContainerEffect Transitions

Container Family: Using ContainerEffect Transitions

The Container Family of controls, including Overlay and all of its subclasses (Panel, Tooltip, Dialog, SimpleDialog), can implement built-in transition effects using the effect property and the ContainerEffect object. This example demonstrates the fade and slide transitions provided with Container.

Use the buttons below to show and hide Overlays, noting their transition treatments as they appear and disappear.

overlay1 (fade in):
overlay2 (slide in):
overlay3 (fade and slide):

Using Transition Effects via the "effect" Property and the ContainerEffect Object

The ContainerEffect class allows Overlay and its subclasses to be configured with transitional animations that are activated when an Overlay is shown or hidden. For instance, an Overlay can easily be made to fade in and out, or slide in and out of the viewport when the visibility of the Overlay is changed. The effect property takes an object literal or an array of object literals which define two fields: the predefined effect to use, and the duration of the animation.

In this tutorial, we will create three Overlays and set them up to use the effect property in different ways. First, we will create a simple Overlay that fades in and out. The built-in ContainerEffect constant used for the fade animation is YAHOO.widget.ContainerEffect.FADE, so we will specify that as the "effect" property of our object literal. The duration should be 0.25 seconds, specified by the "duration" property of the literal:

Our second Overlay shows how you can use ContainerEffect's "SLIDE" constant. This Overlay looks exactly like the first one, but we will replace "FADE" with "SLIDE":

Effects can also be specified as an array of transitions that will all execute simultaneously. For instance, an Overlay can be made to fade and slide in at the same time. When using the ContainerEffect class to configure your Overlay, chaining is not supported, so all animations will always execute at the same time. However, if you need to chain animations, the Animation utility allows you to do this using events. We will set up the third and final Overlay with an array of effects:

YUI Logger Output:

Note: Logging and debugging is currently turned off for this example.

Reload with logging
and debugging enabled.

Container Family Examples:

More Container Family Resources:

Copyright © 2013 Yahoo! Inc. All rights reserved.

Privacy Policy - Copyright Policy - Job Openings