0
How to ignore the cursor position on the scroll bar ?
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;
var speed = $(window).height() / $("#rolagem2").height();
$(window).scrollTop(move * speed);
criarBarraDeRolagem();
e.stopPropagation();
e.preventDefault();
}
});
Còdigo working! Just need to ignore the cursor position on the scroll bar...
EDIT: New fiddle!!! http://jsfiddle.net/1qq27jan/11/
looks good that it is working, post also some attempt of his, tests and similar
– Otto
It would be nice to explain what the code does, and why you need to ignore this cursor position.
– bfavaretto