Download the X Distribution File.
obj = new xSequence(seq)
Default.
// xSequence r1, Copyright 2001-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xSequence(seq) // object prototype
{
// Private Properties
var ai = 0; // current action index of seq
var stop = true;
var running = false;
// Private Method
function runSeq()
{
if (stop) {
running = false;
return;
}
if (this.onslideend) this.onslideend = null; // during a slideend callback
if (ai >= seq.length) ai = 0;
var i = ai;
++ai;
if (seq[i][0] != -1) {
setTimeout(runSeq, seq[i][0]);
}
else {
if (seq[i][2] && seq[i][2][0]) seq[i][2][0].onslideend = runSeq;
}
if (seq[i][1]) {
if (seq[i][2]) seq[i][1].apply(window, seq[i][2]);
else seq[i][1]();
}
}
// Public Methods
this.run = function(si)
{
if (!running) {
if (xDef(si) && si >=0 && si < seq.length) ai = si;
stop = false;
running = true;
runSeq();
}
};
this.stop = function()
{
stop = true;
};
this.onUnload = function() // is this needed? do I have circular refs?
{ // this should already have been done above, don't think it's needed
if (!window.opera) {
for (var i=0; i<seq.length; ++i) {
if (seq[i][2] && seq[i][2][0] && seq[i][2][0].onslideend) seq[i][2][0].onslideend = runSeq;
}
}
};
}
xsequence - This demo illustrates usage.
By your use of X and/or CBE and/or any Javascript from this site you consent to the GNU LGPL - please read it. If you have any questions about the license, read the FAQ and/or come to the forums.
Forum support is available at the X Library Support Forums.
Cross-Browser.com is the home of X - a cross-browser Javascript library, and many demos, applications, articles and documentation.
If you are using X, XC or anything from this site, show off your work by posting a link in the X Showcase forum.