jQuery cycle: custom callback?
This snippet runs my slideshow, which consists of a series of images. At the top o开发者_开发百科f 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,
});
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
Checkout the description of "onBefore" and "onAfter" under Callbacks at http://jquery.malsup.com/cycle/int2.html. Viewing source of the page, you see the full example of how to do it.
精彩评论