问题
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