简体   繁体   中英

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');
        }
      }
    });

  });

HTML 不是物理标签,因此它没有宽度。

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

  1. "slideDown", "slideUp" or "slideToggle" Duration time should be lower than or equal 200
  2. Use reBuild() after complete animation

Example:

    $( "#clickme" ).click(function() {
      $( "#book" ).slideDown( 150, function() {
        fullpage_api.reBuild();
      });
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM