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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:58:15+00:00 2026-06-11T11:58:15+00:00

I am using http://jsfiddle.net/mekwall/up4nu/ for my scrolling on a one pager. How would I

  • 0

I am using http://jsfiddle.net/mekwall/up4nu/ for my scrolling on a one pager. How would I deactivate the current marking when a menu item is clicked? I want to keep it on scroll. But when I am on the first item and click the fourth one, I just want the fourth one to mark current, with no marking “sliding” through second and third item.

I also tried the onePageNav, but it breaks if I have a subpage that doesn’t have content (section with id) on the landing page.

  • 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-11T11:58:16+00:00Added an answer on June 11, 2026 at 11:58 am

    This should work 🙂 I added a noScrollAction variable. I set it before the scrolling animation starts and disable it when it’s ended. But the window scroll still fires after the animation is over (haven’t figured out why yet). So I put an extra delay on it. And set the active class for the right anchor.

    // Cache selectors
    var lastId,
        topMenu = $("#top-menu"),
        topMenuHeight = topMenu.outerHeight()+15,
        // All list items
        menuItems = topMenu.find("a"),
        // Anchors corresponding to menu items
        scrollItems = menuItems.map(function(){
          var item = $($(this).attr("href"));
          if (item.length) { return item; }
        }),
        noScrollAction = false;
    
    // Bind click handler to menu items
    // so we can get a fancy scroll animation
    menuItems.click(function(e){
        var href = $(this).attr("href"),
            offsetTop = href === "#" ? 0 : $(href).offset().top-topMenuHeight+1;
        noScrollAction = true;
        $('html, body').stop().animate({ 
            scrollTop: offsetTop
        },{
            duration: 300,
            complete: function() {
                menuItems
                    .parent().removeClass("active")
                    .end().filter("[href=" + href +"]").parent().addClass("active");
                setTimeout(function(){ noScrollAction = false; }, 10);
            }
        });
        e.preventDefault();
    });
    
    // Bind to scroll
    $(window).scroll(function(){
       if(!noScrollAction){
           // Get container scroll position
           var fromTop = $(this).scrollTop()+topMenuHeight;
    
           // Get id of current scroll item
           var cur = scrollItems.map(function(){
             if ($(this).offset().top < fromTop)
               return this;
           });
           // Get the id of the current element
           cur = cur[cur.length-1];
           var id = cur && cur.length ? cur[0].id : "";
    
           if (lastId !== id) {
               lastId = id;
               // Set/remove active class
               menuItems
                 .parent().removeClass("active")
                 .end().filter("[href=#"+id+"]").parent().addClass("active");
           }
       }    
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here are two examples. One with required result, using tables: http://jsfiddle.net/Dhn3B/ Another with divs:
I added a image hover effect using jquery : http://jsfiddle.net/roXon/HmTrw/ my site : http://windows7themer.com
http://jsfiddle.net/nUcXQ/ How to get dynamic height on the main (black background) I'm using image
here is the code: http://jsfiddle.net/bfQMD/11/ Im using flip pluging and how to change opacity.
Update : Added simple test example http://jsfiddle.net/7UhrW/1/ using normalize.css. Chrome/WebKit and Firefox have different
I'm using this plugin and here is the code: http://jsfiddle.net/gm8t5/ Basically I want to
I'm using simple jcarousel here is ther code: http://jsfiddle.net/w6fLA/ I'm trying to show div
I am building a page using blocks of sections: http://jsfiddle.net/NrkTn/3/ You can see I
http://jsfiddle.net/9BCrs/5/ I have this set up to load a file into a DIV using
Even though the following works: http://jsfiddle.net/N7D5r/ My attempt at using the same code does

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.