オブジェクトがスクロールしてビューポートに表示されると、jquery waypoints はコールバックを発生させます。これは、基本的な実装では問題なく機能します。
ここで、同じ ' article ' タグに 2 つのウェイポイントを指定しようとしまし<article />
た。<article />
offset: 121
// waypoint 1
$.aquaverde.article.waypoint(function(event, direction) {
currentIndex = $(this).index();
if (direction === "down") {
$.aquaverde.wrapper.find('.fixed:eq('+ currentIndex +')').show().siblings(".fixed").hide();
}
});
// waypoint 2
$.aquaverde.article.find('.page').waypoint(function(event, direction) {
if (direction === "down") {
$.aquaverde.wrapper.find(".fixed").hide();
}
},{
offset: 121
});
残念ながら、プラグインは、オブジェクトが上から 121 ピクセルのときに両方のコールバックを起動するため、2 番目の構成が優先されます。
OK、次に連鎖呼び出しを試みました。
// waypoint 1
$.aquaverde.article.waypoint(function(event, direction) {
currentIndex = $(this).index();
if (direction === "down") {
$.aquaverde.wrapper.find('.fixed:eq('+ currentIndex +')').show().siblings(".fixed").hide();
// waypoint 2
$(this).waypoint(function(event, direction) {
$.aquaverde.wrapper.find(".fixed").hide();
},{
offset: 121
});
}
});
しかし、上記とまったく同じ結果が得られます。それを解決するためのアイデアはありますか?
http://imakewebthings.github.com/jquery-waypoints/
ありがとうございました。