Prompt a method or a combination of jquery methods that catches the vertical direction of a page scroll up or down. Not just a scroll scroll, but the scroll direction.

    2 answers 2

    Catches when scrolling down and up

    (function () { let previousScroll = 0; $(window).scroll(() => { let currentScroll = $(this).scrollTop(); currentScroll > previousScroll ? alert('Идем вниз') : alert('Поднимаемсья вверх'); previousScroll = currentScroll; }); }()); 
     div { height: 1000px; } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div>:) </div> 

       document.addEventListener('wheel', (evt)=>{ console.log(evt.deltaY); }); 

      On vanilla JS, you can hang a wheel scraper and make it a value of evt.deltaY . If it is greater than 0 then the scroll goes down, if less then up.