diff --git a/README.md b/README.md index 3a62387..a7245da 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,7 @@ export default ReactSimplyCarouselExample; | **disableNavIfEdgeVisible** (disabled if `infinite` prop enabled) | boolean | `true` | Disable carousel forward nav if last slide is visible / Disable carousel backward nav if first slide is visible | | **disableNavIfEdgeActive** | boolean | `true` | Disable carousel forward nav if activeSlideIndex === lastSlideIndex / Disable carousel backward nav if activeSlideIndex === 0 | | **dotsNav** (experimental) | object | `{}` | Props for carousel dots. Includes `show` (boolean) property for toggle dots nav visibility, `containerProps` (DOM Props for dots nav wrapper div) property, `itemBtnProps` (DOM props for all dots nav buttons) property and `activeItemBtnProps` (DOM props for active dots nav button) | +| **persistentChangeCallbacks** | boolean | `false` | Enable call `onRequestChange` prop even if activeSlideIndex equals new value | ## Demo diff --git a/package.json b/package.json index 95b197c..a016797 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-simply-carousel", - "version": "8.0.0", + "version": "8.1.0", "description": "A simple, lightweight, fully controlled isomorphic (with SSR support) React.js carousel component. Touch enabled and responsive. With support for autoplay and infinity options. Fully customizable", "files": [ "dist/" diff --git a/src/index.tsx b/src/index.tsx index fd01330..35b16c2 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -55,6 +55,7 @@ type ReactSimplyCarouselStaticProps = { disableNavIfEdgeVisible?: boolean; disableNavIfEdgeActive?: boolean; dotsNav?: DotsNav; + persistentChangeCallbacks?: boolean; }; type ReactSimplyCarouselResponsiveProps = (Omit< @@ -154,6 +155,7 @@ function ReactSimplyCarousel({ disableNavIfEdgeVisible = true, disableNavIfEdgeActive = true, dotsNav = {}, + persistentChangeCallbacks = false, } = windowWidth ? { ...propsByWindowWidth, @@ -353,7 +355,10 @@ function ReactSimplyCarousel({ itemsListRef.current!.style.transition = speed || delay ? `transform ${speed}ms ${easing} ${delay}ms` : 'none'; - if (newActiveSlideIndex !== activeSlideIndex) { + if ( + newActiveSlideIndex !== activeSlideIndex || + persistentChangeCallbacks + ) { clearTimeout(autoplayTimerRef.current); onRequestChange(newActiveSlideIndex); } else { @@ -368,6 +373,7 @@ function ReactSimplyCarousel({ } }, [ + persistentChangeCallbacks, activeSlideIndex, offsetCorrectionForCenterMode, delay,