これがバグなのか、それとも書き方なのかはわかりませんが、どんな助けでも素晴らしいです!!
他のプロジェクトで使用した Ben Alman の jQuery hashchange イベントを使用しています
フェードトアニメーションを使用したハッシュイベントで、問題はありませんでした。ここにこのファイルがあるので、1 ページの
サイトと scrollTop 関数の使用。戻るボタンは機能しますが、一度しか機能しません。
進むボタンがまったく機能せず、前後にジャンプしますが、アニメーションしません。以下であり
私が現在持っているもの。
CSS:
<nav id="primary">
<ul>
<li>
<a href="#home">home</a>
</li>
<li>
<a href="#about">about</a>
</li>
<li>
<a href="#services">services</a>
</li>
<li>
<a href="#contact">contact</a>
</li>
</ul>
</nav>
<div id="content">
<article id="home">home</article>
<article id="about">about</article>
<article id="services">services</article>
<article id="contact">contact</article>
</div>
Jクエリ:
var href = '';
var easeDuration = 1000;
var easeType = "easeOutExpo";
//Thumbanil click states/////
$('#primary ul').delegate('li', 'click', function (e) {
e.preventDefault();
var index = $(this).prevAll().length;
href = $('#primary ul li a:eq(' + index + ')').attr('href');
$('html, body').animate({scrollTop: $(href).offset().top},{easing: easeType,duration: easeDuration,complete: function() {
window.location.hash = href;
return false;
}});
});
$(window).bind('hashchange', function(e){
e.preventDefault();
var newHash = window.location.hash.substring(1);
$('html, body').animate({scrollTop: $("#"+newHash).offset().top}, {easing: easeType,duration: easeDuration,complete: function() {
return false;}});
});
$(window).trigger('hashchange');