Skip to content

Commit 0308a91

Browse files
committed
Close #138
1 parent d275ed2 commit 0308a91

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,14 @@ The component extends `FlatList` so all FlatList-props are valid.
153153
| Name | Type | Default | Description |
154154
| ---------------- | ---------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
155155
| data | `object` | None, required | An array of objects (they should either contain a unique `key`-prop or you should pass a `keyExtractor`-function to the component) |
156-
| renderItem | `function` | None, required | [FlatList's renderItem](https://facebook.github.io/react-native/docs/flatlist.html#renderitem). Receives `({item, index, dimensions})` where `dimensions` contains height and width of the slides |
157-
| onSlideChange | `function` | `void` | Called when user goes changes slide (by swiping or pressing next/prev). Function called with arguments `(index: number, lastIndex: number)` |
156+
| renderItem | `function` | None, required | [FlatList's renderItem](https://facebook.github.io/react-native/docs/flatlist.html#renderitem). Receives `({item, index, dimensions})` where `dimensions` contains height and width of the slides |
157+
| onSlideChange | `function` | `void` | Called when user goes changes slide (by swiping or pressing next/prev). Function called with arguments `(index: number, lastIndex: number)` |
158158
| renderPagination | `function` | | Function to render a custom pagination/button component on top of slides. Receives the index of the currently active slide |
159159
| onDone | `function` | `void` | Called when user ends the introduction by pressing the done button |
160160
| onSkip | `function` | Scrolls to the end | Called when user presses the skip button |
161161
| bottomButton | `boolean` | `false` | Enable to show a full-width button under pagination |
162162
| dotStyle | `style` | {backgroundColor: 'rgba(0, 0, 0, .2)'} | Style of inactive pagination dots |
163+
| dotClickEnabled | `boolean` | `true` | Whether users can navigate using the pagination dots |
163164
| activeDotStyle | `style` | {backgroundColor: 'rgba(255, 255, 255, .9)'} | Style of active pagination dot |
164165
| skipLabel | `string` | `Skip` | Custom label for Skip button |
165166
| doneLabel | `string` | `Done` | Custom label for Done button |

src/index.tsx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Props<ItemT> = {
3131
renderPagination?: (activeIndex: number) => React.ReactNode;
3232
activeDotStyle: ViewStyle;
3333
dotStyle: ViewStyle;
34+
dotClickEnabled: boolean;
3435
skipLabel: string;
3536
doneLabel: string;
3637
nextLabel: string;
@@ -59,6 +60,7 @@ export default class AppIntroSlider<ItemT> extends React.Component<
5960
dotStyle: {
6061
backgroundColor: 'rgba(0, 0, 0, .2)',
6162
},
63+
dotClickEnabled: true,
6264
skipLabel: 'Skip',
6365
doneLabel: 'Done',
6466
nextLabel: 'Next',
@@ -203,18 +205,30 @@ export default class AppIntroSlider<ItemT> extends React.Component<
203205
<SafeAreaView>
204206
<View style={styles.paginationDots}>
205207
{this.props.data.length > 1 &&
206-
this.props.data.map((_, i) => (
207-
<TouchableOpacity
208-
key={i}
209-
style={[
210-
styles.dot,
211-
this._rtlSafeIndex(i) === this.state.activeIndex
212-
? this.props.activeDotStyle
213-
: this.props.dotStyle,
214-
]}
215-
onPress={() => this.goToSlide(i, true)}
216-
/>
217-
))}
208+
this.props.data.map((_, i) =>
209+
this.props.dotClickEnabled ? (
210+
<TouchableOpacity
211+
key={i}
212+
style={[
213+
styles.dot,
214+
this._rtlSafeIndex(i) === this.state.activeIndex
215+
? this.props.activeDotStyle
216+
: this.props.dotStyle,
217+
]}
218+
onPress={() => this.goToSlide(i, true)}
219+
/>
220+
) : (
221+
<View
222+
key={i}
223+
style={[
224+
styles.dot,
225+
this._rtlSafeIndex(i) === this.state.activeIndex
226+
? this.props.activeDotStyle
227+
: this.props.dotStyle,
228+
]}
229+
/>
230+
),
231+
)}
218232
</View>
219233
{primaryButton}
220234
{secondaryButton}

0 commit comments

Comments
 (0)