-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Multiple active items in each screen #102
Comments
Regarding your first question, having multiple acting items at once is possible but would require some heavy refactoring. I don't have time to work on it at the moment, but I'll keep that in mind for future releases. And yes, as a workaround you can group two elements in one slide to emulate the behavior, if:
Otherwise, I confirm that you can easily reproduce the second layout. Here is a quick example, using the
|
Awesome! Thanks! Great library :-D However, it seems if I have uneven number of items, I can swipe to a non-existing item such that, if I scroll as much as I can to the right, the last item is in the left of the screen and a non-existing item takes up the right part of the screen. |
If you're talking about your first idea (2 slides in one), that's to be expected since your Don't forget that you're "hacking" the plugin ;-) |
is there any known reason why on my app all items are look active even I set inactiveSlide values?
|
@Markortiz What is your React Native version? If it is not one of the latest, see #173 and particularly this comment. |
@bd-arc i'm currently using |
Hi @Markortiz, I didn't realize you've edited your message. Yes, you're right: the loop feature has been released in version You have a choice to make:
No easy path here, sorry. |
@bd-arc How I can solve this problem?
|
Hi @donnes, I'm going to need more info to help you with that. Can you please open a new issue and make sure to follow the contributing guidelines? |
Hi @bd-arc I create a reproduce Snack to be easy to find the problem, here's the link: https://snack.expo.io/ryxxwAeJG As @mazing said earlier, following your example (#102 (comment)) it's will generate a blank space at end of the scroll. If you run the exemple above and scroll to right you'll can see a blank space. I don't know how solve this problem, I tried many things but can't find a solution. |
@donnes I see what you mean. I didn't provide the full example at that time and I now realize that the code from my previous answer can lead to issues like yours. I've modified the Snack you provided to make it work as expected: https://snack.expo.io/Hynr0n-1z They were two problems:
Note that plugin's official example implements those two suggestions. I'll update the relevant doc section to the following: const horizontalMargin = 20;
const slideWidth = 280;
const sliderWidth = Dimensions.get('window').width;
const itemWidth = slideWidth + horizontalMargin * 2;
const itemHeight = 200;
const styles = Stylesheet.create({
slide: {
width: itemWidth,
height: itemHeight,
paddingHorizontal: horizontalMargin
// other styles for your item's container
},
slideInnerContainer: {
width: slideWidth,
flex: 1
// other styles for the visible container
}
}; Do you think it will make things clear enough? |
@bd-arc I believe I did not explain the issue I was passing correctly. Below is an example of the Carousel on the Airbnb app And now the example I sent earlier (https://snack.expo.io/BJ4_VmS1M) Looking at the examples that I sent you can notice that in the second gif, when the scroll comes to the end, there is a red space as if there was a "ghost" Card. I believe that the correct behavior is when the scroll reaches the end, the scroll does not exceed the last Card. Some like this: |
@donnes Ah, I now see what you mean! To be honest, this can prove tough to implement because it would require modifying But I'll make sure to take a look at it, as I agree that this would be better from a user experience point of view ;-) |
@bd-arc I'll create a fork and try take a look about it. Thank you for the good job! :D |
@donnes I've just played with the source code to see what I would be able to do about it, but I unfortunately don't think that it can be implemented at the moment. Currently, we determine the active item when its position meets an imaginary line linked to the value of The
If you have any idea about how to implement it, I'll be glad to hear your thoughts. Because it seems that I'm kind of stuck until Facebook improves the underlying components (by the way, you can vote to let their team know about it ;-)). |
@bd-arc I had previously tried implemented myself carousel component using FlatList and I got these problems too. Aparently the only way is use ScrollView (for IOs) and ViewPagerAndroid (for Android) but yet I got some problems with the latest versions of React Native (0.50+). By the way, I'll stud the repo code and try some solutions and I back if find something. And also, I'm going to vote for these features as you are suggested. Again, thank you for the good job! 👍 |
@donnes While the plugin is based on The As you can see, I've tried a lot of things to improve the plugin, but RN's core always gets in the way. I'll be pretty glad if you manage to find a solution :-) |
You can style Carousel with prop contentContainerCustomStyle |
Yeah, it's a huge miss in my opinion too. |
@univers3 I heartily agree with you and I'd really like to be able to implement it this way. But if you've read this comment, you already know that this is no piece of cake and that the horde of React Native bugs add another layer of complexity... |
@phithu Amazing! Although it's not an implementation in the module but instead just limiting the width, it works perfectly in my case. For reference, this is what I did: <Carousel
data={this.props.data}
renderItem={this._renderItem}
itemWidth={100}
activeSlideAlignment={'start'}
{/** Other props here... */}
contentContainerCustomStyle={{
overflow: 'hidden',
width: 100 * this.props.data.length
}}
/> |
thank you @FoxInFlame @phithu! Wanted to note that on Android 9 devices when only SINGLE item Carousel is broken by setting
|
I'm just using snap-carousel recently and come across this issue as well for the 'right empty space'. I got the solution but require to add some additional code in Carousel.js lastly, in function:
should do the trick. |
Hi @t-vc, Thanks for sharing your idea! Will it work with all values of |
Do you have any update on this? I was looking for a solution also |
Hi, sorry i didn't realise a reply until @kristoff2016 recent comment. |
@t-vc I hope you can share the solution how can you remove the right white space. thanks in advance :) |
if u notice the original code, this._position[index] is actually calculating each item (start from first to last) snap point, i just add an IF statement to change the last item's snap point, that's all. |
thanks for sharing which file change that I should change or do it? or go to change in the original file in this library? could you help advice me? thank you in advance |
just modify the original file |
Yes, it is working well now. sorry for one more question should I move this lib to my original project? if I have ever do run |
I'm afraid u will have to do so until the author adopt this solution into his latest update. |
Have you raised this PR to the Author? I think it would be great if you could help the Author for this issue that there are many users using yours as well I think. |
Actually I'm not familiar with github. I just registered to share my solution. If u can do it then it would be great. |
Okay, I will do it! |
Thanks a lot, although it is still some touch up to do to make it perfect but I'm sure the author can make it better. |
Waiting the author review the code and approval |
Thanks @kristoff2016! Now we just need to get some people to test it and make sure it doesn't break anything. I've gotten cautious after merging some PR that had a lot of negative side effects for some users... |
Hello, @bd-arc I would say that there is no effect in this PR I tested them all in IOS and Android version in a real device. But Yes, sure we might need some people to test it and make sure that won't affect anything, anyway, thank you very much for very nice plugin. |
can someone send me link https://github.com/archriss/react-native-snap-carousel/tree/flatlist i can't access it @bd-arc |
This is the code and And then use it like this return <Carousel
data={data}
renderItem={this._renderItem.bind(this)}
sliderWidth={deviceWidth}
sliderHeight={pxToDp(296)}
itemWidth={width1}
inactiveSlideScale={0.842}
loop hasParallaxImages has2Item
inactiveSlideOpacity={1}
activeAnimationType={'decay'}
activeSlideAlignment={'custom'}
customMargin={width1}
slideStyle={styles.imageContainer}
lockScrollWhileSnapping removeClippedSubviews
/> <TouchableOpacity activeOpacity={0.8} key={index}>
<ParallaxImage
source={{ uri: 'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1906469856,4113625838&fm=26&gp=0.jpg' }} showSpinner={false}
containerStyle={styles.imageContainer}
style={styles.image}
parallaxFactor={0}
dimensions={{ width: pxToDp(177), height: pxToDp(256) }}
{...parallaxProps}
/>
</TouchableOpacity> |
I have solved this problem |
Hi, when will this PR be merged into the code? I think it's really useful to solve this problem. |
Would it be possible to have multiple items at one slide just like Apple Music:
Would the right approach be to change data such that all elements are grouped with two elements in each group and then print the two elements side-by-side when rendering each item?
However, Airbnb has the same feature where no items are active, but you can only scroll such that two elements are always visible. Can the same behaviour be achieved with the right size options with
react-native-snap-carousel
?The text was updated successfully, but these errors were encountered: