scroll down up js

var lastScrollTop = 0;

// element should be replaced with the actual target element on which you have applied scroll, use window in case of no target element.
element.addEventListener("scroll", function(){ // or window.addEventListener("scroll"....
   var st = window.pageYOffset || document.documentElement.scrollTop; // Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
   if (st > lastScrollTop){
      // downscroll code
   } else {
      // upscroll code
   }
   lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
}, false);

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
scroll up in javascript scroll up or scroll down in js how to scroll down in js js scroll down or up js scroll up and then down javascript scroll up and down scroll up and down javascript scroll down in js scroll down or up js javascript scroll down or up js scroll up scroll up and down in javascript scroll down with javascript scroll up scroll down js scroll up js javascript to scroll down javascript on scroll down scroll down page js how to scroll up in javascript how to scroll down with js scroll up javascript javascript scroll up and down event event scroll down and up js js up and down scroll js scroll up or down check scroll up js javascript event scroll up down js scroll down javascript scroll down up scroll down using javascript javascript how to scroll Up how to scroll up in js js on scroll down js scroll down page scroll down with js scroll down using js javascript scroll down page angular get scroll direction js scroll which direction scroll down js scroll object direction how to know scrolldirection js js scroll event direction javascript scroll element down if user is scrolling up javascript implement scroll direction scroll down and up javascript scroll down and scroll up event in javascript event handling when scroll in x direction detecting scroll direction javascript get scroll direction determine scroll direction javascript how to detect direction of scroll how to detect if user scrolls down javascript js get scroll event direction js get scroll direction on scroll up javascript add veentlistener scroll down on click how to know scroll direction javascript how to scroll down in javascript javascript scroll up detect scroll up in js alert if scroll direction is down detect scroll direction js javascript on scroll up javascrip detect whn i am scrolling up or down scroll down javascript es6 detect scroll javascript if scrolling down onscroll down window offset how to detect scroll direction in javascript angular detect scroll direction how to detect scroll direction without scrolltop how to detect scroll up in javascript event listener scroll up javascript scroll up and scroll down event in javascript javascript detect scroll direction check down scroll javascript detect scroll up using javascri[t find scroll direction javascript scroll up down js how to know window in scroll up or down javascript how to check with javascript scrolling up js check scroll above how to check scroll up or down javascript up scroll event javascript js know when you scroll event listener for scroll down vs scroll up event listener for scroll down and scroll up how to find downscroll event javascript detect scroll up and down javascript vanilla js check scroll direction how to detect scroll up and scroll down in javascript scroll direction javascript javascript detect scroll up js check scrolling direction js check if user scrolling up or down on mobile js get page scroll direction js check if scroll up or down js if scroll direction change not scrolling javascript if scroll up javascript scroll event direction get scroll direction javascript vanilla js detect scroll direction detect scroll direction js event listener scroll direction js eventlistener scroll direction js check if user is scrolling up or down javascript detect when user scroll down onscroll down and upo scroll detection es6 detect scroll inside a div javascript scroll direction detect scroll down js scroll direction js detect scroll direction javascript scroll up event javascript js detect scroll direction on scrollup javascript scroll event direction javascript determine scroll up or down js handling scroll up and down how to determine which way user scrolled
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source