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

Using "sticky"element offsets parallax container #292

Open
moseleyi opened this issue Apr 29, 2020 · 3 comments
Open

Using "sticky"element offsets parallax container #292

moseleyi opened this issue Apr 29, 2020 · 3 comments

Comments

@moseleyi
Copy link

I use a wrapper with logo and navigation as a position:sticky element but I change its size when somebody scrolls past 100px to take up less space.

Unfortunately both versions of the script make the parallax-mirror to shift.

Here is the image:
image

Basically onload it's aligned with the brown container. But once I start scrolling it also moves down by the difference of height of the sticky element..

@wirion
Copy link

wirion commented Jul 14, 2020

I have the exact same issue. I tried without success 2 different ways to get the images to anchor to a deeper element that does not change size

  • changing the parallax-mirror attachment via data-mirror-selector to the deeper element
  • setting the transform property on the deeper element to something different from none so that the position: fixed images would anchor to it, according to MDN

@carlitoselmago
Copy link

I found a dirty quick way to overcome this issue:

Since the positions get updated on window->resize event you could just trigger a fake resize event. If using jquery it's as easy as calling $(window).resize(); along the event that changes you DOM element to position:fixed;

@levmyshkin
Copy link

levmyshkin commented Sep 1, 2021

$(window).resize(); can be too much, because it will stop your scroll. You can trigger parallax.js event to calculate offset again, when you sticky menu is not fixed anymore:
$(window).trigger('resize.px.parallax');

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

4 participants