I'm currently working on developing a custom scroll bar using HTML. Something along the lines of:
<div class="demo">
<div class="content">
My content goes here
</div>
<div class="scrollbar">
<div class="thumb"></div>
</div>
</div>
My goal is to dynamically set the height of the thumb using jQuery.
However, I'm struggling to determine the formula for calculating the thumb size.
I've attempted something similar to:
$.scrollViewHeight = $('.demo').height();
$.contentHeight = $('.content').height();
$.thumbHeight = ($.scrollViewHeight / $.contentHeight) * $.scrollViewHeight;
$('.thumb').height($.thumbHeight);
but it's not producing the desired result.
Q1. What formula should I use to determine the height of the thumb?
I've also set a minimum thumb size of 50px
using CSS.
Q2. How can we calculate the scrolling speed of the thumb in this scenario where there is a lot of content to scroll through?
.