react-native-reanimated-carousel icon indicating copy to clipboard operation
react-native-reanimated-carousel copied to clipboard

What layout style do you want?

Open dohooo opened this issue 3 years ago • 49 comments

Writing here!

BTW, looking forward to your PR!~ 🍺

dohooo avatar Jan 07 '22 16:01 dohooo

scale-fade-in-out

dohooo avatar Jan 08 '22 15:01 dohooo

image

dohooo avatar Jan 09 '22 13:01 dohooo

image

dohooo avatar Jan 09 '22 13:01 dohooo

rotate-scale-fade-in-out

dohooo avatar Jan 11 '22 04:01 dohooo

rotate-in-out

dohooo avatar Jan 11 '22 04:01 dohooo

anim-tab-bar

dohooo avatar Jan 11 '22 04:01 dohooo

Hello,

I want to do something like this. I believe the current "Parallax" solves this, but I have doubts about how to change the size of the item that is not in focus. image

yepMad avatar Feb 26 '22 20:02 yepMad

Hello,

I want to do something like this. I believe the current "Parallax" solves this, but I have doubts about how to change the size of the item that is not in focus. image

https://github.com/dohooo/react-native-reanimated-carousel/blob/main/src/layouts/ParallaxLayout.tsx#L75 here

dohooo avatar Feb 26 '22 22:02 dohooo

https://github.com/dohooo/react-native-reanimated-carousel/blob/main/src/layouts/ParallaxLayout.tsx#L75 here

Thank you! I actually turned this change into a property. In case you find it interesting, I can make a commit with it.

image

yepMad avatar Feb 27 '22 00:02 yepMad

cool,let me a look

dohooo avatar Feb 27 '22 00:02 dohooo

https://github.com/dohooo/react-native-reanimated-carousel/blob/main/src/layouts/ParallaxLayout.tsx#L75 here

Thank you! I actually turned this change into a property. In case you find it interesting, I can make a commit with it.

image

You are the first one to submit layout, thank you for your contribution!~

dohooo avatar Feb 27 '22 00:02 dohooo

You are the first one to submit layout, thank you for your contribution!~

I am happy with that! You can see what I did in this PR. It was simple changes, and a little quick, let me know if there are any side effects or problems. https://github.com/dohooo/react-native-reanimated-carousel/pull/139

yepMad avatar Feb 27 '22 00:02 yepMad

You are the first one to submit layout, thank you for your contribution!~

I am happy with that! You can see what I did in this PR. It was simple changes, and a little quick, let me know if there are any side effects or problems. #139

I released v2.3.1 just now, THX!~ @yepMad

dohooo avatar Feb 28 '22 12:02 dohooo

It would be great to have support for multiple items per a page. I was able to achieve this by setting the width to 50%, and adding a style of overflow: "visible", but this seems a bit hacky, as it's actually leaving the carousel wrapper entirely. As well, you'll notice when not looping the last element can still be scrolled to, leaving an awkward space. Ideally we could customize maxPages to something like data.length - itemsPerPage in order to prohibit the last swipe.

Happy to spend some time contributing to this if you could point me in the right direction.

Simulator Screen Recording - iPhone 13 - 2022-03-02 at 15 35 59

IAmNatch avatar Mar 02 '22 20:03 IAmNatch

One other request: "Auto Height" for horizontal layouts. I know this might not be possible, as the items are currently all positioned absolutely, but it would be great to be able to size to height of the carousel based on the height of the contents. This was achievable in snap-carousel, but they may have been using a very different strategy.

IAmNatch avatar Mar 02 '22 20:03 IAmNatch

@IAmNatch here, Let's discuss it

dohooo avatar Mar 03 '22 02:03 dohooo

@IAmNatch were you able to figure this out, thanks for the help if you can

testermumatstudio avatar Apr 08 '22 06:04 testermumatstudio

hello, where can I find an example to show more than one item

testermumatstudio avatar Apr 08 '22 06:04 testermumatstudio

hello, where can I find an example to show more than one item

What do you mean?

dohooo avatar Apr 08 '22 07:04 dohooo

https://user-images.githubusercontent.com/15078788/156445400-0c2a7f6c-7da2-40a9-9872-2669134bf535.gif some like this, display multiple items in carousel, where can i get this example , as mentioned @IAmNatch, if I want to display 1, 2, 4, 6 elements

