On this dev site I have a bar (blue background) down below that scrolls up as the user scrolls. When it gets to the top, the main nav (white background) moved up and off the page and the blue bar "sticks". It works, but it's very "jumpy" if you scroll slowly. Any ideas how to make this smooth? Here is the jQuery that makes it happen...
<!-- to make sub menu stick to top-->
<script type="text/javascript">
jQuery(function($) {
var docked = false;
var menu = $('.sticky_cta');
var mainmenu = $('#t3-mainnav');
var init = menu.offset().top;
$(window).scroll(function() {
if (!docked && (menu.offset().top - $("body").scrollTop() < 50)){
mainmenu.css({
display: "none",
});
menu.css({
position : "fixed",
top: 0,
});
docked = true;
} else if(docked && $("body").scrollTop() <= init) {
mainmenu.css({
display: "block",
});
menu.css({
position: "relative",
});
docked = false;
}
});
});
</script>