Nivo Slider: How to disable prev(next) arrow on first(last) slide

Published: July 23, 2012  By: Pascal  
Writing-people-old-times-3 Writing-people-old-times-4 Writing-people-old-times-5 Writing-people-old-times-6 Writing-people-old-times-1 Writing-people-old-times-2
Whereas lots of sliders available on the web including the Nivo use to rotate pictures in a loop, in some
cases, the objective sought is to keep a linear, not looped, play mode.
Stopping the Nivo Slider on the last image is possible but the next arrow button still works and this is
obviously inconsistent within such a context. Also, when the slider starts, the previous button is
enabled, allowing the user to get the last slide directly accessible.
However, some simple solutions are there and we will see in this tutorial how to automatically hide the
unwanted arrow at the beginning and at the end of the slideshow.


The HTML

To this end, we use the very useful beforeChange option and the Nivo Slider javascript variables
currentSlide/totalSlides.
As the slider will be stopped on the last slide, we ensure ourself that going back to the penultimate slide
starts it again.
Aside from that, we need to disable the keyboard navigation feature, and, due to the technique used,
the directionnavHide is also set to false (there are likely other ways to do it, don’t hesitate to comment
in this case. Thanks).
A last requirement is to hide the previous arrow when the slider is first shown.

Lines to add in the <head> section
HTML Load Nivo Trick
Modified Nivo Slider's initializing part
HTML Load Nivo Trick
BONUS: fade Out and fade In effect when the slider rotates (Demo)

I found very interesting the idea (thanks Dragos!) of inserting an intermediate and independent effect
between two slides, fading out into the background then fading in the next image.

So, here’s a solution to achieve this (without adding slides or modifying the javascript) with a
differentiated time for the two fading steps.

Note: You must give animSpeed and delayOut variables the same value (100ms in this demo code).

Enjoy!


The HTML

Code to add in the <head> section
HTML Load Nivo Trick
Initializing part

Just add the beforeChange option line.
HTML Load Nivo Trick
• Other download
> demo CSS file
Thanks for reading and hope this helped!
> download code
> download code
> download code

susan
October 12, 2012
I have just discovered the world of nivo-slider, and it's amazing how versatile it is. Thanks for eplanning this useful tool in detail.
I have a technical question about nivo-slider and hope you can help: I would like the arrows to be in relative position from the thumbnail bar, instead of the slider-wrapper. Is it possible? I have a profolio consists of serveral projects with multiple photos. Each project is a full page slideshow with a thumbnail bar and navigation arrows left & right of the thumbnail. I would like to use the same slider code, but they have different number of photos.
I have the nivo-slider worked out with custom thumbnails and all, but I dont' know jQuery so I couldnt' figure out if this is possible at all.
your help would be much appreciated!
Pascal Gautier
Reply:
October 12, 2012
Hi Susan,

Thanks very much for your comment.

As it is specific, I've contacted you through your email.

Cheers!
Phil
May 2, 2013
Does this tutorial still work?

It doesn't work for me :(

or maybe i made something wrong.

Pascal Gautier
Reply:
May 2, 2013
Hi Phil,

Yes, even the latest version (3.2) works fine with it.
But check that the ID of the slider is correct and maybe adapt syntax (jQuery/$).

Cheers!
All the articles!
English Blog