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

Parallaxed elements jump to incorrect positions on resize #57

Open
trijammer opened this issue Feb 21, 2019 · 0 comments
Open

Parallaxed elements jump to incorrect positions on resize #57

trijammer opened this issue Feb 21, 2019 · 0 comments

Comments

@trijammer
Copy link

The resize and scroll events use different calculations to position the parallaxed elements. Resize doesn't factor in the current scroll position, so when resizing after scrolling the parallaxed elements jump to an incorrect position.

$(window).on('resize', function () {
...
  bgOffset = Math.round(offset * factor);
  transform = Math.round((offset - (windowHeight / 2) + height) * factor);
...

VS

$(window).on('scroll', function () {
...
  bgOffset = Math.round((offset - scrolling) * factor);
  transform = Math.round(((offset - (windowHeight / 2) + height) - scrolling) * factor);
...

I've fixed this on my sites by copying the on scroll calculation to on resize.

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

1 participant