0
How to calculate the scrollbar div motion field in this case:
var margem = 0;
function criarBarraDeRolagem(){
if ($( document ).height() < $( window ).height())
{
return;
}
var tamanho = $( window ).height() / $( document ).height();
$('#rolagem2').css('top', margem + ($( window ).scrollTop() * tamanho));
$('#rolagem2').height($( window ).height() * tamanho - (margem + margem) );
}
$(document).ready(function(){
criarBarraDeRolagem();
});
var dragObj = null;
$("#rolagem2, body, html").mouseup(function(){
$('body, html').removeClass("unselectable");
dragObj = null;
});
$("#rolagem2").mousedown(function(){
$('body, html').addClass("unselectable");
dragObj = this;
});
$("#rolagem2, body, html").mousemove(function(e){
if( dragObj )
{
var move = e.pageY - $("#rolagem").offset().top;
$(window).scrollTop(move * 4); // O PROBLEMA ESTÁ AQUI
criarBarraDeRolagem();
e.stopPropagation();
e.preventDefault();
}
});
The script works, only if you increase the body size it looks the same in jsfiddle...
I made a comment on the part of the script you need to change...
I didn’t understand the real problem, it’s the question of not being able to get the scroll bar to the end?
– luigibertaco
@luigibertaco, exactly!!!
– Alan PS
I put
11.5
and she goes all the way... Fiddle– KaduAmaral
@Kaduamaral, but in case I lower the body he Buga...
– Alan PS