Skip to content

Instantly share code, notes, and snippets.

@nicinabox
Created November 20, 2012 16:06
Show Gist options
  • Save nicinabox/4118841 to your computer and use it in GitHub Desktop.
Save nicinabox/4118841 to your computer and use it in GitHub Desktop.
// Augment the api with size
$.fn.superslides.api.size = $("." + $.fn.superslides.options.container_class).children().length;
$(document).on('slides.animated', function(e, current, next, prev) {
var size = $.fn.superslides.api.size;
// Fix for next bug
next = next + 1;
if (current === 0) {
console.log('first slide');
}
if (next === size) {
console.log('last slide');
}
});
@randalldon
Copy link

Great solution and thanks for taking the time. Just fyi i'm using this logic to show/hide navigation arrows as appropriate (which could be useful for others):

// Augment the api with size so we can get the number of slides
$.fn.superslides.api.size = $("." + $.fn.superslides.options.container_class).children().length;

// Logic to handle show/hide of prev/next
$(document).on('slides.animated', function(e, current, next, prev) {

    // Set up size var for length
    var size = $.fn.superslides.api.size;

    // Fix for next bug
    next = next + 1;

    // Logic for prev button
    if (current === 0) {
        $('a.prev').css("visibility","hidden");
    } else {
        $('a.prev').css("visibility","visible");
    }

    // Logic for next button
    if (next === size) {
        $('a.next').css("visibility","hidden");
    } else {
        $('a.next').css("visibility","visible");
    }

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment