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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:41:03+00:00 2026-05-31T00:41:03+00:00

I’m building a custom scroller for a project and i’m trying to work out

  • 0

I’m building a custom scroller for a project and i’m trying to work out how i would have the scroller handler reach the bottom of the window and for the content to also reach the bottom, ie. In this fiddle i have made: http://jsfiddle.net/BPcfc/ I use jQuery UI draggable to set the position top of the window to the same minus position of the dragged handle but when you pull the handle to the bottom of the window, there is still more content out of view. I dont even know what calculations to perform to work this out!?

The relevant JS:

$( "#dragger" ).draggable({ 
    axis: "y", 
    containment: "parent", 
    drag: function(event, ui) {
        var top = ui.offset.top;
        $('#move').css('top', '-'+top+'px');                    
    } 
});
  • 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-31T00:41:04+00:00Added an answer on May 31, 2026 at 12:41 am

    The top position of your drag handle is just one thing. You have to factor in 3 more values in your calculation:

    • The height of your scrolling window’s client area.
    • The height of your content.
    • The height of your drag handle.

    Using these values, the calculation is quite simple:

    (content_height - window_height) / (window_height - handle_height) * top
    ^Part 1                            ^Part 2                           ^Part 3
    

    Part 1 is needed because one windowful of your content is visible on the screen. Part 2 is needed because your handle’s top position can only range from 0 to window_height - handle_height). Simply multiply it by top in part 3, and you’re done.

    I also added a little one-liner to my code which you can freely remove. It resizes your handle to give a rough idea to the user how much content they should expect.

    I’ll leave the rest up to you. You would need to see IF you need a scroller at all and check your divisions for zero values.

    jsFiddle Demo

    Javascript:

    var window_height = $('#window').height();
    var content_height = $('#move').height();
    
    // Remove this line if you want a fixed size dragger
    $('#dragger').css('height', Math.round(window_height / content_height * window_height));
    
    var handle_height = $('#dragger').height();
    
    $( "#dragger" ).draggable({ 
        axis: "y", 
        containment: "parent", 
        drag: function(event, ui) {
            var top = ui.offset.top;
            var newpos = Math.floor((content_height - window_height) / (window_height - handle_height) * top);
            $('#move').css('top', '-'+newpos+'px');                    
        } 
    });
    ​
    

    CSS:

    #window {
        width: 500px;
        height: 500px;
        border: 1px solid red; 
        position: relative; 
        overflow: hidden;    
    }
    
    #dragger {
        width: 32px;
        height: 32px;
        background: green;
        position: absolute;
        right: 0;
        top: 0;
    }
    
    #move {
        width: 100px;
        background: blue;
        position: absolute;
        top: 0;
        left: 0;
        word-break: break-word;
        color: white;   
    }
    ​
    

    HTML:

    <div id="window">
    
        <div id="move">Bacon swine pastrami, prosciutto corned beef cow capicola chicken. Ham hock andouille shoulder short ribs strip steak beef ribs. Short loin swine andouille beef ribs, capicola sausage chicken salami strip steak corned beef meatball shankle t-bone chuck. Beef swine biltong, brisket meatball boudin pastrami chicken salami chuck shankle meatloaf pork loin. Meatloaf shoulder pig, pancetta beef ribs kielbasa ham hock ham t-bone.Bacon swine pastrami, prosciutto corned beef cow capicola chicken. Ham hock andouille shoulder short ribs strip steak beef ribs. Short loin swine andouille beef ribs, capicola sausage chicken salami strip steak corned beef meatball shankle t-bone chuck. Beef swine biltong, brisket meatball boudin pastrami chicken salami chuck shankle meatloaf pork loin. Meatloaf shoulder pig, pancetta beef ribs kielbasa ham hock ham t-bone.</div> 
        <div id="dragger"></div>        
    
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.