Cycle custom timeout for last slide

Cycle custom timeout for last slide

In the cycle plugin, if you don't want the timeout to be equal for all slides, you can write a function to calculate the timeout on a slide-by-slide basis. This function takes the basic form:

  1. function calculateTimeout(currSlide, nextSlide, options, isForward) {
  2.   var index = options.currSlide;
  3.   if (index == 0) {
  4.     return ...;
  5.   } else if (index == ...) {
  6.     return ...;
  7.   } else {
  8.     return ...;
  9.   }
  10. }
It's easy to see how to set the timeout for the first slide: Just test for index == 0. But how do you identify the last slide if you don't know how many slides are in the show?

Many thanks.