tags:

views:

29

answers:

1

This snippet runs my slideshow, which consists of a series of images. At the top of the slideshow I have "image x of y". Is it possible to add a callback that is tied to each the prev and next buttons? One callback would add 1 to the x and the other subtract.

So this is some form of pagination for which I could not find an out of the box solution with the cycle plugin.

I could obviously attach my own functions to #prev and #next but the count would still get incremented even if no other images are shown. I need to be able to detect whether or not images are being "slided" in to view.

$('#prod_list').cycle({ 
    fx:     'scrollHorz', 
    prev:   '#prev', 
    next:   '#next', 
    timeout: 0 ,
    nowrap: 1,          
});
A: 

Can't you use the prevNextClick option, as defined in the Cycle Options?

This takes a function in the following format:

function(isNext, zeroBasedSlideIndex, slideElement)

There are also several other options that can help with pagination.

  • pagerAnchorBuilder
  • allowPagerClickBubble
  • pagerEvent
  • pagerClick
  • pager
Fermin
I saw this option yes, just not sure of how to implement it? How would I detect the difference between next and prev ?
stef
(Untested) - Check the first parameter (isNext) which will tell you if it is Next (true) or Prev (false). You can also use zeroBasedSlideIndex parameter to see which element is to be transitioned too.
Fermin