私が取り組んでいるこのプロジェクトに関するいくつかの質問を投稿しましたが、これが私の最新の問題です!
ページ A にクリック イベントを設定してアンカー タグの ID をページ B に渡し、scrollTop アニメーションのマーカーとして使用できるようにします。また、下部の固定ナビゲーションに影響を与えずにページをスクロールできるように iScroll をセットアップしました。
iScroll はページ A で正常に動作し、scrollTop はページ B で正常に動作します。iScroll をページ B に追加しようとすると、scrollTop に干渉し、動作が停止します。私はデバッグを試みましたが、特に問題を引き起こしているのはラッパー div のようです。これまたは事実は絶対に配置されています。私はそれを修正するためにいくつかの異なる方法を試しましたが、ただぐるぐる回っているようです. エラーが私を夢中にさせているので、エラーを見つけられるかどうかを確認できる人はいますか?
以下のコード!
<div id="wrapper">
<div id="scroller">
Content
</div>
</div>
<div id="footer">
Content
</div>
#footer {
position: fixed;
z-index: 2;
bottom: 0;
left: 0;
width: 100%;
padding: 0;
height: 65px;
}
#wrapper {
position: absolute;
z-index: 1;
top: 0;
bottom: 90px;
left: 0;
width: 100%;
overflow: auto;
color: #696868;
}
#scroller {
position:absolute;
paddding:0;
margin: 0 20px;
}
// Store div ID in local Storage
var storage = window.localStorage;
$("a.scroll_link").click(function(event) {
event.preventDefault();
var value = $(this).attr("id");
storage.setItem("key",value);
window.location=$(this).attr("href");
});
$(document).ready(function() {
//Retrieve ID from local storage
var value = window.localStorage.getItem("key");
console.info(value);
//If null then re-define
if (value != "" && value != "undefined" && value != null) {
var storage = window.localStorage;
storage.setItem("key",value);
var scroll_type = "";
if ($.browser.webkit) {
scroll_type = "body";
} else {
scroll_type = "html";
}
//Scroll to position based on ID
$(scroll_type)
.stop()
.animate({
//get top-position of target-element and set it as scroll target
scrollTop: ($("#" + value).offset().top - 25)
//scrolldelay: 1.5 seconds
}, {
duration: 1500,
complete: function () {
storage.clear(); //Clear item from local storage
},
});
}
});