Open dhanilkumart opened 7 years ago
You could do something like this, I use it to disable Sticky when it hits the footer.
https://gist.github.com/remyo/7c8c8117723968c2700f0d9110f3c3a1
Nice trick but makes very bad UX Updated gist for instant action.
$(document).ready(function(){ $window = $(window); $window.scroll(function() { var element_1 = $(".sidebar"); var element_2 = $(".footer"); var element_1_top = element_1.offset().top; var element_2_top = element_2.offset().top; var element_1_bottom = element_1_top + element_1.height(); var element_2_bottom = element_2_top + element_2.height();
if (element_1_bottom >= element_2_top && element_1_top < element_2_bottom) {
$(".sidebar").unstick();
}
}); });
How to disable the stick event when it is reaches the bottom of it's parent div?? I want that div only stick in it's parent div