Before it is suggested, I have searched extensively for a solution and have not found one suitable based on my technical ability.
I need to be able to change the offset of this waypoint script to '-1' if it's going up and '0' if it's scrolling down.
$(document).ready(function(){
$('section').waypoint(function(direction) {
var me = $(this); //added
thisId = $(this).attr('id');
$('ul.side_nav li').each(function(){
var secondaryID = $(this).attr('class');
if ( secondaryID == thisId )
{
$('ul.side_nav li').removeClass('active');
//added
if(direction==='up'){
me = $(this).prev();
}
//added
if(!me.length){
me = $(this);
}
$(this).addClass('active');
}
});
});
});
I have tried various things such as:
$(document).ready(function(){
$('section').waypoint(function(direction) {
var me = $(this); //added
thisId = $(this).attr('id');
$('ul.side_nav li').each(function(){
var secondaryID = $(this).attr('class');
if ( secondaryID == thisId )
{
$('ul.side_nav li').removeClass('active');
//added
if(direction==='up'){
me = $(this).prev();
}
//added
if(!me.length){
me = $(this);
}
$(this).addClass('active');
}
});
});
$('section').waypoint(function(direction) {
if (direction === 'down') {
// Do stuff
}
}, {
offset: '0'
}).waypoint(function(direction) {
if (direction === 'up') {
// Do stuff
}
}, {
offset: '-1'
});
});
But have been unable to get a result...Again due to my lack of knowledge with JS, Jquery and Waypoint.js.
Any help would be gratefully received!