-
Notifications
You must be signed in to change notification settings - Fork 484
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
Deprecate package, do not use #676
Comments
If this is being deprecated, any suggestions of good alternatives? |
|
As a side note, at MUI, we have the plan to bring a native carousel component into MUI's product: mui/material-ui#33392, mui/mui-x#3601. I don't know if we will start from my project (react-swipeable-views), it will be up to the engineering of the team who takes ownership of it. |
I replaced usage of this library with my own tiny implementation and it is working just fine for me: import { useEffect, useRef } from "react"
export function SwipeableViews(
{ className = "", index, onChangeIndex, ...rootProps }:
{ index: number, onChangeIndex: (index: number) => void } & React.HTMLProps<HTMLDivElement>
) {
const containerRef = useRef<HTMLDivElement>(null)
const scrollTimeout = useRef<number>()
useEffect(() => {
containerRef.current?.children[index]?.scrollIntoView({ behavior: "smooth" })
}, [index])
return (
<div
{...rootProps}
ref={containerRef}
className={
"flex snap-x snap-mandatory overflow-x-scroll " +
"*:w-full *:flex-shrink-0 *:snap-center *:snap-always " + className
}
onScroll={({ currentTarget }) => {
if (scrollTimeout.current) clearTimeout(scrollTimeout.current)
scrollTimeout.current = window.setTimeout(() => {
const pageWidth = currentTarget.scrollWidth / currentTarget.children.length
onChangeIndex(Math.round(currentTarget.scrollLeft / pageWidth))
}, 100)
}}
/>
)
}
It also doesn't animate container's height. The height is just max height of children. You can give max-height to children and make them scrollable instead. It probably doesn't work in react-native, because it uses scroll-snap. Codesandbox (version without tailwind) (edit: updated with more features) Edit2: I made a library |
@phaux can you make this a library on npm? |
Maybe. In the meanwhile you can just copy Edit: Here's the library |
Considering that #558 has been up for 3 years with no real progress on finding a maintainer to take over the ownership of this project, I think that it's time to start the deprecation process of it. This issue is the first step, it will help the community coordinate on who to remove this dependence.
Next, we will need to:
Thanks everyone!
The text was updated successfully, but these errors were encountered: