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 treatmens as they appear and disappear.
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:
1 | YAHOO.example.container.overlay1 = |
2 | new YAHOO.widget.Overlay("overlay1", { xy:[150,100], |
3 | visible:false, |
4 | zIndex:1000, |
5 | width:"300px", |
6 | effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} } ); |
view plain | print | ? |
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":
1 | YAHOO.example.container.overlay2 = |
2 | new YAHOO.widget.Overlay("overlay2", { xy:[250,200], |
3 | visible:false, |
4 | zIndex:1000, |
5 | width:"300px", |
6 | effect:{effect:YAHOO.widget.ContainerEffect.SLIDE,duration:0.25} } ); |
view plain | print | ? |
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:
1 | YAHOO.example.container.overlay3 = |
2 | new YAHOO.widget.Overlay("overlay3", { xy:[350,300], |
3 | visible:false, |
4 | zIndex:1000, |
5 | width:"300px", |
6 | effect:[{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5}, |
7 | {effect:YAHOO.widget.ContainerEffect.SLIDE,duration:0.5}] } ); |
view plain | print | ? |
INFO1887ms (+0) 8:07:46 AM:Config
setProperty: zindex=1000
INFO1887ms (+0) 8:07:46 AM:Config
Firing Config event: zindex=1000
INFO1887ms (+0) 8:07:46 AM:Config
Firing Config event: iframe=false
INFO1887ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, width=300px, fixedcenter=false, effect=[object Object],[object Object], visible=false, x=350, y=100, iframe=false, zindex=1000,
INFO1887ms (+0) 8:07:46 AM:Config
queueProperty: iframe=undefined
INFO1887ms (+1) 8:07:46 AM:Config
setProperty: xy=350,100
INFO1886ms (+0) 8:07:46 AM:Config
setProperty: y=100
INFO1886ms (+0) 8:07:46 AM:Config
setProperty: x=350
INFO1886ms (+0) 8:07:46 AM:Config
Firing Config event: y=100
INFO1886ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, width=300px, fixedcenter=false, effect=[object Object],[object Object], visible=false, x=350, y=100, iframe=false, zindex=1000,
INFO1886ms (+0) 8:07:46 AM:Config
queueProperty: iframe=undefined
INFO1886ms (+0) 8:07:46 AM:Config
setProperty: xy=350,100
INFO1886ms (+0) 8:07:46 AM:Config
setProperty: y=100
INFO1886ms (+0) 8:07:46 AM:Config
setProperty: x=350
INFO1886ms (+1) 8:07:46 AM:Config
Firing Config event: x=350
INFO1885ms (+0) 8:07:46 AM:Config
Firing Config event: visible=false
INFO1885ms (+0) 8:07:46 AM:Config
Firing Config event: effect=[object Object],[object Object]
INFO1885ms (+0) 8:07:46 AM:Config
Firing Config event: fixedcenter=false
INFO1885ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, width=300px, fixedcenter=false, effect=[object Object],[object Object], visible=false, x=350, y=100, iframe=false, zindex=1000,
INFO1885ms (+10) 8:07:46 AM:Config
queueProperty: iframe=undefined
INFO1875ms (+0) 8:07:46 AM:Config
Firing Config event: width=300px
INFO1875ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, width=300px, fixedcenter=false, effect=[object Object],[object Object], visible=false, x=350, y=100, iframe=false, zindex=1000,
INFO1875ms (+1) 8:07:46 AM:Config
queueProperty: iframe=undefined
IFRA1874ms (+0) 8:07:46 AM:global
xy: 350,100
INFO1874ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, width=300px, fixedcenter=false, zindex=1000, effect=[object Object],[object Object], visible=false, x=350, y=100, iframe=false,
INFO1874ms (+0) 8:07:46 AM:Config
queueProperty: y=100
INFO1874ms (+0) 8:07:46 AM:Config
setProperty: y=100
INFO1874ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, width=300px, fixedcenter=false, zindex=1000, effect=[object Object],[object Object], visible=false, x=350, iframe=false,
INFO1874ms (+0) 8:07:46 AM:Config
queueProperty: x=350
INFO1874ms (+1) 8:07:46 AM:Config
setProperty: x=350
INFO1873ms (+0) 8:07:46 AM:Config
Firing Config event: xy=350,100
INFO1873ms (+0) 8:07:46 AM:Config
Firing Config event: constraintoviewport=false
INFO1873ms (+0) 8:07:46 AM:Config
Firing Config event: appendtodocumentbody=false
INFO1873ms (+0) 8:07:46 AM:Config
Firing Config event: monitorresize=true
INFO1873ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, width=300px, fixedcenter=false, iframe=false, zindex=1000, effect=[object Object],[object Object], visible=false,
INFO1873ms (+0) 8:07:46 AM:Config
queueProperty: effect=[object Object],[object Object]
INFO1873ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, visible=false, width=300px, fixedcenter=false, iframe=false, zindex=1000,
INFO1873ms (+0) 8:07:46 AM:Config
queueProperty: zindex=1000
INFO1873ms (+1) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, zindex=null, xy=350,100, visible=false, width=300px, fixedcenter=false, iframe=false,
INFO1872ms (+0) 8:07:46 AM:Config
queueProperty: width=300px
INFO1872ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, constraintoviewport=false, zindex=null, xy=350,100, iframe=false, visible=false,
INFO1872ms (+0) 8:07:46 AM:Config
queueProperty: visible=false
INFO1872ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, constraintoviewport=false, zindex=null, xy=350,100, iframe=false,
INFO1872ms (+1) 8:07:46 AM:Config
queueProperty: xy=350,100
INFO1871ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, constraintoviewport=false, iframe=false, zindex=null,
INFO1871ms (+0) 8:07:46 AM:Config
queueProperty: iframe=false
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: iframe=false
INFO1871ms (+0) 8:07:46 AM:Config
Added property: iframe
INFO1871ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, zindex=null, constraintoviewport=false,
INFO1871ms (+0) 8:07:46 AM:Config
queueProperty: constraintoviewport=false
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: constraintoviewport=false
INFO1871ms (+0) 8:07:46 AM:Config
Added property: constraintoviewport
INFO1871ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, zindex=null,
INFO1871ms (+0) 8:07:46 AM:Config
queueProperty: zindex=null
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: zindex=null
INFO1871ms (+0) 8:07:46 AM:Config
Added property: zindex
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: height=undefined
INFO1871ms (+0) 8:07:46 AM:Config
Added property: height
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: width=undefined
INFO1871ms (+0) 8:07:46 AM:Config
Added property: width
INFO1871ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true,
INFO1871ms (+0) 8:07:46 AM:Config
queueProperty: fixedcenter=false
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: fixedcenter=false
INFO1871ms (+0) 8:07:46 AM:Config
Added property: fixedcenter
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: context=undefined
INFO1871ms (+0) 8:07:46 AM:Config
Added property: context
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: xy=undefined
INFO1871ms (+0) 8:07:46 AM:Config
Added property: xy
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: y=undefined
INFO1871ms (+0) 8:07:46 AM:Config
Added property: y
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: x=undefined
INFO1871ms (+0) 8:07:46 AM:Config
Added property: x
INFO1871ms (+0) 8:07:46 AM:Config
Config event queue: visible=true, monitorresize=true, appendtodocumentbody=false,
INFO1871ms (+0) 8:07:46 AM:Config
queueProperty: appendtodocumentbody=false
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: appendtodocumentbody=false
INFO1871ms (+0) 8:07:46 AM:Config
Added property: appendtodocumentbody
INFO1871ms (+0) 8:07:46 AM:Config
Config event queue: visible=true, monitorresize=true,
INFO1871ms (+0) 8:07:46 AM:Config
queueProperty: monitorresize=true
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: monitorresize=true
INFO1871ms (+0) 8:07:46 AM:Config
Added property: monitorresize
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: effect=undefined
INFO1871ms (+0) 8:07:46 AM:Config
Added property: effect
INFO1871ms (+0) 8:07:46 AM:Config
Config event queue: visible=true,
INFO1871ms (+0) 8:07:46 AM:Config
queueProperty: visible=true
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: visible=true
INFO1871ms (+0) 8:07:46 AM:Config
Added property: visible
INFO1871ms (+0) 8:07:46 AM:Config
setProperty: zindex=1000
INFO1871ms (+0) 8:07:46 AM:Config
Firing Config event: zindex=1000
INFO1871ms (+0) 8:07:46 AM:Config
Firing Config event: iframe=false
INFO1871ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, width=300px, fixedcenter=false, effect=[object Object], visible=false, x=350, y=100, iframe=false, zindex=1000,
INFO1871ms (+0) 8:07:46 AM:Config
queueProperty: iframe=undefined
INFO1871ms (+1) 8:07:46 AM:Config
setProperty: xy=350,100
INFO1870ms (+0) 8:07:46 AM:Config
setProperty: y=100
INFO1870ms (+0) 8:07:46 AM:Config
setProperty: x=350
INFO1870ms (+0) 8:07:46 AM:Config
Firing Config event: y=100
INFO1870ms (+0) 8:07:46 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, xy=350,100, width=300px, fixedcenter=false, effect=[object Object], visible=false, x=350, y=100, iframe=false, zindex=1000,
INFO1870ms (+0) 8:07:46 AM:Config
queueProperty: iframe=undefined
INFO1870ms (+0) 8:07:46 AM:Config
setProperty: xy=350,100
INFO1870ms (+0) 8:07:46 AM:Config
setProperty: y=100
INFO1870ms (+1870) 8:07:46 AM:Config
setProperty: x=350
INFO0ms (+0) 8:07:44 AM:global
Logger initialized
Note: You are viewing this example in debug mode with logging enabled. This can significantly slow performance.
Copyright © 2008 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings