Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kevin-LeMasters-PixelParade/b7571eb3f598e11358e7db313bb6d356 to your computer and use it in GitHub Desktop.
Save Kevin-LeMasters-PixelParade/b7571eb3f598e11358e7db313bb6d356 to your computer and use it in GitHub Desktop.

Header will need to be set to sticky and overlay by default.

Simply add this script to your global JS or enque as a seperate script file.

window.onscroll = function(e) {
var scrollY = window.pageYOffset || document.documentElement.scrollTop;
var header = document.querySelector('header');
var height = -header.clientHeight;
header.style.transition = 'transform 0.5s';
(scrollY <= Math.max(this.lastScroll, 300) || window.innerWidth <= 200 || this.loaded === undefined)
? header.style.transform = 'translateY(0px)'
: header.style.transform = 'translateY(' + height + 'px)';
this.lastScroll = scrollY;
this.loaded = true;
};
@Kevin-LeMasters-PixelParade
Copy link
Author

Thanks Abby, Small world. Check out some of Zach's gists, he has a great assortment of BB snippets. https://gist.github.com/zackpyle and he created this nice plugin for class management https://github.com/zackpyle/BBClassDropdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment