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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:17:37+00:00 2026-05-30T20:17:37+00:00

I was thinking to make custom scrollbar jQuery plugin, there are many plugins available

  • 0

I was thinking to make custom scrollbar jQuery plugin, there are many plugins available for it but I want to make my own, problem is I am not getting the concept that how should I move a content by moving other div element (scrollbar) and also how should I move content by using mouse scroller??

Please help me to understand this.

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-30T20:17:39+00:00Added an answer on May 30, 2026 at 8:17 pm

    Scrollbars logic

    (onInit, onResize) thumbSize = viewportSize * viewportSize / areaSize
    (onThumbDrag)      viewportScrollPos = areaSize / viewportSize * thumbPos
    (onViewportScroll) thumbPos = viewportScrollPos / viewportSize * thumbSize
    

    The easiest concept would be to use the jQuery UI draggable and attach the .draggable() Method to the .scrollbar

    var $scrollable  = $(".scrollable"),
        $scrollbar   = $(".scrollbar"),
        height       = $scrollable.outerHeight(true),    // visible height
        scrollHeight = $scrollable.prop("scrollHeight"), // total height
        barHeight    = height * height / scrollHeight;   // Scrollbar height!
    
    // Scrollbar drag:
    $scrollbar.height( barHeight ).draggable({
      axis : "y",
      containment : "parent", 
      drag: function(e, ui) {
        $scrollable.scrollTop( scrollHeight / height * ui.position.top  );
      }
    }); 
    
    // Element scroll:
    $scrollable.on("scroll", function() {
      $scrollbar.css({top: $scrollable.scrollTop() / height * barHeight });
    });
    .parent{
      position:relative;
      overflow:hidden;
      height:200px;
      width:180px;
      background:#ddd;
    }
    .scrollable{
      overflow-y:scroll;
      position:absolute;
      padding:0 17px 0 0;
      width: 180px;
      height:100%;
    }
    .scrollbar{
      cursor:n-resize;
      position:absolute;
      overflow:auto;
      top:0px;
      right:0px;
      z-index:2;
      background:#444;
      width:17px;
      border-radius:8px;
    }
    <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="//code.jquery.com/ui/1.11.0/jquery-ui.min.js"></script>
    
    <div class="parent">
      <div class="scrollbar"></div>
      <div class="scrollable">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras non nunc eget sapien molestie mollis. Proin vestibulum vehicula varius. Duis a nunc ac risus facilisis consectetur.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras non nunc eget sapien molestie mollis. Proin vestibulum vehicula varius. Duis a nunc ac risus facilisis consectetur.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras non nunc eget sapien molestie mollis. Proin vestibulum vehicula varius. Duis a nunc ac risus facilisis consectetur.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras non nunc eget sapien molestie mollis. Proin vestibulum vehicula varius. Duis a nunc ac risus facilisis consectetur.       
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras non nunc eget sapien molestie mollis. Proin vestibulum vehicula varius. Duis a nunc ac risus facilisis consectetur.
      </div>
    </div>

    The above is just an example with the needed logic and math involved,
    it misses the "hide-scrollbar", just to keep it simple. I’ll leave to you to add all the needed tweaks, addons.

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

Sidebar

Related Questions

Is there any way to make a function (the ones I'm thinking of are
I'm thinking about frameworks. I know they make life a lot easier, but as
I am thinking of developing a Silverlight application and want to make use of
I want to expose few web services but thinking of hosting those as Windows
I'm looking to make my own custom < function that can take any number
I'm a do it yourself kind of guy, but I want to make sure
I'm thinking to write custom authorize attribute and I'm not sure about output caching.
I'm trying to make my own custom view, currently all it does is draw
I'm trying to make Core Data objects inherit from my own custom class rather
I am thinking about buying an iPod touch to make some money on developing

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.