0

So slider moves to right side till 5th slide (the last slide), after fifth slide, it automatically moves to the left side to first slide. Is there any chance to make it slide it to right side not rewind back? Here's code -

function scrollToRight() {
    if (global_current_elem == 5) {elem = 1;}
    else {elem = global_current_elem + 1;}
    jQuery('#slider_element').scrollTo('#element'+elem, 500, {easing:'easeInOutCubic', axis:'x' });
    set_active_btn(elem);
    global_current_elem = elem;
}

function scrollToLeft() {
    if (global_current_elem == 1) {elem = 5;}
    else {elem = global_current_elem - 1;}
    jQuery('#slider_element').scrollTo('#element'+elem, 500, {easing:'easeInOutCubic', axis:'x' });
    set_active_btn(elem);
    global_current_elem = elem; 
}

1 Answer 1

0

Your code in scrollToRight is clearly written to do that in the first line -

if (global_current_elem == 5) {elem = 1;}

Remove that line if you don't want the rewind behavior.

2
  • Yeah, but then it just won't move to first slide. I need script to move to first slide, just in the same direction, like it moved forward. from 1 - 5 slide its moving to the right side, after 5th slide i need to move from 5 to 1 to the right side too, but it rewinds bakc to the first slide, with scrolltoleft function, but i need with scrolltoright. Y2OK
    – Y2ok
    Oct 17, 2011 at 11:01
  • Hmm, the .toSlide doesn't support that, so you could look into alternatives like the jCarousel circular scroll
    – ankit
    Oct 17, 2011 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.