Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Read
here I
also advise you to read about scrollleft
Here is another option
https://github.com/kasparsj/jquery-data-parallax here is a ready-made example, but it lags, it seems to me.
If I understand correctly, then in principle, you can screw it here, the solution that I gave to a similar question . Only replace scrollTop with scrollLeft Sandbox
example
UPD jsfiddle.net/27mz45L2/1
var elH = horizontal.offsetHeight,
elTop = horizontal.offsetTop,
winH = window.innerHeight,
factor = horizontal.scrollWidth / (elH * 2 + winH);
window.addEventListener('scroll', function (e) {
var elPosTop = horizontal.getBoundingClientRect().top + elH,
elPosBot = horizontal.getBoundingClientRect().bottom - elH;
if ((elPosTop >= 0) && (elPosBot <= winH)) {
var dE = document.documentElement,
top = (this.pageYOffset || dE.scrollTop) - (dE.clientTop || 0);
horizontal.scrollLeft = Math.abs(elTop - winH - top) * factor;
}
}, false);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question