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

Add a new boolean option, relativeToWrapper. #125

Merged
merged 1 commit into from
Sep 15, 2018

Conversation

MadsMadsDk
Copy link

This addition originates from the need to let movement be relative to a wrapper, rather than scroll position of a wrapper or the scroll position of the window.
We'll use the wrappers vertical offset, and subtract it from the scrollposition, to enable an effect, that feels like the element is relative to its wrapper instead.

Simply a boolean, telling us whether or not it should be relative to the container selected in the wrapper option.

This addition originates from the need to let movement be relative to a wrapper, rather than scroll position of a wrapper or the scroll position of the window.
We'll use the wrappers vertical offset, and subtract it from the scrollposition, to enable an effect, that feels like the element is relative to its wrapper instead.

Simply a boolean, telling us whether or not it should be relative to the container selected in the wrapper option.
@MadsMadsDk MadsMadsDk mentioned this pull request Sep 3, 2018
@simgooder
Copy link

simgooder commented Sep 5, 2018

I just reviewed this as a potential fix, and for my use case, this seems to do the trick. I was half expecting this to support multiple wrapper options. I'll have to take further look when I get some time.
Your fix works as expected.

@salunet
Copy link

salunet commented Sep 7, 2018

How can i use this for horizontal scrolling?

@MadsMadsDk
Copy link
Author

This feature is currently only supported for vertical scrolling.

@salunet
Copy link

salunet commented Sep 7, 2018

@MadsMadsDk can you make it work for horizontal scrolling?

@moeamaya
Copy link
Member

@MadsMadsDk Should I merge or you interested in adding it for horizontal?

@MadsMadsDk
Copy link
Author

@moeamaya You can merge this - I'll do another PR for horizontal if I get the time to look into it. Shouldn't be too hard though.

@moeamaya moeamaya merged commit fdd78ad into dixonandmoe:master Sep 15, 2018
@lindsayweb
Copy link

Does relativeToWrapper still work with the current version of Rellax? When I add relativeToWrapper:true, the rellax elements stop moving. The transform CSS does not change on scroll.

@cristian-rodriguez-glb
Copy link

Same thing using wrapper: this.parentElement 😞

@one-juru
Copy link

This is a great addition, but it seems to be broken in the current version (if I'm not mistaken)

As far as my understanding goes, setting a wrapper will enable Rellax to use the scroll position inside the wrapper for the movement. If there is no scrolling inside the element which was set as a wrapper, Rellax won't move anything. This option (relativeToWrapper) is supposed to change that behavior, and instead still takes the scroll position of the body but calculates the difference between the body and the wrapper element, so that is seems as if the element only moves after the wrapper element is seen by the user. Is this a correct understanding of this option?

Using "relativeToWrapper" at the moment will result in the object being further down the page (so I can confirm that the initial calculation (body minus position of the wrapper element) still works) but it won't move and stick to the position that initially was calculated. If my understanding is correct, the element is supposed to move with the scroll position of the body if relativeToWrapper is set to true

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.

8 participants