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

Infinite and AutoPlay does not work with 2 slides #81

Open
Shreerang opened this issue Feb 20, 2019 · 1 comment
Open

Infinite and AutoPlay does not work with 2 slides #81

Shreerang opened this issue Feb 20, 2019 · 1 comment

Comments

@Shreerang
Copy link

I see that there is an exact same issue #80 but is closed, when it is pretty much reproducible.

@z2s8
Copy link

z2s8 commented May 15, 2019

A workaround that ended up solving this for me was to check if there are 2 slides, and if yes duplicate them to make it 4. Example - where slide elems are passed as children:

constructor(props) {
    super(props);
    if (React.Children.count(props.children) === 2) {
      // slider breaks if there are exactly 2 items, so we make it 4
      this.children = []
      React.Children.map(props.children, (child, index) => {
        this.children.push(child);
      });
      React.Children.map(props.children, (child, index) => {
        this.children.push(child);
      });
    } else {
      this.children = props.children;
    }
}

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

2 participants