Search code examples
javascriptslidedownfullpage.js

SlideDown doesn't work with fullPage.js


guys. I got an headache trying to understand, how to fix it, but I don't know JavaScript at all. So, please, help me with it. The trouble is, that ScrollDown (maybe and Up) doesn't work, when fullPage.js enabled. See codes.

SlideDown:

    jQuery(document).ready(function(e){
// -- menu ---\
$(window).scroll(function () {
  var html = document.documentElement;
       // $(".blockMenu").css("top",$(document).scrollTop())
       if($('html').width()>1000){
         if($(document).scrollTop()>=200){
          $('.hedMenu').slideUp()
          $('.hedMenu2').slideDown()
        }
        else{
          $('.hedMenu2').slideUp()
          $('.hedMenu').slideDown()
        }
      }
    })
})

fullPage:

 $(document).ready(function() {
    $('#fullpage').fullpage({
     sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE', 'whitesmoke', '#ccddff'],
     anchors: ['firstPage', 'secondPage', '3rdPage', '4thpage', 'lastPage'],
     menu: '#menu',
     afterLoad: function(anchorLink, index){

        //section 2
        if(index == 2){
          //moving the image
          $('#section1').find('img').delay(500).animate({
           left: '0%'
         }, 1500, 'easeOutExpo');

          $('#section1').find('p').first().fadeIn(1800, function(){
           $('#section1').find('p').last().fadeIn(1800);
         });;

        }

       //section 3
       if(anchorLink == '3rdPage'){
          //moving the image
          $('#section2').find('.intro').delay(500).animate({
           left: '0%'
         }, 1500, 'easeOutExpo');
        }
      }
    });

  });

Solution

  • if($(document).scrollTop()>=200){ won't work in your code as detailed in fullPage.js FAQ:

    fullPage.js doesn't actually scroll the site but it changes the top or translate3d property of the site. Only when using the fullPage.js option scrollBar:true or autoScrolling:false it will actually scroll the site in a way it is accessible for the scrollTop property.

    That's why you should make use of callbacks, or use the scrollBar:true option of fullPage.js