2016-09-09 11 views
1

Scrollifyプラグインを使用しています。私はボタンをクリックするとセクションに移動したい。しかし、sectionNamefalseに設定しても、動作しないようです。 sectionNamefalseに設定されていないときはうまく動作しますが、ページをリフレッシュ/リロードして(たとえば3番目のセクションで)スクロールすると、アドレスバーには#が表示されません。次のセクション(第1セクションから第4セクション)。
に移動しますかsectionNamefalseの場合、特定のセクションに移動しますか?sectionNameがfalseのときにスクロール移動が動作しない

は、ここで私はこれまでやったことだ:
JS

$('.goNotify').click(function (e) { 
    e.preventDefault(); 
    $.scrollify.move($(this).attr("href")); 
}); 

HTML

<a href="#notify" class="goNotify"> 
    <button id="btnDrive" class="btnNotif" type="button" name="btnDrive" title="Get Notified When Available">Get Notified When Available</button> 
</a> 

<section id="notify" class="panel" data-section-name="notify"> 
<!-- content --> 
</section> 

ありがとう! :)

答えて

0

移動メソッドに移動するセクションのインデックスを解析する必要があります。もちろん

+0

それは働いた!ありがとう:) – Potato

0

ので、私は、コードのこの部分で同じ問題とバイパスそれを持っていた:«getScrollifySectionIndex»方法はHREFを解析し、パネルのインデックスを返す

$("a.scrollify").on("click",function() { 
    $.scrollify.move(getScrollifySectionIndex($(this).attr("href"))); 
}); 

function getScrollifySectionIndex(anchor){ 
    var idpanel = false; 
    jQuery('section.panel').each(function(i){ 
     if(jQuery(this).data('section-name') == anchor.toString().replace(/#/g,"")){ 
     //console.log(jQuery(this).data('section-name') , i , anchor.toString().replace(/#/g,"")); 
     idpanel = i; 
     } 
    }); 
    return idpanel; 
}; 

非常にうまく動作します:)

関連する問題