CSS-Tricks / AnythingSlider

A jQuery Slider plugin for anything.
http://css-tricks.github.io/AnythingSlider/
GNU Lesser General Public License v3.0
1.15k stars 380 forks source link

AnythingSlider navigation links #555

Closed gvost closed 9 years ago

gvost commented 11 years ago

Hey is there a way to make the links for the slide you are on become hidden when you reach the last slide?

I have narrowed it down to this piece of code...

base.slideControls = function(toggle){
            var dir = (toggle) ? 'fadeOut' : 'fadeOut',
                t1 = (toggle) ? 0 : o.animationTime,
                t2 = (toggle) ? o.animationTime : 0,
                op = (toggle) ? 1 : 0,
                sign = (toggle) ? 0 : 1; // 0 = visible, 1 = hidden
            if (o.toggleControls) {
                base.$controls.stop(true,true).delay(t1)[dir](o.animationTime/1).delay(t2);
            }
            if (o.buildArrows && o.toggleArrows) {
                if (!base.hovered && base.playing) { sign = 1; op = 0; } // don't animate arrows during slideshow
                base.$forward.stop(true,true).delay(t1).animate({ right: base.arrowRight + (sign * base.arrowWidth), opacity: op }, o.animationTime/2);
                base.$back.stop(true,true).delay(t1).animate({ left: base.arrowLeft + (sign * base.arrowWidth), opacity: op }, o.animationTime/2);
            }
        };

but I am hitting a wall, what happens now is the navigation appears on load, but it immediately fades out. Thanks in advance for any help!

Mottie commented 11 years ago

Sorry which links are you referring to? The navigation tab links? The navigation arrows?

The code you shared above is actually the code to toggle the navigation and arrows when you hover over the slider. It has nothing to do with the last slide.

gvost commented 11 years ago

the navigation tab links, that makes sense why it's not doing anything when i make changes to it. haha.

Mottie commented 11 years ago

I'm still not 100% sure what you want, but here is a demo that hides all of the navigation links when the slider is on the last page.

$('#slider').anythingSlider({
    infiniteSlides: false,
    stopAtEnd: true,
    onSlideComplete: function(slider) {
        slider.$nav.toggle(slider.currentPage !== slider.pages);
    }
});