testermumatstudio avatar Apr 09 '22 03:04 testermumatstudio

https://user-images.githubusercontent.com/15078788/156445400-0c2a7f6c-7da2-40a9-9872-2669134bf535.gif some like this, display multiple items in carousel, where can i get this example , as mentioned @IAmNatch, if I want to display 1, 2, 4, 6 elements

image

I added an example. You can look at this demo in home page, and click that gif it will navigate you to code example. 🍺

dohooo avatar Apr 09 '22 06:04 dohooo

https://user-images.githubusercontent.com/15078788/156445400-0c2a7f6c-7da2-40a9-9872-2669134bf535.gif some like this, display multiple items in carousel, where can i get this example , as mentioned @IAmNatch, if I want to display 1, 2, 4, 6 elements

BTW, This code will control the number of items that displaied. image

dohooo avatar Apr 09 '22 06:04 dohooo

https://user-images.githubusercontent.com/15078788/156445400-0c2a7f6c-7da2-40a9-9872-2669134bf535.gif some like this, display multiple items in carousel, where can i get this example , as mentioned @IAmNatch, if I want to display 1, 2, 4, 6 elements

BTW, This code will control the number of items that displaied. image

grateful for your help and your time, really thanks, I'm going to try and study the code

testermumatstudio avatar Apr 10 '22 07:04 testermumatstudio

@dohooo hi thanks for this amazing library, can we use this as a swiper like tinder?

Nadimkhan120 avatar Apr 11 '22 11:04 Nadimkhan120

i have this code I can't get it to show 1, 2, 4, 6 items, I want to be able to use the count and make it work... on the other hand, create an issue to be able to pass style props or breakpoints of any library, can you help me, please

this is carousel:

const COUNT = 6


export interface Props {
}

interface State {
  width: number;
  data:any;
  PAGE_WIDTH:any;
  isVertical:any;
  user:any;
}

import CurrentUserStore from "../../../../stores/CurrentUserStore";
import ResponsiveWidthStore from "../../../../stores/ResponsiveWidthStore";
import { Collection } from "../../../../models/IdentityModels";

import CardCollectionsCarousel from '../../../Cards/CardsExplore/CardCollectionsCarousel/CardCollectionsCarousel'

import CardCollections from '../../../Cards/CardsFran/CardCollections/CardCollections'


export default class CarouselSales extends ComponentBase<Props, State> {

    
private r
protected _buildState(props: Props, initState: boolean) {
   
     const partialState: Partial<State> = {
      data: CurrentUserStore.getCollectionsSongbird().filter((value)=>value.name!==""),
      PAGE_WIDTH:ResponsiveWidthStore.getWidth(),
      width:ResponsiveWidthStore.getWidth(),
      user:CurrentUserStore.getUser(),
      isVertical:false
  };
  
this.r = React.createRef<ICarouselInstance | null>(null);
return partialState;
}

  
renderItem = ({item, index}:{item:Collection, index}) => {
console.log("item"+JSON.stringify(item))

    return (   
      <Box sx={styles.item} >
        <CardCollections key={index} index={index} userAvatar={item.userAvatar}  ownerAddress={item.owner} tokenAddress={item.collectionAddress}  user={this.state.user} name={item.name} description={item.description} filePath={item.filePath}  />
      </Box>
    );
  }

  private baseOptions =({
        vertical: false,
        width: 1300 / COUNT,
        height: 260,
        style: {
            width: 1300,
        },
    } as const);

render(){
return (

  <Stack  sx={{mx:15}}>
    <Stack  direction='row' sx={{alignItems:'center',justifyContent:'space-between', mb:5}}>

        <Typography sx={{ fontFamily:"Poppins_400Regular",color:"white" ,alignSelf:'center',fontSize:35,  }}>
          Hot Collections
        </Typography>

        <Stack direction='row' mt={2} spacing={5} sx={{alignItems:'center', alignSelf:'center',justifyContent:'center'}}>
          <FontAwesome5 name="arrow-left" size={24} color="white" onPress={() => this.r.current?.next()}/>
          <FontAwesome5 name="arrow-right" size={24} color="white" onPress={() => this.r.current?.prev()}/>
        </Stack>

    </Stack>

    <Box sx={{width:'100%', alignSelf:'center',justifyContent:'center'}}>
      <Carousel
        {...this.baseOptions}
        ref={this.r}
        data={this.state.data}
        renderItem={this.renderItem}
      />
    </Box>
  </Stack>
  )}
}

