2015-02-23 104 views
0

我正在使用两个jQuery插件fullpage和ferromenu。初始化/未初始化一个jQuery插件页更改

fullpage使窗口滚动整个页面,ferromenu是一个整齐的圆形菜单,可以扩展和折叠。

的问题是,由于全页让我的整个网站的一个页面,ferromenu每一个页面上显示,所以我不希望只是用$(文件)进行初始化。就绪

这是我试过,但我现在的问题是,当页面改变从网址远

$(window).on('hashchange', function(e){ 

var pageURL = $(location).attr("href"); 

if (pageURL === "https://www.example.com/index.php#thirdPage") { 
    $("#custom-nav").ferroMenu({ 
      position : "center-center" 
    }); 
}; 

}); 

回答

1

你应该使用fullPage.js如onLeaveafterLoad提供的回调:

$(document).ready(function() { 
    $("#custom-nav").ferroMenu({ 
     position: "center-center" 
    }); 

    $('#fullpage').fullpage({ 
     anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'], 

     onLeave: function (index, nextIndex, direction) { 
      //going to section 3 ? 
      if (nextIndex == 3) { 
       $('.ferromenu-controller').show(); 
      } else { 
       $('.ferromenu-controller').hide(); 
      } 

     } 
    }); 
}); 

甚至通过使用fullpage.js加入到体内的CSS3类,如this tutorial详细。

0

我不知道这是否是做的最好的方式,但我发现类为它不会消失它创建的html对象,只是改变了我的if语句的else部分中的显示属性。

$(window).on('hashchange', function(e){ 

var pageURL = $(location).attr("href"); 

if (pageURL === "https://www.example.com/index.php#thirdPage") { 
    $("#custom-nav").ferroMenu({ 
      position : "center-center" 
    }); 
} else { 
    $('.ferromenu-controller').css('display', 'none'); 
}; 

});