View Full Version : Featured Content Slider v2.0 - Limit Cycles?

05-13-2008, 11:48 AM
1) Script Title: Featured Content Slider v2.0

2) Script URL (on DD):http://www.dynamicdrive.com/dynamicindex17/featuredcontentslider.htm

3) Describe problem:

Thank you for the new version! I would like to be able to designate how many times the content slider cycles through the content. By default, it cycles infinitely, but I would like to have the option to allow it to cycle 3 times (or x times) and stop. This question was answered for the previous version here (http://www.dynamicdrive.com/forums/showthread.php?t=19142) but of course this solution won't work with the new version. How would one implement this option in v2.0?

Thank you for your help.

05-13-2008, 06:26 PM
There may be a more elegant way to do this, but you can use the onChange function to count the number of times you reach the first slide, and to clear the auto interval when that number gets to a certain point:

id: "slider1", //id of main slider DIV
contentsource: ["inline", ""], //Valid values: ["inline", ""] or ["ajax", "path_to_file"]
toc: "#increment", //Valid values: "#increment", "markup", ["label1", "label2", etc]
nextprev: ["Previous", "Next"], //labels for "prev" and "next" links. Set to "" to hide.
enablefade: [true, 0.2], //[true/false, fadedegree]
autorotate: [true, 3000], //[true/false, pausetime]
onChange: function(previndex, curindex){ //event handler fired whenever script changes slide
//previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
//curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
if(typeof this.times!='number')this.times=0;
if(curindex==1) this.times++;
if(this.times>2) {clearInterval(window["fcsautorun"+this.id]);this.onChange=function(){return;};}

In the above, it will reach the first slide 3 times (including the very first time) then stop.

05-13-2008, 07:43 PM

Many thanks, that worked perfectly. (The code sample did indeed display the first slide 3 times.)