Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallax offset from top #19

Open
theedgy opened this issue Feb 19, 2020 · 2 comments
Open

Parallax offset from top #19

theedgy opened this issue Feb 19, 2020 · 2 comments

Comments

@theedgy
Copy link

theedgy commented Feb 19, 2020

Hi there.
I noticed that you are calculating element height based on offsetTop value which is relative to closes parent. That means when i put your parallax image into some content wrapper in the middle of page height, then this calculations are based on that wrapper and not on window, so it ends up with half of image because of wrong calculations.

PS. As a reference i fixed it by myself for own purposes, but you can review and use it as well. It was about to change the line : https://github.com/marrio-h/universal-parallax/blob/master/dist/universal-parallax.js#L48
into var containerTop = document.documentElement.scrollTop + container.top

@ivarvanwooning
Copy link

Works like a charm, thank you.

@Auriana
Copy link

Auriana commented Oct 3, 2024

Hi,
I had an issue with sticky headers: the parallax backgrounds were shifted according to its parent element (the image wasn't covering the entire element). With this update, the issue is solved, thanks you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants