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 hasPrevPage and hasNextPage booleans #29

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

jasongerbes
Copy link
Contributor

This PR adds hasPrevPage and hasNextPage booleans to SnapCarouselResult to indicate if there's a previous or next page to scroll to.

@richardscarrott, I have updated the README.md and Storybook components to use these new properties. You may also want to update the CodeSandbox example after this change has been released.

Closes #28.

@jasongerbes jasongerbes marked this pull request as ready for review September 10, 2024 21:21
}}
onClick={() => prev()}
disabled={!hasPrevPage}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Owner

@richardscarrott richardscarrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks for sending this PR, appreciate it 👍

I'll publish a new release once I get a sec.

@richardscarrott richardscarrott merged commit 832e1bb into richardscarrott:main Sep 12, 2024
2 checks passed
@richardscarrott
Copy link
Owner

This is available in a pre-release https://github.com/richardscarrott/react-snap-carousel/releases/tag/v0.5.0-next.1 -- npm add react-snap-carousel@0.5.0-next.1

I'll run it in production for a little bit and then make it available as v0.5.0 proper.

@richardscarrott
Copy link
Owner

@jasongerbes
Copy link
Contributor Author

Thanks @richardscarrott! 🎉

Unrelated, have you considered adding support for autoplay?

It’d be neat if react-snap-carousel could be used to create something similar to Apple’s scroll-based carousels with autoplay:

ScreenRecording_09-21-2024.08-36-42_1.mov

https://www.apple.com/iphone-16-pro/

@richardscarrott
Copy link
Owner

@jasongerbes I think that UI could be built relatively easily on top of what react-snap-carousel already offers -- imo it's prob best react-snap-carousel doesn't get involved with the timer logic as, for example in that instance, each item's video could be a different length so an out-the-box autoplay function likely wouldn't suffice -- there is a very basic example of autoplay here -- #17

re: playing the video when an item becomes active, that could be done using activePageIndex (similar to showing the text here) or alternatively I've found
useInView from framer-motion to be quite effective as it factors in all scroll parents.

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.

Feature Request: Add prevDisabled and nextDisabled
2 participants