[英]Slide Up / Slide Down
I have a slide up and slide down effect on two of my pages, the problem is once the About slide is up, if I click on the contact link, it flashes to the contact page before sliding down. 我在两个页面上都有向上和向下滑动的效果,问题是一旦“关于”幻灯片打开,如果我单击联系人链接,它会闪烁到联系人页面,然后向下滑动。 For some reason the jquery of both slides are formatted the same, but it doesn't seem to happen if i click the about link when the contact slide is up. 由于某些原因,两张幻灯片的jquery格式都相同,但是如果我在联系幻灯片打开时单击“关于”链接,似乎不会发生。 I am not sure what the problem is, I was hoping you guys could help me fix it. 我不确定是什么问题,我希望你们能帮助我解决问题。
I uploaded it to my host so you guys could see it for yourself. 我将其上传到我的主机,以便大家可以自己查看。 http://maximsiebert.com/unamed/Untitled-1.html http://maximsiebert.com/unamed/Untitled-1.html
Here is my jQuery 这是我的jQuery
$(document).ready(function() {
$('.contact').click(function () {
if ($('#aboutpage').is(":visible")) {
$('#aboutpage').slideUp(800)
$('#portfolio').slideDown(800)
$('#portfolio').slideUp(800)
$('#contactpage').slideDown(800)
}
else if ($('#contactpage').is(":visible")) {
$('#contactpage').slideUp(1000)
$('#portfolio').slideDown(1000)
}
else if ($('#contactpage').is(":hidden")) {
$('#portfolio').slideUp(1000)
$('#contactpage').slideDown(1000)
$('html, body').animate({scrollTop:0}, 'slow');
}
});
}); });
$(document).ready(function() {
$('.about').click(function () {
if ($('#contactpage').is(":visible")) {
$('#contactpage').slideUp(800)
$('#portfolio').slideDown(800)
$('#portfolio').slideUp(800)
$('#aboutpage').slideDown(800)
}
else if ($('#aboutpage').is(":visible")) {
$('#aboutpage').slideUp(1000)
$('#portfolio').slideDown(1000)
}
else if ($('#aboutpage').is(":hidden")) {
$('#portfolio').slideUp(1000)
$('#aboutpage').slideDown(1000)
$('html, body').animate({scrollTop:0}, 'slow');
}
});
}); });
Generally you should wait the shown page to slideDown and after that to slideUp the new page. 通常,您应该等待显示的页面下滑,然后再滑动新页面。
So you should use the following approach: 因此,您应该使用以下方法:
$('.about').click(function () {
.... if contact page is shown ...
$('#aboutpage').slideDown(800, function() {
$('#aboutpage').slideUp(800);
});
.....
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.