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 6135323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:27:55+00:00 2026-05-23T17:27:55+00:00

My webpage animates scrolling when users click on links to the same page. I

  • 0

My webpage animates scrolling when users click on links to the same page. I want to cancel this animation as soon as the user tries to scroll (otherwise the user and the browser are fighting for control) – no matter whether with the mouse wheel, the keyboard or the scrollbar (or any other way – are there other ways of scrolling?). I managed to cancel the animation after the mouse wheel or keyboard are used, how do I get this working with the scrollbar?

Here is how my code looks for the keyboard:

$(document.documentElement).keydown( function (event) {
    if(event.keyCode == 38 || 40) stopScroll();
});

function stopScroll() {
    $("html, body").stop(true, false);
}

I also tried a more elegant way of doing this by using scroll(), the problem is that scroll() catches everything including the animated and automated scrolling. I could not think of any way to let it catch all scrolling except the animated scrolling.

  • 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-05-23T17:27:56+00:00Added an answer on May 23, 2026 at 5:27 pm

    you need animation marker, something like this

    $("html, body").stop(true, false).prop('animatedMark',0.0).animate({scrollTop : top, animatedMark: '+=1.0'})
    

    Here is the code, the code was mix of GWT and javascript so moved it to js, not fully tested, please try it

    var lastAnimatedMark=0.0;
    function scrollToThis(top){
        // Select/ stop any previous animation / reset the mark to 0 
        // and finally animate the scroll and the mark
        $("html, body").stop(true, false).prop('animatedMark',0.0).
        animate({scrollTop : top, animatedMark: '+=1.0'}
        ,10000,function(){
            //We finished , nothing just clear the data         
            lastAnimatedMark=0.0;
            $("html, body").prop('animatedMark',0.0);
        });
    }
    //Gets the animatedMark value
    function animatedMark() {
        var x=$("html, body").prop('animatedMark');
        if (x==undefined){
            $("html, body").prop('animatedMark', 0.0);
        }
        x=$("html, body").prop('animatedMark');
        return x;
    };
    
    //Kills the animation
    function stopBodyAnimation() {
        lastAnimatedMark=0;
        $("html, body").stop(true, false);
    }
    //This should be hooked to window scroll event 
    function scrolled(){
        //get current mark
        var currentAnimatedMark=animatedMark();         
        //mark must be more than zero (jQuery animation is on) & but 
        //because last=current , this is user interaction.
        if (currentAnimatedMark>0 && (lastAnimatedMark==currentAnimatedMark)) {
            //During Animation but the marks are the same ! 
            stopBodyAnimation();
            return;
        }
    
        lastAnimatedMark=currentAnimatedMark;    
    }
    

    Here is the blog about it

    http://alaamurad.com/blog/#!canceling-jquery-animation-after-user-interaction

    Enjoy!

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

Sidebar

Related Questions

In my webpage, I want the website to greet the user, but the username
I have a webpage where I want the user to see a new image
I have a webpage. I want to change the icon on button down (this
My webpage currently looks like this: <asp:Table runat=server style=position: absolute; left: 0%; top: 82%;
I have a webpage (say www.example.com/a.asp) .. I am having an iframe in this
There's a webpage that enables service providers to check customers insurance validity. The page
I'm trying to add some iPhone style scrolling inertia to a web page that
I have the following animations in my web page: $(.anim-item).not(this).animate({ opacity: 0, }, {
This webpage looks fine in dreamweaver but when I view it in any browser,
Webpage is - http://schnell.dreamhosters.com/spriteanimate.html Just go to the page and 'View Source' and you'll

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.