title: Sticky sidebar: stick to bottom when scrolling down, top when scrolling up
body: <p>I have been looking for some time now for a solution to my sticky sidebar problem. I have a specific idea of how I would like it to act; effectively, I would like it to stick to the bottom as you scroll down, and then as soon as you scroll back up I would like it to stick to the top, in a fluid motion (no jumping). I am unable to find an example of what I am trying to achieve, so I have created an image that I hope will illustrate the point clearer:</p>
  
  <p><img src="https://i.stack.imgur.com/VAVaP.png" alt="Sticky sidebar: stick to bottom when scrolling down, top when scrolling up"></p>
  
  <ol>
  <li>Sidebar sits under the header.</li>
  <li>As you scroll down the sidebar remains level with the content of the page so that you can scroll through both sidebar and content.</li>
  <li>Reach the bottom of the sidebar, the sidebar sticks to the bottom of the viewport (most plugins only allow for sticking to top, some that allow for sticking to bottom don't allow for both).</li>
  <li>Reach the bottom, sidebar sits above the footer.</li>
  <li>As you scroll back up, the sidebar stays level with the content so you can scroll through the content and sidebar again.</li>
  <li>Reach the top of the sidebar, the sidebar sticks to the top of the viewport.</li>
  <li>Reach the top and the sidebar sits back below the header.</li>
  </ol>
  
  <p>I hope this is enough information. I have created a jsfiddle to test any plugins/scripts, which I have reset for this question: <a href="http://jsfiddle.net/jslucas/yr9gV/2/" rel="noreferrer">http://jsfiddle.net/jslucas/yr9gV/2/</a> <code>.</code></p>