const styles ={
  container: {
    flex: 1,
    marginHorizontal:15
  },
  container2: {
    flex: 1,
    marginHorizontal:10
  },
  item: {
    alignSelf: 'center',
    justifyContent: 'center',
    marginHorizontal:5
  },
  itemInvisible: {
    backgroundColor: 'transparent',
  },
};

this is my card component:


const useStyles = makeStyles(() => ({
  card: {
    backgroundColor:'#16151A',
    border: '0.5px solid #474747',
    borderRadius: 14,
    transition: '0.4s',
    '&:hover': {
      borderColor: '#676767',
    },
    width: 220,
    height:240,
    color:' #fff',
  },
  container: {
    justifyContent: 'center',
    alignItems:'center',
    fontWeight: 100,
  },


}));

export default function CardPrincipal( props): JSX.Element {
  const styles = useStyles();
  const { index } = props;
  return ( 
<Box className={styles.card}>

  <CardMedia
    component="img"
    sx={{      
    width: '100%',
    height:120,
    borderTopLeftRadius:14,
    borderTopRightRadius:14 }}
    src="https://www.xtrafondos.com/wallpapers/montanas-minimalista-flat-3128.jpg" 
    alt="Image Perfil NFT" />
  
  <Box className={styles.container} >
    <Typography 
      sx={{
        fontFamily:"Poppins_600SemiBold",
        color:"white",
        overflow: 'hidden',
        textOverflow: 'ellipsis',
        fontSize:18
      }}>
        Lily Rose { index }
    </Typography>

    <Typography 
      sx={{
        fontFamily:"Poppins_400Regular",
        color:"#838990",
        overflow: 'hidden',
        textOverflow: 'ellipsis',
        fontSize:12
      }}>
        ERC-1155
    </Typography>
  </Box>

</Box>
)}

Here is an example of how it looks, the black space on the right allows me to move the ccarousel with the mouse but it does not render the other card

https://gateway.pinata.cloud/ipfs/QmeMVb6VDGFNrHWZFv8Qv6TAi6cjgrNCsmvJigseki29wS https://gateway.pinata.cloud/ipfs/QmUFcsKi2eHMrV7At4wXnvkRRyNJU7GJHTGzcwdA7fWa7o

and in this example I would like to pass mui props or any library that allows me to break points, and grab the automatic width or height as how much one places width:'100%' in mui, here is the example


  private baseOptions =({
        vertical: false,
        width: '100%'/ COUNT, <======  HERE is the problem 
        height: 260,
        style: {
            width:  {xs:200,sm: 250, md: 500, lg: 800}, <======  HERE is the problem  
        },
    } as const);

I hope you can help me thanks

testermumatstudio avatar Apr 21 '22 02:04 testermumatstudio

@dohooo hey, thanks so much for this it's working great! +1 request for auto height, is this currently possible with react-native-reanimated-carousel?

louisholley avatar May 12 '22 08:05 louisholley

@dohooo hi thanks for this amazing library, can we use this as a swiper like tinder?

hi, you have closed the request, have you implemented it, or you have just closed it.

Nadeemkhan122 avatar May 15 '22 17:05 Nadeemkhan122

@dohooo hey, thanks so much for this it's working great! +1 request for auto height, is this currently possible with react-native-reanimated-carousel?

uh.. auto height doesn't match our current implementation. Because currently is the absolute layout, if u haven't set height it will show nothing.

dohooo avatar May 16 '22 02:05 dohooo

@dohooo hi thanks for this amazing library, can we use this as a swiper like tinder?

hi, you have closed the request, have you implemented it, or you have just closed it.

I just closed it 😐. I think tinder animation isn't look like carousel.

dohooo avatar May 16 '22 02:05 dohooo

+1 for dynamic height @louisholley @IAmNatch Did you find a way to implement it? Or an alternative lib?

marcoturi avatar May 19 '22 18:05 marcoturi