Skip to content

Instantly share code, notes, and snippets.

@SilencerWeb
Last active September 30, 2018 07:19
Show Gist options
  • Save SilencerWeb/b893689f2365d6a13f6b588a24f55186 to your computer and use it in GitHub Desktop.
Save SilencerWeb/b893689f2365d6a13f6b588a24f55186 to your computer and use it in GitHub Desktop.
const initWaypoints = () => {
const header = document.querySelector('.header');
new Waypoint({
element: document.querySelector('.intro'),
handler: function (direction) {
if (direction === 'down') {
header.classList.add('header_hidden');
setTimeout(() => {
header.classList.add('header_sticky');
}, 50);
} else {
header.classList.remove('header_sticky');
header.classList.remove('header_hidden');
}
},
offset: '-50%',
});
new Waypoint({
element: document.querySelector('.about'),
handler: function (direction) {
if (direction === 'down') {
setTimeout(() => {
header.classList.remove('header_hidden');
}, 50);
} else {
header.classList.add('header_hidden');
}
},
});
};
initWaypoints()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment