1

I'm trying to create a dependent caption display from within the Cycle call:

$('#slideshow-images').cycle({
        fx: 'scrollVert',
        pager:  '#slideshow-navigation',
        activePagerClass: 'active',
        timeout: 8000,
        delay: 2000,
        manualTrump:false,
        before: captionProgress
});

function captionProgress(currSlideElement, nextSlideElement, options, forwardFlag) {
     var arr = $('.slideshow-caption');
     // need to do something here but don't know what...
}

So that before the new image slides in - the caption changes - caption has the same index as the image, but I don't quite know how to trigger the right caption.

Here's the structure of the slideshow:

<div id="slideshow-captions"> 
    <div class="slideshow-caption active">
        <h2>Heading 1</h2>
        <h1>Consulting<br />
        Services</h1>
    </div>
    <div class="slideshow-caption">
        <h2>Heading 2</h2>
        <h1>Consulting<br />
        Services</h1>
    </div>
    <div class="slideshow-caption">
        <h2>Heading 3</h2>
        <h1>Consulting<br />
        Services</h1>
    </div>
</div>

<div id="slideshow-images"> 
    <div class="slideshow-image">
        <h1 class="heading">Gallery image</h1>
        <img src="/images/header/01.jpg" alt="" width="620" height="304" />     
    </div>
    <div class="slideshow-image">
        <h1 class="heading">Gallery image</h1>
        <img src="/images/header/02.jpg" alt="" width="620" height="304" />             
    </div>
    <div class="slideshow-image">
        <h1 class="heading">Gallery image</h1>
        <img src="/images/header/03.jpg" alt="" width="620" height="304" />         
    </div>
</div>

Any idea how to achieve it?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
user398341
  • 6,339
  • 17
  • 57
  • 75

1 Answers1

2
arr.eq(currSlideElement).show();

Or if you have 'active' class to control visibility

arr.find('.active').removeClass('active');   
arr.eq(currSlideElement).addClass('active');

I don't know if this would work too:

arr.eq(currSlideElement).removeClass('active');   
arr.eq(nextSlideElement).addClass('active');

I suppose this last snippet is the most suitable.

corbacho
  • 8,762
  • 1
  • 26
  • 23