Results 1 to 3 of 3

Thread: Featured Content Slider v2.0 - Limit Cycles?

  1. #1
    Join Date
    May 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Featured Content Slider v2.0 - Limit Cycles?

    1) Script Title: Featured Content Slider v2.0

    2) Script URL (on DD):http://www.dynamicdrive.com/dynamici...tentslider.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 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.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    featuredcontentslider.init({
    	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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    John,

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

    Sadie

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •