-
Notifications
You must be signed in to change notification settings - Fork 156
Closed
Labels
Description
⚠️ V3 is out! ⚠️
yarn add react-scroll-parallax
If you encounter issues or bugs throw a comment in this thread.
V3
This is to address some long standing enhancement requests and to improve/modernize the code base so that I and others are more willing to contribute once again.
Documentation and demos (WIP):
Goals
- Better documentation and examples
- Address long standing requests for new features like applying other transforms
- Simplify basic usage (add
speed
prop) - Refactor everything to TypeScript
- Separate core (non React) functionality to a new package/dependency (parallax-controller)
Component Changes
x
andy
props becometranslateX
andtranslateY
- Add
rotate
transforms:rotateX
,rotateY
,rotateZ
- Add
scale
transforms:scaleX
,scaleY
,scaleZ
- Add
opacity
prop - Add
speed
prop. Example:<Parallax speed={-1} />
- Add
easing
functions - non linear effect transitions - Add
rootMargin
to apply as element boundary that determine start/ending transitions and when an element enters/leaves the viewport - Add callbacks for events:
onProgressChange
,onEnter
,onExit
- Add
shouldAlwaysCompleteAnimation
option to solve ParallaxBanner > When scroll position at top, transform doesn't start from 0 #122 - Add
startScroll
andendScroll
options to set scroll top/left bounds manually.
New Hook
Add useParallax
hook to setup an element.
const Component = () => {
const { ref } = useParallax({ translateY: [100, -100] });
return (
<div ref={ref}>
<div />
</div>
);
};
Possible Updates/Considerations
Expose internal value of(onProgressChange)percentMoved
via callback for custom transformsUse CSS variables to apply transformsHandle cases where scroll is at top but element starts in the view. Requires an optional way to set start position.(shouldAlwaysCompleteAnimation)Add atargetElement
to use as the scroll progressAllow setting scroll bounds manually viastartScroll
andendScroll
values, instead of relying on the elements position for progress updates.
TODOs
- Publish an alpha to start testing
react-scroll-parallax@alpha
- Publish new storybook https://react-scroll-parallax-v3.surge.sh/
Please feel free to add comments and requests to this issue.