Skip to content

Instantly share code, notes, and snippets.

@Realetive
Forked from Cezarion/affix.html
Last active August 29, 2015 14:17
Show Gist options
  • Save Realetive/b92d2ed9129f3a6b90ce to your computer and use it in GitHub Desktop.
Save Realetive/b92d2ed9129f3a6b90ce to your computer and use it in GitHub Desktop.
<script type="text/javascript">
window.onscroll = scroll;
function scroll () {
var scrollTop = window.pageYOffset;
console.log(scrollTop);
if( scrollTop > 363 ){
document.getElementById('summary').style.top="20px";
document.getElementById('summary').style.position="fixed";
}
else
{
document.getElementById('summary').style.position="relative";
document.getElementById('summary').style.top="50px";
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment