var prevPosition = 0;
document.addEventListener('scroll', onScroll);
function onScroll() {
if (document.body.scrollTop > prevPosition) {
menu.removeClass('menu-open');
} else {
menu.addClass('menu-open');
}
prevPosition = document.body.scrollTop;
}