Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prev button bug if visible is multiple of li's #3

Open
kevinch opened this issue Apr 4, 2013 · 4 comments
Open

Prev button bug if visible is multiple of li's #3

kevinch opened this issue Apr 4, 2013 · 4 comments

Comments

@kevinch
Copy link

kevinch commented Apr 4, 2013

I've noticed on the simple red demo and also on my current dev that if you set the 'visible' parameter to 4, for example, and put 12 items in the ul, then if you press the 'prev' button, it'll go to the end of the carousel right after the last item and show nothing. Same if you set 'visible' to 3 and display 6 or 9 items, prev goes to some white space.

@TuniLame
Copy link

Hello, I have the same problem here. Did you resolve it?

@kevinch
Copy link
Author

kevinch commented Apr 18, 2013

Yes with some css/js of my own. But i didn't change the plugin original files. For the css i just set the left arrow to a display:none. Here's the javascript (jQuery based):

var countbook = Math.ceil(($('ul.lookbook li').length)/3),
    aa = 1;

$('.lookbook .next').on('click', function(){
    aa++;
    if(aa >= 2){ $('.lookbook .prev').show(); } 
    if (aa == (countbook)) { $('.lookbook .next').hide(); }
});

$('.lookbook .prev').on('click', function(){
    aa--;
    if(aa == 1){ $('.lookbook .prev').hide(); } 
    if (aa < (countbook)) { $('.lookbook .next').show(); }
});

As you can see, i divide the number of items var the countbook variable by 3 on the first line. This is because i'm dispalying 3 images at a time in the slider. Feel free to update.

@TuniLame
Copy link

Hello,
Thanks for your asnwer, that resolved my problem :)

@kfedotov
Copy link

There's this line of code in the plugin:
if (config.current < 0)
config.current = (config.visible == 1) ? config.items - 1 : config.items - config.visible + (config.visible - (config.items % config.visible));

Changing it to the following solved it for me:
if (config.current < 0)
config.current = (config.visible == 1) ? config.items - 1 : config.items - 2 * config.visible + (config.visible - (config.items % config.visible));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants