Scroll below slider when the last slide is shown

The following code snippet can be used to scroll below the slider automatically when the last slide is shown.

SR7

// the speed of the scrolling transition (ms)
var scrollTime = 500;
// the amount of time before the scrolling begins (ms)
var scrollDelay = 2000;

document.addEventListener("sr.slide.afterChange", function (e) {
  if (e.id == revapi1603.id && (revapi1603.maxSlide()-1) == e.current.index) {
    setTimeout(function() {
	    SR7.F.scrollToId({id:revapi1603.id, 
                          offset:0,
                          action:"scrollunder",
                          speed:scrollTime});
    },scrollDelay);
  }
}); 

SR6

// the speed of the scrolling transition (ms)
var scrollTime = 500;
 
// the amount of time before the scrolling begins (ms)
var scrollDelay = 2000;
 
// change the "revapi1" part with your slider's ID
// https://tinyurl.com/zb6hzpc
var api = revapi1.on('revolution.slide.onchange', function(e, data) {
 
    if(data.slideIndex === api.revmaxslide()) {
 
        setTimeout(function() {
 
            var bounds = api[0].getBoundingClientRect();
            jQuery('html, body').animate({
                scrollTop: window.pageYOffset + bounds.top + bounds.height
            }, scrollTime);
 
        }, scrollDelay);
    }
}); 

Important Notice

Adjust the number “1” in the the “revapi1” part of the code for what your slider’s ID is.

Scroll below slider when the last slide is shown

The Author

KC

Strength does not come from winning. Your struggles develop your strengths. When you go through hardships and decide not to surrender, that is strength.

If you need help with anything related to our plugin, please comment on a post or email me at [email protected].

Liked this Post?
Please Share it!