Skip to content

Instantly share code, notes, and snippets.

View WWPME's full-sized avatar
🤖
git pull'ing

WWPME WWPME

🤖
git pull'ing
View GitHub Profile
$(window).scroll(() => {
// Distance from top of document to top of footer.
topOfFooter = $("#footer").position().top;
// Distance user has scrolled from top, adjusted to take in height of sidebar.
scrollDistanceFromTopOfDoc = $(document).scrollTop() + 650;
// Difference between the two.
scrollDistanceFromTopOfFooter = scrollDistanceFromTopOfDoc - topOfFooter;
// If user has scrolled further than footer,
// pull sidebar up using a negative margin.