Jitender
Jitender

Reputation: 7969

scrollable div using css and jquery

I want to make custom scroll for my div. I have write some code but it is not working fine. First of all it is on mousemove . This should be work like other scroll works. Fiddle

here is code

var height = $('.frm').height(),
overflowHeight= $('.overflow').height();    
var finalheight = overflowHeight-height;
$('.tab').mousemove(function(e){
var top= parseInt($('.tab').css('top'));
var ac= top;
$('.overflow').css({top:-ac})
var y= e.pageY;
$(this).css({top:y})    

Upvotes: 0

Views: 69

Answers (1)

Parthik Gosar
Parthik Gosar

Reputation: 11646

I changed your code a little,

var height = $('.frm').height(),
overflowHeight= $('.overflow').height();    
var finalheight = overflowHeight-height;

$('.scroll').mousemove(function(e){
    var top= parseInt($('.tab').css('top'));
    var ac= top;
    $('.overflow').css({top:-ac})
    var y= e.clientY;
    $(".tab").css({top:y})  
});

Fiddle http://jsfiddle.net/v6qsu/2/

Also there are many libraries available which you could use for custom scrolling , like jscrollpane

http://jscrollpane.kelvinluck.com/

Upvotes: 1

Related Questions