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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:47:56+00:00 2026-05-14T23:47:56+00:00

I’m looking to recreate the effect used on this site: http://www.brizk.com/ The site uses

  • 0

I’m looking to recreate the effect used on this site: http://www.brizk.com/

The site uses one large page that scrolls down. As you scroll down and pass different sections the menu navigation on the left changes css class to “current” as the corresponding div comes into view.

I presume this can be done with jQuery using $(window).height();

I’m fairly new to jQuery and what I want to write is something like this (in laymans terms):

  • Get height of browser window
    – if div#content1 is 100px from top and/or 200px from bottom change menu a#link1 to ‘.current’
    – else remove .current from all menu a links

… and repeat for 4 different content divs.

Can anyone point me in the right direction..?
Thanks.

  • 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-14T23:47:57+00:00Added an answer on May 14, 2026 at 11:47 pm

    I didn’t look at the code example (it’s more fun to challenge myself :P) but this is how I would do it – demo here.

    I saved the position of each element block to minimize the number of DOM calls, then just searched through the array. To help you understand some of the variables.

    $(window).height() // returns the viewport height
    $(document).height() // returns the height of the entire document
    $(window).scrollTop() // returns the Y position of the document that is at the top of the viewport
    

    Script:

    var topRange      = 200,  // measure from the top of the viewport to X pixels down
        edgeMargin    = 20,   // margin above the top or margin from the end of the page
        animationTime = 1200, // time in milliseconds
        contentTop = [];
    
    $(document).ready(function(){
    
     // Stop animated scroll if the user does something
     $('html,body').bind('scroll mousedown DOMMouseScroll mousewheel keyup', function(e){
      if ( e.which > 0 || e.type == 'mousedown' || e.type == 'mousewheel' ){
       $('html,body').stop();
      }
     });
    
     // Set up content an array of locations
     $('#sidemenu').find('a').each(function(){
      contentTop.push( $( $(this).attr('href') ).offset().top );
     });
    
     // Animate menu scroll to content
      $('#sidemenu').find('a').click(function(){
       var sel = this,
           newTop = Math.min( contentTop[ $('#sidemenu a').index( $(this) ) ], $(document).height() - $(window).height() ); // get content top or top position if at the document bottom
       $('html,body').stop().animate({ 'scrollTop' : newTop }, animationTime, function(){
        window.location.hash = $(sel).attr('href');
       });
       return false;
     });
    
     // adjust side menu
     $(window).scroll(function(){
      var winTop = $(window).scrollTop(),
          bodyHt = $(document).height(),
          vpHt = $(window).height() + edgeMargin;  // viewport height + margin
      $.each( contentTop, function(i,loc){
       if ( ( loc > winTop - edgeMargin && ( loc < winTop + topRange || ( winTop + vpHt ) >= bodyHt ) ) ){
        $('#sidemenu li')
         .removeClass('selected')
         .eq(i).addClass('selected');
       }
      });
     });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

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.