-
Notifications
You must be signed in to change notification settings - Fork 63
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
React-native-wheely infinite scroll #42
Comments
Cool idea, but I will not be able to implement it, you can give it a try and make PR :) |
@erksch
and you can call it like this:
video_2024-08-03_07-00-55.mp4I hope that is helpful. |
YOU GENIUS 🤩 Just what I needed |
@Mahmood-AlHajjo Pretty cool trick 😄 |
I have a question about your trick. const [selectedMinute, setSelectedMinute] = useState<number>(Number(minute));
const hours = Array.from({ length: 60 }, (_, i) => (i + 1).toString());
<InfiniteWheelPicker
selectedIndex={hours.indexOf(selectedHour.toString())}
options={hours}
onChange={index => setSelectedHour(hours[index])}
itemStyle={styles.itemStyle}
itemTextStyle={{
fontSize: 18,
fontWeight: 'bold',
}}
containerStyle={{ flex: 1, alignItems: 'flex-end' }}
selectedIndicatorStyle={{
backgroundColor: '#F4F4F5',
borderRadius: 0,
borderTopLeftRadius: 8,
borderBottomLeftRadius: 8,
}}
/> const InfiniteWheelPicker = ({
options,
selectedIndex,
onChange,
...rest
}) => {
const extendedOptions = [...options, ...options, ...options];
const middleIndex = Math.floor(extendedOptions.length / 3) + selectedIndex;
const handleIndexChange = index => {
const newIndex = index % options.length;
onChange(newIndex);
};
return (
<WheelPicker
selectedIndex={middleIndex}
options={extendedOptions}
onChange={handleIndexChange}
flatListProps={{
initialNumToRender: extendedOptions.length,
getItemLayout: (_, index) => ({ length: 70, offset: 70 * index, index }),
}}
visibleRest={1}
itemHeight={70}
{...rest}
/>
);
}; But visibleRest={1} is not available. The option disappears like this, and then you scroll back to see it again.. Is there any solution to this problem? |
Hi, is it possible when I reach the last item on my list to show again the first item? Like infinite scroll at the picker wheely?
The text was updated successfully, but these errors were encountered: