在我的代碼中遇到了一些小問題。我已經寫出了一個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