gardni
gardni

Reputation: 1424

fullpage.js moveTo() function

I'm trying to use the moveTo() function in fullpage.js that allows me to navigate to a particular section/slide, which looks like this:

/*Scrolling to the section with the anchor link `firstSlide` and to the 2nd Slide */
$.fn.fullpage.moveTo('firstSlide', 2);

I'm trying to use this within the afterSlideLoad() function, in an attempt to automatically cycle through the slides. my code looks like this:

 $.fn.fullpage({
     anchors: ['home', 'gallery'],
     afterSlideLoad: function(anchorLink, index, slideAnchor, slideIndex) {
         if (anchorLink == 'gallery') {
             if (slideIndex == 11) {
                  setTimeout(function() {
                      moveTo(2,0);
                  }, 1000);
             } else {
                  setTimeout(function() {
                      moveTo(2, slideIndex + 1);
                  }, 1000);
             }
         }
     });

Which doesn't appear to do anything, I've also tried moveTo('gallery', 1);

any suggestions with where I am going wrong?

Upvotes: 1

Views: 9347

Answers (1)

Alvaro
Alvaro

Reputation: 41595

As specified in the documentation you are linking, the function must be called like this:

$.fn.fullpage.moveTo('firstSlide', 2);

And not like you are doing it:

moveTo('firstSlide', 2);

Live demo

Upvotes: 2

Related Questions