Skip to content

V3 #123

@jscottsmith

Description

@jscottsmith

⚠️ 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):

  1. V3 Docs
  2. V3 Demo Site
  3. V3 Storybook
  4. V2 Migration Guide

Goals

Component Changes

  1. x and y props become translateX and translateY
  2. Add rotate transforms: rotateX, rotateY, rotateZ
  3. Add scale transforms: scaleX, scaleY, scaleZ
  4. Add opacity prop
  5. Add speed prop. Example: <Parallax speed={-1} />
  6. Add easing functions - non linear effect transitions
  7. Add rootMargin to apply as element boundary that determine start/ending transitions and when an element enters/leaves the viewport
  8. Add callbacks for events: onProgressChange, onEnter, onExit
  9. Add shouldAlwaysCompleteAnimation option to solve ParallaxBanner > When scroll position at top, transform doesn't start from 0  #122
  10. Add startScroll and endScroll 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

  1. Expose internal value of percentMoved via callback for custom transforms (onProgressChange)
  2. Use CSS variables to apply transforms
  3. Handle cases where scroll is at top but element starts in the view. Requires an optional way to set start position. (shouldAlwaysCompleteAnimation)
  4. Add a targetElement to use as the scroll progress
  5. Allow setting scroll bounds manually via startScroll and endScroll values, instead of relying on the elements position for progress updates.

TODOs

Please feel free to add comments and requests to this issue.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions