added some extra smarts to the fixed sidebar

Added in a check for the window height before applying fixed positioning to the sidebar. This is to solve a problem where currently if you are browsing on a small screen (or in some cases even a large screen) the bottom of the sidebar gets cut off and made inaccessible.
Not sure. I personally find the first way to be easier to read but happy to change if we have an existing convention elsewhere?