Skip to content

Commit

Permalink
Merge pull request #48 from vadymshymko/feature/add-initial-slides-vi…
Browse files Browse the repository at this point in the history
…sibility-prop

Feature/add initial slides visibility prop
  • Loading branch information
vadymshymko authored Jun 9, 2022
2 parents 59199c0 + 04ccdd2 commit 79d9915
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export default ReactSimplyCarouselExample;
| **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 |
| **showSlidesBeforeInit** | boolean | `false` | Show slides on very first (initial) carousel render |

## Demo

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-simply-carousel",
"version": "8.1.0",
"version": "8.2.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/"
Expand Down
10 changes: 9 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type ReactSimplyCarouselStaticProps = {
disableNavIfEdgeActive?: boolean;
dotsNav?: DotsNav;
persistentChangeCallbacks?: boolean;
showSlidesBeforeInit?: boolean;
};

type ReactSimplyCarouselResponsiveProps = (Omit<
Expand Down Expand Up @@ -156,6 +157,7 @@ function ReactSimplyCarousel({
disableNavIfEdgeActive = true,
dotsNav = {},
persistentChangeCallbacks = false,
showSlidesBeforeInit = false,
} = windowWidth
? {
...propsByWindowWidth,
Expand Down Expand Up @@ -782,7 +784,13 @@ function ReactSimplyCarousel({
flexFlow: 'row wrap',
padding: '0',
overflow: 'hidden',
maxWidth: innerMaxWidth ? `${innerMaxWidth}px` : 0,
// eslint-disable-next-line no-nested-ternary
maxWidth: innerMaxWidth
? `${innerMaxWidth}px`
: !innerMaxWidth && showSlidesBeforeInit
? undefined
: 0,
flex: !innerMaxWidth && showSlidesBeforeInit ? `1 0` : undefined,
}}
ref={innerRef}
>
Expand Down

0 comments on commit 79d9915

Please sign in to comment.