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

relativeToWrapper bugfix #240

Closed
wants to merge 1 commit into from
Closed

relativeToWrapper bugfix #240

wants to merge 1 commit into from

Conversation

jakobwiens7
Copy link

Added a condition to make sure scroll event listeners are not being applied to the wrapper element if relativeToWrapper is true. This fixes issue #170 .

@jakobwiens7 jakobwiens7 changed the title Update rellax.js (Bugfix) relativeToWrapper bugfix Feb 3, 2022
@cvillalobos
Copy link

Has anyone else tested this fix? As for me, the animation is still happening on the element even if it is not within the viewPort.
This is my initialization:

var parallaxSlider = new Rellax('.rellax'
    , {
      speed: -2,
      center: true,
        wrapper: '.custom-element',
        relativeToWrapper: true,
      round: false,
      vertical: true,
      horizontal: false,
      breakpoints:[576, 768, 1201]
    });

And still, the animate() function executes and so the image gets hidden due to the scrolling action.

Screen Shot 2022-03-21 at 4 08 07 PM 1

@jakobwiens7
Copy link
Author

That's correct, the animation is still happening outside of the viewport. From my understanding its just the values of speed and percentage that are relative to the wrapper element when using wrapper and relativeToWrapper.

However, without this fix there would be no animation at all, since the scroll listener initially was being applied to the wrapper element and thus listens for some scrolling action happening inside of it. I may be wrong, but i think this feature just doesn't work the way one would expect it to, unfortunately.

@cvillalobos
Copy link

cvillalobos commented Mar 22, 2022

Oh ok, I got your point. Agree with your solution proposed.
Indeed, the custom wrapper does not seem to work as one will expect.

Actually, I have coded a new attribute within the library so the animation takes place only lead by the ViewPort area. This is configurable as needed. If you want to check my proposal here is the link to the PR: New configurable 'leadByViewPort' attribute

@jakobwiens7 jakobwiens7 closed this by deleting the head repository Oct 19, 2023
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

Successfully merging this pull request may close these issues.

2 participants