react-animated-slider
react-animated-slider copied to clipboard
Infinite and AutoPlay does not work with 2 slides
I see that there is an exact same issue https://github.com/erichbehrens/react-animated-slider/issues/80 but is closed, when it is pretty much reproducible.
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;
}
}