Skip to content

Commit

Permalink
Fix the issue of the next arrow being disabled when responsive is ena…
Browse files Browse the repository at this point in the history
…bled.

When the responsive setting is enabled, the `slidesToScroll` should use the value from responsive settings; otherwise, it will be unexpectedly disabled.
  • Loading branch information
kaneg authored and femioladeji committed Mar 9, 2024
1 parent 5b0343d commit 03adf39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ export const showPreviousArrow = (
export const showNextArrow = (
properties: FadeProps | SlideProps | ZoomProps,
currentIndex: number,
moveSlides: ButtonClick
moveSlides: ButtonClick,
responsiveSettings?: Responsive
) => {
const { nextArrow, infinite, children } = properties;
let slidesToScroll = 1;
if ('slidesToScroll' in properties) {
if (responsiveSettings) {
slidesToScroll = responsiveSettings?.settings.slidesToScroll;
} else if ('slidesToScroll' in properties) {
slidesToScroll = properties.slidesToScroll || 1;
}
const isDisabled = currentIndex >= React.Children.count(children) - slidesToScroll && !infinite;
Expand Down
2 changes: 1 addition & 1 deletion src/slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export const Slide = React.forwardRef<SlideshowRef, SlideProps>((props, ref) =>
{renderTrailingSlides()}
</div>
</div>
{props.arrows && showNextArrow(props, index, moveSlides)}
{props.arrows && showNextArrow(props, index, moveSlides, responsiveSettings)}
</div>
{!!props.indicators && showIndicators(props, index, goToSlide, responsiveSettings)}
</div>
Expand Down

0 comments on commit 03adf39

Please sign in to comment.