treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Anything Slider startstoppend if one slide only?

  • Hey Guys

    As I write in the subject how can I make the "Anything Slider" have startstopped set to true if there is only one slide in the slider!
    I have tried to test for length but it don't seem to work.

    Here's what I tried.

    var slideLength = $j('#top-image-wrap ul').find('> li').length;

    if ( slideLength >= 3 ) {

    $j('#top-image').anythingSlider({
    easing: \"easeInOutExpo\",
    autoPlay: true,
    startStopped: true,
    delay: 5000,
    ...
    navigationFormatter: null
    });

    } else {

    $j('#top-image').anythingSlider({
    easing: \"easeInOutExpo\",
    autoPlay: true,
    startStopped: false,
    delay: 5000,
    ...
    navigationFormatter: null
    });

    }


    When I type
    $j('#top-image-wrap ul').find('> li').length;

    in consul in firebug it returns 3. And that make sence since there is one original and 2 clones.

    I always mix up the > < but I have tried the different combinations and noting seems to work. I'm sure it's a really simple problem but I just cant make it work.

    Hope you can help.

    Mads
  • Solved it:

    The length test don't include the clones so the >= 3 should be a != 1 and then it works.

    Mads