2013-12-16 30 views
1

好吧,我試圖修改現有的fullpage.js插件(https://github.com/alvarotrigo/fullPage.js/)。返回到使用fullpage.js插件的部分的主幻燈片

我需要的是,當用戶離開每個部分時,該部分應該自動返回到該部分的主幻燈片。

例如,使用我的測試網站位於:(http://trouve.thinkatmosphere.com)。如果我目前處於'about'部分,並且我導航到右側,然後離開'about'部分,並在返回到'about'部分時導航到'client'部分,我需要將它放在第一個再次滑動該部分。

我將如何修改下面的代碼,讓我來執行此:

$.fn.fullpage.moveToSlide = function (index, slide) { 
    var destiny = ''; 
    if(isNaN(index)) { 
    destiny = $('[data-anchor="'+index+'"]'); 
    } else { 
    destiny = $('.section').eq((index -1)); 
    } 
    if (isNaN(index) && slide !== 'undefined') { 
    scrollPageAndSlide(index, slide); 
    } else { 
    if (destiny.length > 0) { 
     scrollPage(destiny); 
    } 
    } 
};` 

回答

1

它不能與任何選項來完成。你需要修改它的插件,但不是你指出的功能。這樣用戶將被重定向到給定部分並滑動。您需要在用戶不知情的情況下在後臺進行移動。

您將需要使函數scrollSlider公衆和你自己的代碼中調用它(onLeaveafterLoad回調)

要公開,因此從初始化或任何其他外部代碼入店,你需要從這個改變功能的報頭:

function scrollSlider(section, slide) { 
    if (typeof slide != 'undefined') { 
     var slides = section.find('.slides'); 
     var destiny = slides.find('[data-anchor="' + slide + '"]'); 
     if (!destiny.length) { 
      destiny = slides.find('.slide').eq(slide); 
     } 

     landscapeScroll(slides, destiny); 
    } 
} 

向該:

$.fn.fullpage.scrollSlider= function(section, slide){ 
    /// .... the same code as in the old function 
} 

Then,onLeave of the current section,you can call that that function for the same section given 0 for the slide

相關問題