1
最近在個人網站上工作,並使用jQuery ScrollTop來動畫我的內容div。但我遇到了一個問題。ScrollTop奇怪的填充
1:沒有在每一個參與
第二頂奇怪的填充:滾動並不一致,即。它不會每次都滾動相同的高度。
您可以在這裏看到的頁面:http://mnpwr.dk/v2/index.html
- 我加了一個紅色邊框,所以它會更容易看到問題。
jQuery的:
jQuery.noConflict();
jQuery(document).ready(function() {
getHash();
});
// Keep track of our current state
currentSection = 1;
function getHash() {
jQuery('.scroll').on('click', function() {
// Get our new state
var gethash = jQuery(this).attr('class').split(' ')[0];
// Calculate the difference, with element height of 500px using formular dest = (newPows - currentPos) * elmHeight
var scrollTop = (gethash - currentSection) * 500
jQuery('#contentDiv').animate({
scrollTop: scrollTop
}, 500);
return false;
});
}
謝謝,無法相信我錯過了。這隻能回答我的一個問題。它似乎仍然不會每次都滾動相同的長度。他們滾動你的菜單進一步下降。 – 2013-02-08 12:46:29
@Köd我在我的回答中解釋了你的第二個問題。 – 2013-02-08 12:57:33
事實上,利潤率決定了一切,邊界只是爲了顯示問題;)現在一切都很好,謝謝!只是想知道,你會如何建議使用.offset(),我可能會再次使用它。 – 2013-02-08 13:06:56