-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add scrollBehavior prop #18
Comments
Can't say I've run into that issue myself but happy to accept a PR. I think it'd make most sense to pass it into Something like this type SnapCarouselGoToOptions = {
readonly behavior: ScrollBehavior;
};
// ...
const { scrollRef, prev, next, goTo } = useSnapCarousel();
return (
<div style={styles.root}>
<button onClick={() => goTo(0, { behavior: 'auto' })}>start</button>
<button onClick={() => prev({ behavior: 'auto' })}>prev</button>
<button onClick={() => next({ behavior: 'auto' })}>next</button>
<ul style={styles.scroll} ref={scrollRef}>
{items.map((item, i) =>
renderItem({
item,
isSnapPoint: snapPointIndexes.has(i)
})
)}
</ul>
</div>
); |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
By default, the scroll behavior in the hook is 'smooth' (see use-snap-carousel.tsx:169).
There is a known bug on chromium based browsers with smooth scroll behavior (ex: https://bugs.chromium.org/p/chromium/issues/detail?id=1299237).
I would like to be able to change the scroll behavior when using the useSnapCarousel hook.
I can do a PR if you want to.
The text was updated successfully, but these errors were encountered: