lukesnowden / FSVS

Full Screen Vertical Scroll
https://www.lukesnowden.co.uk/full-screen-vertical-scroll/
722 stars 145 forks source link

add a counter to slider #43

Closed lucbord closed 6 years ago

lucbord commented 6 years ago

Hi Luke, great work! I have tried to add a counter to slider with:

      var totalItems = $('.slide').length;

        var currentIndex = $('.slide').index() + 1;
            $('.num').html(''+currentIndex+'/'+totalItems+'');

        $('#fsvs-body').bind('slid', function() {
            currentIndex = $('.active-slide').index() + 1;
            $('.num').html(''+currentIndex+'/'+totalItems+'');
        });

but when jump from a slide to another the number is not updated.. Any idea or suggestion?
Thanks in advance!

lukesnowden commented 6 years ago

not sure what you are trying to achieve but just a heads up, you have a typo on this line;

$('#fsvs-body').bind('slid', function() {
lukesnowden commented 6 years ago

you can also do the following;


$.fn.fsvs({
    afterSlide: function( slideIndex ) {
        alert( slideIndex );
    }
});