Fullpage.js - 将所有幻灯片重置为第一个幻灯片

时间:2015-11-06 05:52:14

标签: javascript jquery html fullpage.js

我正在使用FullPage.js v2.7.4 当用户更改幻灯片然后将该部分留给另一部分时,返回该部分将导致他们访问的最后一张幻灯片出现。

我想这样做,以便当用户打开(假设)第2部分中的幻灯片4,然后他们离开去第3部分时,返回第2部分将显示幻灯片1,而不是4。

我已尝试在SO上发布的其他解决方案,但他们没有做任何事情(猜测它的版本问题)。

我的fullpage_init.js看起来像这样:

jQuery(document).ready(function($) {
    $(document).ready(function() {
        $('#fullpage').fullpage({
            sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE', 'whitesmoke', '#ccddff'],
            anchors: ['firstPage', 'secondPage', '3rdPage', '4thpage', 'lastPage'],
            menu: '#menu',
            scrollingSpeed: 1000,
            onLeave: function(index, nextIndex, direction){
                setTimeout(function(){
                    var section = $('.section').eq((index - 1));
                    if (section.find('.slides').length) {
                        $.fn.fullpage.scrollDefault(section, 0);
                    }
                }, 500);
            }
        });
    });
});

我的main.js看起来像这样:

$.fn.fullpage.scrollDefault = function(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);
        }
        if(destiny.length){
            landscapeScroll(slides, destiny);
        }
    }
};

有什么想法吗?

0 个答案:

没有答案
相关问题