Closed exoer closed 2 years ago
😳 you're absolutely right, the second image is the initial one in view. I've never noticed before.
It looks to be an issue with flex box and the order
css attribute and how we determine what is "next/previous" image.
The carousel is something I mimicked a long time ago from here.
I'd love a PR that fixes this if you want.
BTW. It would be nice with an example that didn't use styled components
What would you like to see used? Could include in the above PR 😸
I was trying to solve this with this code, but with no luck, on the next it always render a blank space before, why it is working on prev and not on next IDK
transform: ${(props) => {
if (!props.sliding) return 'translateX(calc(0%))';
if (props.dir === PREV) return 'translateX(calc(-100%))';
if (props.dir === NEXT) return 'translateX(calc(100%))';
return 'translateX(calc(0%))';
}};
what resolved for me the sequence was to change my carousel slider array something to this :
const carouselData = [{ ...data[data.length - 1] }, ...data, { ...data[0] }, { ...data[1] }];
as also the style:
transition: ${(props) => (props.sliding ? 'none' : 'transform 1s ease')};
transform: ${(props) => {
if (!props.sliding) return 'translateX(calc(-100%))';
if (props.dir === PREV) return 'translateX(calc( 2 * (-100%)))';
return 'translateX(0%)';
}};
Thank you for the feedback. I was able to make the ordering correct by simply adjusting the initial state. #278
Have you notice that if you only have two items, and go PREV, it will show a BLANK slide?
Describe the bug The example in
examples/app/SimpleCarousel
starts on the 2nd image not the first.Steps or Sandbox to reproduce coped the sample code to my next.js app.
Expected behavior Expected the first image to come first
Device/Browser Chrome
Additional context
BTW. It would be nice with an example that didn't use
styled components