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.
You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.
Note: You are viewing this example in debug mode with logging enabled. This can significantly slow performance.
Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings