Skip to content

Instantly share code, notes, and snippets.

@Cezarion
Created October 8, 2013 10:36
Show Gist options
  • Save Cezarion/6882786 to your computer and use it in GitHub Desktop.
Save Cezarion/6882786 to your computer and use it in GitHub Desktop.
Affix js with vanilla js
<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