fix(parallax): child horizontal prop defaults to parent's #1458
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
Currently, when
Parallax
hashorizontal={true}
, allParallaxLayer
s still translate vertically unlesshorizontal={true}
is manually set on all of them. This change makes it soParallaxLayer
s' defaulthorizontal
matchesParallax
's.What
horizontal
toIParallax
interface andParallax
'sstate
ParallaxLayer
to see ifhorizontal === undefined
and reassign it if it is.Checklist
You can test this by looking at the sandbox demo "Parallax" (not vert). Currently, when you scroll horizontally, the layers still translate vertically.
This might be a breaking change if anyone is relying on this behavior, but it wouldn't affect anyone who has already manually set
horizontal
onParallaxLayer
s.I will also submit a PR for the docs to add
horizontal
toParallaxLayer
's prop list, but will wait until a decision is reached on this so I can accurately describe its behavior. I understand everyone is probably busy with v9 bug fixes, so if this is not a high priority right now, I'll just update the docs to reflect how it currently works.