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

  • Home
  • SEARCH
  • 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 6929627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:20:32+00:00 2026-05-27T11:20:32+00:00

I have a simple piece of code which shows a scrollbar when the mouse

  • 0

I have a simple piece of code which shows a scrollbar when the mouse is over a container, and fade it out when the mouse leaves:-

$('#sidebar-wrapper').on('mouseenter mouseleave', '#TopPane, #BottomPane', function(e){

var $div = $(this).find ('.jspDrag');


    if ( e.type == 'mouseenter') {
    $div.show();
    }

    if ( e.type == 'mouseleave' ) { 
    $div.fadeOut('600');
    }


});

What I want to do is have a mousedown event on $(‘.jspDrag’) that will prevent the mouseleave event from firing for the whole duration that the mouse is held down.

The idea is that if the user is moving the scrollbar with the mouse by holding down the button on it, they may accidentally slip out of the element, if so I do not want the custom scrollbar div to fadeout, as long as the left mouse button is still held down.

I have playd with setTimeout but and the mousedown events but have been able to find a solution that provides the correct behaviour. Any ideas?

EDIT:

Just to provide more detail – I am looking for the same behaviour that the “facebook” sidebar custom scrollers have. On Facebook the scroller appears when you hover over the sidebar, as does mine. But on Facebook if you hold the mouse down and move the mouse out of the sidebar or even on to the actual browser scroller, the custom scroller remains visible and active. This is the bahviour I wish to emulate.

EDIT 2:

I have added a JsFiddle to demonstrate as requested. I have stripped the css/content as much as possible. Ig you hover your mose over the top div you will see the hidden custom scrollbar appear.

http://jsfiddle.net/wSMVg/

  • 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-27T11:20:32+00:00Added an answer on May 27, 2026 at 11:20 am

    A simple solution will be:

    var mousedown = 0;
    $('#sidebar-wrapper').mousedown(function(){
        mousedown = 1;
    });
    $('#sidebar-wrapper').mouseup(function(){
        mousedown = 0;
    });
    $('#sidebar-wrapper').on('mouseenter mouseleave', '#TopPane, #BottomPane', function(e){
        var $div = $(this).find ('.jspDrag');
        if ( e.type == 'mouseenter') {
            $div.show();
        }
        if ( e.type == 'mouseleave' ) { 
            if (mousedown == 0){
                $div.fadeOut('600');
            }
        }
    });
    

    just not sure whether $('#sidebar-wrapper') is the correct object 🙂

    EDIT:

    here’s the jsfiddle: http://jsfiddle.net/wSMVg/5/

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

Sidebar

Related Questions

I have a piece of ada code shown below which is a simple switch
friends, I have a piece of code which can perform simple add, subtraction, multiplication,
I have a very simple piece of code below which I think gives the
I have a simple piece of PHP code which requires a random number to
I have following simple piece of code, which is a part of ipv6 handling
I have a simple piece of code: public string GenerateRandomString() { string randomString =
I've wrote this simple piece of code. And I have a slight problem with
I have a piece of code which works in a way that is unexpected
I have a simple peice of jQuery code that submits a form and hides/shows
I have written a piece of Java code which is intended as to call

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.