Skip to content
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

If InfiniteLoop is true, it comes out from the end of data #744

Open
Leekee0905 opened this issue Sep 1, 2023 · 3 comments
Open

If InfiniteLoop is true, it comes out from the end of data #744

Leekee0905 opened this issue Sep 1, 2023 · 3 comments

Comments

@Leekee0905
Copy link

  const slides = Array.from({ length: 4}).map((_, index) => (
    <Box key={index} style={{
      display: 'flex',
      flexDirection: 'row',
      justifyContent: 'center',
      alignItems: 'center'
    }}>
      {bookData
        .slice(index * itemPerPage, (index + 1) * itemPerPage)
        .map((item:any, itemIndex:number) => {
          return(
          <Box key={itemIndex}>
            <Paper  style={{ margin: '0 15px', height: '300px', width: '200px', cursor: 'pointer', marginBottom: '12px'}}>
                <img src={item.thumbnailUrl} alt='book' style={{height: '300px', width: '200px'}} loading='lazy'/>
            </Paper>
            <Typography sx={{fontSize: '12px', maxWidth: '200px',overflow: 'hidden', textOverflow: 'ellipsis',margin: '0 auto' }}>
                {item.title}
            </Typography>
          </Box>
          
        )})}
    </Box>
  ));


<Carousel
          showArrows={true}
          emulateTouch={true}
          showStatus={false}
          showThumbs={false}
          infiniteLoop={true}
          autoPlay={true}
          selectedItem={0}
          renderArrowPrev={(onClickHandler, hasPrev, label) =>
            hasPrev && renderCustomArrow(onClickHandler, label, 'prev')
          }
          renderArrowNext={(onClickHandler, hasNext, label) =>
            hasNext && renderCustomArrow(onClickHandler, label, 'next')
          }
          className="custom-carousel-container"
        >
          {slides}
</Carousel>

Desktop (please complete the following information):

  • OS: Windows
  • Browser chrome
  • Version 116.0.5845.141

If InfiniteLoop is True when the browser is rendered, it comes out from the end of the data even though the selectedItem is 0,
and if InfiniteLoop is False, it comes out from the beginning

When you see four items on a carousel page when the length of the data is 10
If there are 2 items on the last page, the last 2 items will be on the first carousel page when it is rendered for the first time, and if you go back to the beginning when you turn the carousel page, you will see 4 original data

@hunxjunedo
Copy link

I think that is intended and for a purpose.

@elkingarcia11
Copy link

Have you managed to resolve this issue? I'm encountering the same problem. The final item appears on the initial slide, despite being assigned the last index.

@ib45kc
Copy link

ib45kc commented Jun 22, 2024

you can fix add ref and action
sliderRef.current?.moveTo(0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants