【发布时间】:2013-12-20 04:37:50
【问题描述】:
我正在尝试关闭/打开导航,例如水平滚动上的滑动门。
问题 1:当您向右滚动时,导航会关闭...但是当您滚动回页面开头或到达末尾时,我无法重新打开它。导航打开但随后循环功能或快速关闭,不确定是什么原因造成的?
JS FIDDLE (SCROLL NAV OPEN/CLOSE)
// PAGE LEFT NAV
//SCROLL RIGHT HIDE NAV
$(window).scroll(function() {
if ($(this).scrollLeft() > 0)
{
$('.nav-line-top').animate({'top': 150},400);
$('.nav-line-bottom').animate({'top': 150},400);
$('.nav-serries-inner').delay(0).slideUp();
}
else
{
$('.nav-line-top').animate({'top': 0},400);
$('.nav-line-bottom').animate({'top': 0},400)
$('.nav-serries-inner').delay(0).slideDown();
}
});
// SCROLL END OF PAGE + SHOW NAV
$(window).scroll(function () {
if ($(window).scrollLeft() >= $(document).width() - $(window).width() - 40) {
$('.nav-line-top').animate({'top': 0},400);
$('.nav-line-bottom').animate({'top': 0},400);
$('.nav-serries-inner').delay(0).slideDown();
}
else
{
$('.nav-line-top').animate({'top': 150},400);
$('.nav-line-bottom').animate({'top': 150},400)
$('.nav-serries-inner').delay(0).slideUp();
}
});
问题 2:导航并没有按照我的设想完全打开和关闭。我希望线条像两个垂直移动的滑动门一样排列在一起或分开。它现在所做的是关闭、延迟线,然后它们向下移动到中心位置,它应该在一个动作中一起流动。
我想到的打开/关闭示例是这样的EXAMPLE,但垂直
nav.serries{
position:fixed;
top:56%;
left:0;
display:block;
height:400px;
width:150px;
margin: -200px 0;
padding-left:20px;
}
.nav-line{
width: 20px;
border-bottom: 1px solid #808080;
margin-bottom: 5px;
margin-top: 11px;
postion:relative;
top:0px;
left:0;
}
//HOVER SHOW NAV
$('.nav-serries-open').hover(function(){
$('.nav-line-top').animate({'top': 0},400);
$('.nav-line-bottom').animate({'top': 0},400);
$('.nav-serries-inner').delay(0).slideDown();
});
// LEAVE HOVER HIDE NAV
$('nav.serries').mouseleave(function(){
$('.nav-line-top').animate({'top': 150},400);
$('.nav-line-bottom').animate({'top': 150},400);
$('.nav-serries-inner').delay(200).slideUp();
})
感谢您的帮助。
【问题讨论】:
标签: javascript jquery css horizontal-scrolling