Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:07:58+00:00 2026-06-13T08:07:58+00:00

I am trying to make this scrolleffect work on a website. When a users

  • 0

I am trying to make this scrolleffect work on a website. When a users scroll down it automagically has to go to the next slide. When the users scrolls up it has to go one slide back. I have tried a lot of things using the onScroll function in Jquery, but none of them seem to work.

I use the following script to check whether the users scrolls up or down.

var lastScrollTop = 0;
var check = 1;
var scrollDirection = 'down';

var scrollBottom = $(window).scrollTop() + $(window).height();
    $(window).scroll(function(event) {
        slideHeight = $('.slide').height();
         var st = $(this).scrollTop();
         if (st > lastScrollTop){
             scrollDirection = 'down';
             if (check == 1){
                $('body').scrollTo( {top:'0px', left:'100%'}, 800 );
     check = 0;    
 }

         } else {
             scrollDirection = 'up';
         }
         lastScrollTop = st;


         console.log('ScrollDirection: '+ scrollDirection);

    });

I am not coming any further than this. The (test)website where developing takes place is: http://bit.ly/RBcffY
If anyone has experience with this kind of function it would be really helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:07:59+00:00Added an answer on June 13, 2026 at 8:07 am

    The jquery.mousewheel plugin can be used to capture the mouse wheel even when no scrolling happened (contrary to $.scroll). This way you can both detect that the mouse wheel was moved and prevent the scrolling from happening. Then it’s just a matter to performing the animated scrolling yourself.

    var scrollingScreen = false;
    $("body").mousewheel(function(event, delta) {
        if ( !scrollingScreen ) {
            scrollingScreen = true; // Throttles the call
            var top = $("body").scrollTop() || // Chrome places overflow at body
                      $("html").scrollTop();   // Firefox places it at html
            // Finds slide headers above/below the current scroll top
            var candidates = $(".slide").filter(function() {
                if ( delta < 0 )
                    return $(this).offset().top > top + 1;
                else
                    return $(this).offset().top < top - 1;
            });
            // If one of more are found, updates top
            if ( candidates.length > 0 ) {
                if ( delta < 0 )
                    top = candidates.first().offset().top;
                else if ( delta > 0 )
                    top = candidates.last().offset().top;
            }
            // Performs an animated scroll to the right place
            $("html,body").animate({ scrollTop:top }, 800, "easeInOutQuint", function() {
                scrollingScreen = false; // Releases the throttle
            });
        }
        return false; // Prevents default scrolling
    });​
    

    Working example at jsFiddle. This is pretty consistent with the behavior of the reference you showed, and you could add extra effects as needed – by inserting code either before the animate or in its callback function, to perform them before or after the scrolling respectively. (Obs.: the fiddle, running in an iframe, cannot access scrollTop in some browsers, for security reasons, so it stores the top variable globally; however, the code as shown in the answer should work fine in a standalone page)

    Note: both in the reference site and in my example, middle clicking and moving the mouse scrolls at will. You might want to prevent that or not, your choice. Nonetheless, the updated example scrolls to a specific point instead of just addind some delta, like you suggested in your question – $('.slide').height(). The reason is to account for the possibility that different slides have different heights. Also, knowing exactly which slide you’re showing allows you to properly set the location’s hash.

    See also this related question for more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make this sample program work (defn foo ([x] (foo x
I'm trying to make this fragment work: Version History --------------- These are the versions
when trying to make this question, i got this one it is using Java,
I'm basically trying to make this code work in windows and I have to
I've been trying to make this script work for an hour with zero luck.
I'm trying to make this registration work. I have a number of IEventFactory<> responsible
I am trying to make this jquery carousel work with different widths. Right now
I'm having headaches trying to make this work: I have a <a> element with
I am trying to make this map only allow one marker on the page
I'm trying to make this query work, in my model Workshop I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.