Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to stop floating (sliding) div at footer
    primarykey
    data
    text
    <p><a href="https://stackoverflow.com/questions/225843/how-can-i-have-a-sliding-menu-div-that-doesnt-move-unless-the-page-is-scrolled-d">How can I have a sliding menu div that doesn&#39;t move unless the page is scrolled down past a certain point</a></p> <p>i used the code from this link for a floating menu. it has how to stop the stop float at the header, but not at the footer. how can i modify this code to stop at the footer?</p> <pre><code> //// CONFIGURATION VARIABLES: var name = "#sidebar"; var menu_top_limit = 0; var menu_top_margin = 0; var menu_shift_duration = 500; var menuYloc = null; /////////////////////////////////// $(window).scroll(function() { // Calculate the top offset, adding a limit offset = menuYloc + $(document).scrollTop() + menu_top_margin; // Limit the offset to 241 pixels... // This keeps the menu out of our header area: if(offset &lt; menu_top_limit) offset = menu_top_limit; // Give it the PX for pixels: offset += "px"; // Animate: $(name).animate({top:offset},{duration:menu_shift_duration,queue:false}); }); </code></pre> <p>I have another similar code that is supposed to stop at the footer, but it is not working:</p> <pre><code>var name = "#sidebar"; var menuYloc = null; var footer = '#footer'; //Specify the ID for your footer. $(document).ready( function() { menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px"))) $(window).scroll( function() { var offset = menuYloc + $(document).scrollTop(); var anotherOffset = offset; var docTop = $(window).scrollTop(); var footerTop = $(footer).offset().top; var maxOffset = footerTop - $(name).height() - 20; var minOffset = docTop; offset = offset &gt; maxOffset ? maxOffset : offset; offset = offset &lt; minOffset ? minOffset : offset; $(name).animate({top:offset + 'px'},{duration:500,queue:false}); } ); } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload