import { CarouselInternalState , CarouselProps } from "../types" ; import { getSlidesToSlide } from "./common" ; function populateNextSlides ( state , props , slidesHavePassed = 0 ) { const { slidesToShow , currentSlide , itemWidth , totalItems } = state ; const slidesToSlide = getSlidesToSlide ( state , props ) ; let nextSlides ; let nextPosition ; const nextMaximumSlides = currentSlide + 1 + slidesHavePassed + slidesToShow + ( slidesHavePassed > 0 ? 0 : slidesToSlide ! ) ; if ( nextMaximumSlides <= totalItems ) { nextSlides = currentSlide + slidesHavePassed + ( slidesHavePassed > 0 ? 0 : slidesToSlide ! ) ; nextPosition = - ( itemWidth * nextSlides ) ; } else if ( nextMaximumSlides > totalItems && currentSlide !== totalItems - slidesToShow ) { nextSlides = totalItems - slidesToShow ; nextPosition = - ( itemWidth * nextSlides ) ; } else { nextSlides = undefined ; nextPosition = undefined ; } return { nextSlides , nextPosition } ; } export { populateNextSlides } ;