var start_mouse_y = 0;
var scroll_offset = 0;
function SET_SCROLL_EVENT(e){
document.getElementById("online_list_scroll").draggable = true;
start_mouse_y = e.clientY;
}
function ADJUST_SCROLL_EVENT(e){
dont_pass = (412 - set_scroll_height);
mouse_y = e.clientY;
scroll_top = parseInt(document.getElementById("online_list_scroll").style.top);
scroll_offset = (mouse_y - scroll_top) + 46;
new_top = scroll_top + (mouse_y - start_mouse_y);
document.getElementById("DEBUG").innerHTML = "my: "+mouse_y+"<br>new_top: "+new_top+"<br>scroll_offset: "+scroll_offset+"<br>scroll_top: "+scroll_top;
if(new_top <= 0){
document.getElementById("online_list_scroll").style.top = 0+"px";
}else if(new_top >= dont_pass){
document.getElementById("online_list_scroll").style.top = dont_pass+"px";
}else{
document.getElementById("online_list_scroll").style.top = new_top+"px";
}
scroll_bottom = set_scroll_height + new_top;
scroll_percent = scroll_bottom / 412;
online_show = (document.getElementById("online_list").scrollHeight - 412) * scroll_percent;
online_show = Math.round(online_show);
document.getElementById("online_list").scrollTop = online_show;
}
var SCROLL_FLAG = 0;
document.onmouseup = function(){ SCROLL_FLAG = 0; };
document.onmousemove = function(event){ if(SCROLL_FLAG == 1){ADJUST_SCROLL_EVENT(event);} };
Javascript code snippet above
<div style="float: left; width: 13px; position: relative; height: 412px;">
<div id="online_list_scroll" style="width: 5px; position: absolute; top: 0px; left: 4px; border-radius: 4px; background-color: #3f3f3f; height: 15px;"
onmousedown="if(SCROLL_FLAG == 0){ SET_SCROLL_EVENT(event); SCROLL_FLAG = 1; }"></div>
</div>
HTML content above
The scrolling behavior of the scrollbar is erratic and fast, jerking back and forth. It does work but not smoothly as expected. Any help or insight would be greatly appreciated as I have been struggling with this all night.
Thank you in advance for any assistance provided.