在我的代码中遇到了一些小问题。我已经写出了一个JQUERY序列,您可以在其中单击“注册”,然后在窗体显示其自身的位置向下滚动。现在我在底部有一个按钮,功能关闭窗体并将您滚动回顶部。Jquery“scrollTop”&“height”.click delay issues
的例子可以在这里看到:http://www.icecable.com/sandbox/priority%5Fsign%5Fup/test.html
点击“注册”和动画工作正常。点击“关闭并返回顶部”,动画再次正常工作。 问题出现在此之后。
如果您尝试单击“立即注册”按钮,“高度”动画将像平常一样开始,但“scrollTop”动画没有明显的原因会有大的延迟。
这里是我的代码
$(document).ready(function() {
$('.dealer').click(function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: '860'
}, 1800, "easeInOutQuint");
});
$('.top').click(function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: '0px'
}, 1500, "easeInOutQuint");
});
$('.dealer').click(function(e) {
e.preventDefault();
$('#priority').animate({
height: 'show'
}, 1200, "easeInOutCirc");
});
$('.top').click(function(e) {
e.preventDefault();
$('#priority')
.animate({
height: 'hide'
}, 590, "easeInQuint");
});
//Form for Distributors
$('.distributor').click(function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: '860'
}, 1800, "easeInOutQuint");
});
$('.top').click(function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: '0px'
}, 1500, "easeInOutQuint");
});
$('.distributor').click(function(e) {
e.preventDefault();
$('#distributor').animate({
height: 'show'
}, 1200, "easeInOutCirc");
});
$('.top').click(function(e) {
e.preventDefault();
$('#distributor')
.animate({
height: 'hide'
}, 590, "easeInQuint");
});
});
什么我做错了吗?表单被隐藏后,是否有办法重置事件?任何帮助/见解/资源将不胜感激!
请问
非常感谢回应!我尝试编辑顶部的位置值,但我仍然得到延迟。我不知道如何调用位置值,因为它在控制台日志中滚动。所以我不认为它会进入头寸的负数,但它可能会按照您的建议通过原始数字。我无法弄清楚如何看待这一点。再次感谢。 – CabralMedia 2013-03-21 21:06:06
我不相信你可以在滚动过程中显示位置(我可能会误会 - 我不记得),但只要你可以在滚动开始之前检查并停止之后,你应该能够得到一些好的数据。 – 2013-03-22 12:23:30