Scrollify - get last viewed section

半世苍凉 提交于 2019-12-11 15:15:53

问题


Is there any way to get last viewed section index/id/class when moving to next or previous section using scrollify.js?

Am looking for any predefined function like scrollify.current() for getting last viewed section.

Thanks in advance


回答1:


Not able to find any predefined class, so wrote my own function.

var prevIndex = 0;

$.scrollify({
    before:function(index, sections) {
    var prevSection = '#'  + getScrollifySectionID(prevIndex)
    prevIndex = index;                  

    //Do your code with PrevSection(ID).

    }
});

function getScrollifySectionID(index){
    var sectionID = '';
    $('.scrollify-section').each(function(i){                               
        if(i == index){                     
            sectionID = $(this).data('section');                
        }
    });         
    return sectionID;
};


来源:https://stackoverflow.com/questions/45431016/scrollify-get-last-viewed-section

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!