Sequencing
Sequencing is the process of setting some action to be carried out on the members of an array. You can then step through the array, carrying out the action on each member in turn.
Required files
http://yui.yahooapis.com/2.8.0r4/build/yahoo-dom-event/yahoo-dom-event.jshttp://yui.yahooapis.com/2.8.0r4/build/selector/selector.jshttp://yoursite.com/ojay/js-class.jshttp://yoursite.com/ojay/core.js
For example, let’s say you want to rotate the source of some image on your page. You have a list of images:
var sources = [
'header-1.jpg', 'header-2.jpg',
'some-other-file.jpg', 'ad-banners.jpg'
];
and an action that can be applied to an item in the list to change the source of your image:
function(source) {
Ojay('#my-image').set({src: source});
}
You create a sequence to perform this action like so:
var seq = sources.sequence(function(source) {
Ojay('#my-image').set({src: source});
});
You can then tell the sequence to loop, pausing by some number of seconds between each member:
seq.loop(10);
You can tell the loop to pause whenever you like:
seq.pause();
or you can tell it to pause when it next reaches the end of the list:
seq.finish();
You can start the loop again by calling seq.loop().
