2016-07-05 89 views
0

我正在使用fullPage.js創建網站並且出於設計目的,我只想在滾動時顯示導航。我試過這個FullPage.js:滾動時只顯示導航

$(document).ready(function() { 
      $('#fullpage').fullpage({ 
       //navigation 
       menu: '#menu',    
       navigation: window.addEventListener("scroll", function(){return true}), 
       navigationPosition: 'right', 
       scrollBar: true, 
      }); 
     }); 

但它不起作用。

+0

呃,'addEventListener'需要*功能*。 – gcampbell

+0

navigation:window.addEventListener(「scroll」,function(){return true})是這樣嗎?謝謝,但仍然沒有運氣,我會更新我的問題 – Bossan

+1

添加到gcampbell,fullPage.js自帶beforeMove和afterMove方法,因此您可以像beforeMove一樣使用:function(){nav.style.display ='';},afterMove :function(nav.style.display ='none'} – Shiv

回答

1

基於從@gcampbell此幫助工作對我來說

var nav = document.querySelector('#fp-nav'); 
     nav.style.display = 'none'; 
     document.addEventListener('scroll', function() { 
      nav.style.display = 'inline'; 
      setTimeout(function(){ nav.style.display = 'none'}, 1000); 
     }); 
    });