Menu 2 effects: one for scrolling down and one for facing [closed]

0

Hello, I am in doubt about how to make a menu (jquery). It is apparent to the top of the site, running 100 px from the top down, it hides (ok so far I've been able to do), and is hidden until the end of the site. When it reaches the end, and the reverse scrolling happens from bottom to top, the menu will appear, with a background (it activates another css) and it goes to the top. What function do I call to identify the scroll from the bottom up?

    
asked by anonymous 04.09.2016 / 00:56

1 answer

1

Save the current scrollTop in a variable and in the next scroll check if it was greater or less:

var scrollbkp = $(window).scrollTop(); // inicia a variável global com o scrollTop atual

$(window).scroll(function() {
  if ($(window).scrollTop() > scrollbkp) {
    // scroll para baixo
    console.log('para baixo');
  } else {
    // scroll para cima
    console.log('para cima');
  }
  scrollbkp = $(window).scrollTop(); // regrava o scrollTop para verificar na próxima vez
});
.conteudo {
height: 2500px;
background-color:#ddd;
}
.as-console-wrapper {
max-height: 50px!important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="conteudo">
conteudo...
</div>
    
04.09.2016 / 14:44