Bhaskar Garibidi
Bhaskar Garibidi

Reputation: 45

Stop Sticky Div at Certain Point for Jquery.Sticky.js

I'm using jquery.sticky.js on my webpage. Div is properly working i.e sticky but I need to stop the div before my footer.

I had used below code for sticky DIV

jQuery(document).ready(function(){ jQuery("#sticker").sticky({topSpacing:0}); });

My footer DIV has ID - #stop-sticky, how would I stop stickyness in the footer section?

Upvotes: 0

Views: 1364

Answers (1)

karthick
karthick

Reputation: 12176

You have to set bottomSpacing on the sticker. Your bottomSpacing value will be the footer's height + all the elements following it. I have attached a sample fiddle. Hope it helps

$(document).ready(function(){ 
    var stickyBottomOffset = $('footer').height();
    $("#sticker").sticky({topSpacing:0, bottomSpacing: stickyBottomOffset + $('nav').height() });
});

https://jsfiddle.net/xLb6sgc2/

Upvotes: 2

Related Questions