【问题标题】:FullPage.js: Only show navigation when scrollingFullPage.js:仅在滚动时显示导航
【发布时间】:2016-07-05 16:19:21
【问题描述】:

我正在使用 fullPage.js 制作一个网站,出于设计目的,我希望导航仅在滚动时显示。这个我试过了

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

但它不起作用。

【问题讨论】:

  • 呃,addEventListener 需要一个函数
  • 导航:window.addEventListener("scroll", function(){return true}) 像这样?谢谢,但仍然没有运气,我会更新我的问题
  • 在gcampbell中加入fullPage.js自带了beforeMove和afterMove方法,所以你可以像beforeMove:function(){nav.style.display = '';}, afterMove:function(nav. style.display = 'none'}
  • fullpage.js 没有“滚动显示导航”功能,因此您必须自己编写。也许像var nav = document.querySelector('nav'); nav.style.display = 'none'; document.addEventListener('scroll', _.throttle(function () { nav.style.display = '' }, 250)); 这样的东西。假设导航是一个<nav> 元素。还假设 lodash。

标签: javascript jquery fullpage.js


【解决方案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); 
        });
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-07
    • 1970-01-01
    • 2021-09-05
    • 1970-01-01
    相关资源
    最近更新 更多