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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:18:16+00:00 2026-05-29T22:18:16+00:00

I have a sidebar on my site that occasionally needs to be scrolled. It’s

  • 0

I have a sidebar on my site that occasionally needs to be scrolled. It’s an unpleasant user experience when, after scrolling the sidebar to the bottom with the mousewheel, the main window begins to scroll.

I’d like to make sure the main window does not scroll with the mouse wheel when the mouse wheel is over my sidebar, though preferably only when my sidebar itself is showing scrollbars.

I’d probably like to avoid use of javascript scroll bars as they seem to often not perform as well as the defaults (laggier, wait on other js code, etc), though it looks like this solution may require them.

Thanks!

EDIT::
Here’s the code I ended up using, a simple adaptation of what I found in the first link from my accepted answer.

(function($) {
    $.fn.hasScrollBar = function() {
        return this.get(0).scrollHeight > this.height();
    }
})(jQuery);

/** This is high-level function.
 * It must react to delta being more/less than zero.
 */
function handle(delta) {
    slider = $('#wl-slider');

    if(slider.hasScrollBar()){
        if (delta > 0 && slider.scrollTop() == 0 && slider.hasClass('scroll-hover')){
            event.preventDefault();
            event.returnValue = false;
        }
        else if (delta < 0 && (slider.get(0).scrollHeight - slider.scrollTop() == slider.outerHeight()) && slider.hasClass('scroll-hover')){
            event.preventDefault();
            event.returnValue = false;
        }

    }
}



/** Event handler for mouse wheel event.
 */
function wheel(event){

        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
        } else if (event.detail) { /** Mozilla case. */
                /** In Mozilla, sign of delta is different than in IE.
                 * Also, delta is multiple of 3.
                 */
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it.
         * Basically, delta is now positive if wheel was scrolled up,
         * and negative, if wheel was scrolled down.
         */
        if (delta)
                handle(delta);

}

/** Initialization code. 
 * If you use your own event management code, change it as required.
 */
if($('#user-level').size() != 0)
{
  if (window.addEventListener)
        /** DOMMouseScroll is for mozilla. */
        window.addEventListener('DOMMouseScroll', wheel, false);
  /** IE/Opera. */
  window.onmousewheel = document.onmousewheel = wheel;
}
  • 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-29T22:18:17+00:00Added an answer on May 29, 2026 at 10:18 pm

    I guess you won’t suffice with standard event handlers e.g. in jquery and you need to handle directly the mouse wheel – I just googled these resources:

    • http://www.adomas.org/javascript-mouse-wheel/
    • http://www.javascriptkit.com/javatutors/onmousewheel.shtml

    And then look directly if the sidebar is already scrolled at the bottom/top and if yes, filter out the scroll event.

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

Sidebar

Related Questions

I have a masterpage with a sidebar that conatians an accordion control for site
I have a sidebar in my app that can be hidden/shown via a toggle
I have a sidebar that I want to behave like it's frozen on the
I have a sidebar navigation that lists blog entry titles down the side of
I have in a sidebar: <div id=yyy> [shortcode]</div> It outputs a title that when
I will create a webpage that has a sidebar, and the sidebar will have
Okay, on one of my sites I have a news sidebar that displays events
I have a web site that collects high scores for a game - the
I have a site, http://www.denispellerin.ca/ that works fine in almost all browsers except ff2.0
I have a router that does the site navigation nicely and also works when

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.