Thursday, January 29, 2009

[jQuery] Re: [Cycle Plugin]

> Mike, thanks for your reply :) It's not clear to me how I would check
> on this value. Below is my new code, how would I actually code the
> "{booleanflag?!}" part?
>
> //init vars
> var initcount = 0;
> var imgcount = $('div#imgcontainer img').size();
>
> //callback function
> function onAfter()
> {
>         if({booleanflag?!})
>         {
>                 initcount++;
>                 if(initcount>imgcount) { initcount = 1; }
>         }
>         else
>         {
>                 initcount--;
>                 if(initcount<1) { initcount = imgcount; }
>         }
>
>         $('div#controls span').html(initcount+'/'+imgcount);
>
> }
>

You need to declare the function parameters that Cycle passes to your
callback:

function onAfter(currElement, nextElement, options, isForward) {
if (isForward) {
// ...
}
else {
// ...
}
}

No comments: