2012-11-19 67 views
0

使用這個jQuery的:https://github.com/JamyGolden/PlusAnchorjQuery的滾動偏移量

我期待使其滾動到錨特異性,但給它一個頂部50像素的偏移。我有一個50px的固定標題,當頁面滾動時,標題覆蓋部分的一部分。

任何幫助或正確的方向點讚賞。

感謝

我的代碼:

<script type="text/javascript"> 
$(document).ready(function(){ 
$('body').plusAnchor({ 
easing: 'easeInOutExpo', 
speed: 800, 
onInit: function(base) { 
if (base.initHash != '' && $(base.initHash).length > 0) { 

window.location.hash = 'hash_' + base.initHash.substring(1); 

window.scrollTo(0, 0); 

$(window).load(function() { 

timer = setTimeout(function() { 

$(base.scrollEl).animate({ 
scrollTop: $(base.initHash).offset().top 

}, base.options.speed, base.options.easing); 
}, 500); // setTimeout 

}); // window.load 
}; // if window.location.hash 

} // onInit 
}); 
}); 
</script> 
+0

不能用越好的jQuery插件scrollTo? http://flesler.blogspot.it/2007/10/jqueryscrollto.html – sbaaaang

+0

我可以但這對我來說工作得很好,它更小。開發人員迴應我的github問題,並已解決。儘管感謝您的回覆。 – bskool

回答