I've been having the hardest time getting an element to be pinned to the left side of the page but also be able to scroll up and down.
I have already tried the method where you just change the left position to $(window).scrollLeft(), but this gives a very choppy-looking animation.
What i'm looking for is the opposite of this fiddle, but I can't quite get it to work:
var leftInit = $(".scroll_fixed").offset().left;
var top = $('.scroll_fixed').offset().top - parseFloat($('.scroll_fixed').css('margin- top').replace(/auto/, 0));
$(window).scroll(function(event) {
var x = 0 - $(this).scrollLeft();
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('.scroll_fixed').addClass('fixed');
} else {
// otherwise remove it
$('.scroll_fixed').removeClass('fixed');
}
$(".scroll_fixed").offset({
left: x + leftInit
});
});
Notice that this div is fixed top but not left. I'm looking for the opposite, fixed left and not top. Any ideas?
I tried editing this fiddle but can't get it working.