Skip to content

Commit 288cf72

Browse files
authored
feat: hideDots in swiper using a prop (#975)
1 parent 1986bc3 commit 288cf72

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

example/src/SwiperExample.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ function SwiperExample() {
147147
/>
148148
</View>
149149
</Section>
150+
151+
<Section title="Hide Dots Example" style={undefined}>
152+
<Swiper
153+
vertical={false}
154+
hideDots
155+
style={{ width: "100%", height: 300 }}
156+
>
157+
<SwiperItem style={[style.item, { backgroundColor: "#fdd3d3" }]}>
158+
<Text>Test Slide 1</Text>
159+
</SwiperItem>
160+
<SwiperItem style={[style.item, { backgroundColor: "#d6d3fd" }]}>
161+
<Text>Test Slide 2</Text>
162+
</SwiperItem>
163+
<SwiperItem style={[style.item, { backgroundColor: "#c9fdd9" }]}>
164+
<Text>Test Slide 3</Text>
165+
</SwiperItem>
166+
</Swiper>
167+
</Section>
150168
</Container>
151169
);
152170
}

packages/core/src/components/Swiper/Swiper.tsx

+14-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface SwiperProps<T> {
3333
minDistanceForAction?: number;
3434
minDistanceToCapture?: number;
3535
theme: ReadTheme;
36+
hideDots?: boolean;
3637
}
3738

3839
const Swiper = forwardRef<SwiperRef, SwiperProps<any>>(
@@ -61,6 +62,7 @@ const Swiper = forwardRef<SwiperRef, SwiperProps<any>>(
6162
minDistanceForAction,
6263
minDistanceToCapture,
6364
style,
65+
hideDots = false,
6466
}: SwiperProps<any>,
6567
ref
6668
) => {
@@ -157,10 +159,20 @@ const Swiper = forwardRef<SwiperRef, SwiperProps<any>>(
157159
nextTitleStyle: { color: nextTitleColor },
158160
dotsTouchable,
159161
...(dotColor
160-
? { dotProps: { badgeStyle: { backgroundColor: dotColor } } }
162+
? {
163+
dotProps: {
164+
badgeStyle: {
165+
backgroundColor: hideDots ? "transparent" : dotColor,
166+
},
167+
},
168+
}
161169
: {}),
162170
...(dotActiveColor
163-
? { dotActiveStyle: { backgroundColor: dotActiveColor } }
171+
? {
172+
dotActiveStyle: {
173+
backgroundColor: hideDots ? "transparent" : dotActiveColor,
174+
},
175+
}
164176
: {}),
165177
}}
166178
>

0 commit comments

Comments
 (0)