File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
src/react-elastic-carousel/components Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -260,8 +260,10 @@ class Carousel extends React.Component {
260260
261261 convertChildToCbObj = index => {
262262 const { children } = this . props ;
263- const child = children [ index ] ;
264- return { item : child . props , index } ;
263+ // support decimal itemsToShow
264+ const roundedIdx = Math . round ( index ) ;
265+ const child = children [ roundedIdx ] ;
266+ return { item : child . props , index : roundedIdx } ;
265267 } ;
266268
267269 getNextItemIndex = ( currentIndex , getPrev ) => {
@@ -285,8 +287,10 @@ class Carousel extends React.Component {
285287 const { children } = this . props ;
286288 const { firstItem } = this . state ;
287289 const nextItemIndex = this . getNextItemIndex ( firstItem , getPrev ) ;
288- const asElement = children [ nextItemIndex ] ;
289- const asObj = { item : asElement . props , index : nextItemIndex } ;
290+ // support decimal itemsToShow
291+ const roundedIdx = Math . round ( nextItemIndex ) ;
292+ const asElement = children [ roundedIdx ] ;
293+ const asObj = { item : asElement . props , index : roundedIdx } ;
290294 return asObj ;
291295 } ;
292296
You can’t perform that action at this time.
0 commit comments