我正在尝试关闭/打开导航像水平滚动上的推拉门。滚动关闭/打开导航像推拉门
问题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();
})
感谢您的帮助。
非常感谢!前两个代码块完美地工作(并且看起来很干净)。我知道重复这样的代码似乎是错误的,但我只知道使用var不写函数来简化工作,所以我很感激你给我看。 – Gmodal
随着你发布的最后一块代码: 我想要做的是.nav-line-top和.nav-line-bottom向下/向上移动并在屏幕中心(垂直)以便它们作为小视觉来提醒观看者,如果需要,他们可以将鼠标悬停在此上方以显示导航。 它几乎可行,它只是不垂直居中任何想法? http://jsfiddle.net/gmodal/vHcr8/9/ – Gmodal
我很高兴你能学到一些东西。我认为你仍然需要获得关于CSS的一些基本知识 - 定位是必须的。 它并不居中,因为它只停留在放置它的位置,底线只是因为它被上面的内容“推”下来(它的高度由jQuery的动画改变了)。动画一个元素比三个更容易(http://jsfiddle.net/wnc6h/)。附:请记住按下旁边的箭头旁边的文章是有帮助的 - 它会增加作者的声誉 - 这比说“谢谢”更好;) –