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.
This example shows how you can use the events that ProgressBar fires.
The code to create the ProgressBar is:
We instantiate the ProgressBar and configure it so that the initial value is 127, which is halfway between 0 and 255. We chose this range so that the values can translate directly into color values, which we then apply to the bar. The ProgressBar uses an Animation instance which we can get and access directly to set its duration and easing method.
We are listening to the three events related to movement:
start
signals the start of the movementprogress
is fired during the movementcomplete
signals the completion of the movementWithout animation, the start
, progress
and complete
events fire one after the other in close sequence.
Our event handlers do a few simple things:
start
eventvalue
received from the progress
eventvalue
)complete
eventThe value
argument passed by all events provides the nominal value of the ProgresBar, not the size of the bar itself.
A value of 50 will always be halfway in a range of 0 to 100, whether the ProgressBar is 100 or 500 pixels wide.
We have also provided a slider to change the end values for the bar so that we can show how to respond to those events and display their values. The ProgressBar inherits the attribute change events from the Element Utility, so before and after change events are available for all configuration attributes.
The markup for the text labels are shown below. Notice the yui-pb-range
and yui-pb-caption
class names in their declaration. The ProgressBar itself does not use those class names at all, but they are defined as part of the "Sam"
skin as a convenience to the implementer.
Note: Logging and debugging is currently turned off for this example.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.
Copyright © 2013 Yahoo! Inc. All rights reserved.