我需要页面加载的锚点(multiscroll.js)

时间:2015-10-01 12:22:53

标签: anchor fullpage.js multiscroll.js

如果您注意到加载页面时没有锚点:

http://alvarotrigo.com/multiScroll/

但如果再向下滚动:

  

/ multiScroll /#首先出现。

首页加载时我需要'#first'而不是我滚动时所以我可以在页面加载时使用afterLoad函数。

小提琴https://jsfiddle.net/oadfcjt2/8/

$('#myContainer').multiscroll({

sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE'],
menu: false,
afterLoad: function(anchorLink, index){
    if(index == 1){
        alert("first");
    }
}
});

有任何帮助吗?谢谢。

1 个答案:

答案 0 :(得分:1)

使用afterRender回调。

$('#myContainer').multiscroll({

    sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE'],
    menu: false,
    afterLoad: function (anchorLink, index) {
        afterLoadActions(anchorLink, index);
    },
    afterRender: function () {
        var activeSection = $('.ms-left').find('.ms-section.active');
        var activeAnchor = activeSection.data('anchor');

        afterLoadActions(activeAnchor, activeSection.index());
    }
});


function afterLoadActions(anchorLink, index) {
    if (index == 1) {
        alert("first");
    }
}