views:

144

answers:

1

I'm using a lightweight jQuery plugin for carousel, it works great except that it doesn't support circular carousel, i.e it'll auto-slide 1,2,3,4 and then backwards 4,3,2,1 instead of 1,2,3,4 then again jumping back to 1,2,3,4 again, which is what I want.

Here's the jsFiddle for it: http://jsfiddle.net/vLZFh/

I'd really appreciate any help.

Many thanks

+1  A: 

In function setTimer it is decided weather the carousel moves forward or backwards. In the case of forward the function move is called with 1 as value for iDirection, in the other case with value -1. In function move it's only checked if the sum of iDirection and iCurrent produces a valid value. The easiest way to get the effect you want to have is to get rid of bForward in setTimer (but you might as well just ignore that) and to modify function move to jump back to 0 if iCurrent > iSteps, like this:

function move(..) {
  iCurrent++;
  if (iCurrent >= iSteps) iCurrent = 0;
  ...
}
xor_eq
Erm...I don't think I understand, can you modify (and save) that jsfiddle? Thanks!
Nimbuz
actually I'm not sure if I didn't do that already when answering your question.
xor_eq
Saved Fiddle will not have the same URL, can you share that new url. Thanks
Nimbuz
you're lucky I got this tab still opened: http://jsfiddle.net/vLZFh/5/
xor_eq
Indeed I'm, thanks heaps! Works perfect :)
Nimbuz
Oh, there's a small problem: carousel now slides in one direction only. Clicking 'next' takes a slide further, but clicking 'back' also does the same. see: http://jsfiddle.net/vLZFh/11/
Nimbuz
I guess you could have tried this on your own, it was really not that hard: http://jsfiddle.net/vLZFh/13/
xor_eq
Then maybe you didn't notice that If left/right works fine, then the auto slide 1-2-3 <> 1-2-3 becomes 1-2-3 <> 3-2-1 again.
Nimbuz
oh, come on, did you even take a look at the code? http://jsfiddle.net/vLZFh/14/ - what I'm trying to say is: the changes I made were absolutly minor, you could have done them easily for yourself, but i doubt that you even tried.
xor_eq