Question title might be bit confusing, but please have a look at this fiddle for more info.
I have a container with scrollbar and one element fixed left to it. When I am scrolling I would like to make fixed element content
also scrolling. Here is the code
$('.parent').on('scroll', function(){
var top = $(this).scrollTop(), _top = $('.right').offset().top;
$('.left').animate({
scrollTop : top - _top
},0)
});
Please refer to fiddle for demo.
This is working but there is some non uniform scrolling and I am unable to fix it.
I think the extra subtraction of _top is causing the uniformity issue, since it is recalculating the offset top each time, and continually subtracting it.
$('.parent').on('scroll', function(){
var top = $(this).scrollTop(), _top = $('.right').offset().top;
$('.left').animate({
scrollTop : top
},0)
});
Appears to let the scrolling be more uniform, minus some padding issues.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments