I have an element that has a fixed position, but has the ability to scroll left and right using the jQuery calculation that I used from this example in JsFiddle.
$(window).scroll(function(event) {
var x = 0 - $(this).scrollLeft();
var y = $(this).scrollTop();
if (y >= top) {
$('.scroll_fixed').addClass('fixed');
} else {
$('.scroll_fixed').removeClass('fixed');
}
$(".scroll_fixed").offset({
left: x + leftInit
});
});
The solution works well until I have to scroll left, where the element scrolls "parallaxes" against the rest of the document - i.e. it scrolls about twice as fast as the rest of the document.
I know this is a problem with jQuery calculation, but was it interesting if someone came across this before? and if so, how did you deal with this? I am at a loss ....
change
- , $(window).scrollLeft(); , .
div "wrapperDiv", $( ". wrapperDiv" ). scrollLeft();
, , Stack Overflow, 7 ....