nuka-carousel icon indicating copy to clipboard operation
nuka-carousel copied to clipboard

When displaying more than 1 slide wrapAround doesn't function as one would expect(Re: infinite looping/head to tail)

Open travisdmathis opened this issue 9 years ago • 5 comments

An infinite wrap around should place the 1st slide at the end of the last slide.. creating an infinite loop. wrapAround when displaying multiple slides should be head to tail.

currently the way the implementation of wrapAround works is if I have 8 total slides, 6 visible and slide 1 slide at a time, it doesn't wrap until the last slide has passed creating a huge area of nothing

broken_head_to_tail

travisdmathis avatar Feb 08 '17 19:02 travisdmathis

So, I have an infinite loop working using custom decorators for anyone who comes across this. It's important to note, to get this to work properly you need to also use wrapAround.

This however still isn't ideal, but it's closer to what I want. With this it bounces back to the first position where as it should place slide 0 next to the last slide head to tail and scroll in a loop.

const decorators = [{
      component: React.createClass({
        render() {
          return (
            <button
              onClick={
                this.props.currentSlide === 3 ?
                () => this.props.goToSlide(0) : this.props.nextSlide}>
              <i className='fa fa-chevron-right fa-3x'/>
            </button>
          )
        }
      }),
      position: 'CenterRight',
      style: {
        padding: 20,
        right: 0
      }
}];

  <Carousel decorators={decorators} slidesToShow={6} slidesToScroll={1} wrapAround={true}>
     {cards}
  </Carousel>

travisdmathis avatar Feb 08 '17 22:02 travisdmathis

This issue still exists with the release of v4.0.0.

regan-karlewicz avatar Mar 16 '18 16:03 regan-karlewicz

may-07-2018 22-43-46

To be honest, it is annoying that the bug is not fixed to the 4th release

bibblebabl avatar May 07 '18 20:05 bibblebabl

@travisdmathis it works only with next/prev button? but what about swipe?

bibblebabl avatar May 07 '18 20:05 bibblebabl

Pull #369 implements a fix for this

samwhale avatar Jul 06 '18 22:07 samwhale