I am using JQuery Waypoint to scroll the left side navigation. How can I stop the scroll before the footer?
<script type="text/javascript">
var $jq = jQuery.noConflict();
$jq(document).ready(function() {
$jq('.top').addClass('hidden');
$jq.waypoints.settings.scrollThrottle = 30;
$jq("#toc").waypoint(function(event, direction) {
$jq('.top').toggleClass('hidden', direction === "up");
if (direction === 'down') {
var cssObj = {'position' : 'fixed', 'top' : '3px', 'left' : '100px'}
}
else {
var cssObj = {'position' : 'absolute', 'top' : '3px', 'left' : '100px'}
}
$jq('#toc').css(cssObj);
},{
offset: '3'
});
});
</script>
You can set another waypoint for the footer whose offset is equal to the height of the
#tocelement plus any padding, borders, and positioning additions.So maybe something like:
This way, once it detects that the amount of room between the top of the footer and the top of the page is equal to the total height of the
#tocelement, it’ll go back toposition:absoluteand abottomvalue of403px. Adjust this to match the height of the footer and accommodate for the spacing you desire between the footer and the#tocelement.Here‘s an example.