Skip to content

Commit 6c04eae

Browse files
authored
Fix/Badge - add hitSlop support to badge container (#724)
* Adding hitSlop support to badge container * Adding hitSlop PropType
1 parent bfd2a70 commit 6c04eae

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/components/badge/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ export default class Badge extends PureBaseComponent {
4444
* the badge size (default, small)
4545
*/
4646
size: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(BADGE_SIZES)), PropTypes.number]),
47+
/**
48+
* Defines how far a touch event can start away from the badge.
49+
*/
50+
hitSlop: PropTypes.shape({
51+
top: PropTypes.number,
52+
bottom: PropTypes.number,
53+
left: PropTypes.number,
54+
right: PropTypes.number
55+
}),
4756
/**
4857
* width of border around the badge
4958
*/
@@ -212,6 +221,7 @@ export default class Badge extends PureBaseComponent {
212221
borderWidth,
213222
backgroundColor,
214223
containerStyle,
224+
hitSlop,
215225
icon,
216226
onPress,
217227
testId,
@@ -226,7 +236,7 @@ export default class Badge extends PureBaseComponent {
226236
const Container = !_.isEmpty(animationProps) ? AnimatableView : onPress ? TouchableOpacity : View;
227237
if (!_.isEmpty(animationProps)) {
228238
console.warn('Badge component will soon stop supporting animationProps.' +
229-
'Please wrap your Badge component with your own animation component, such as Animatable.View',);
239+
'Please wrap your Badge component with your own animation component, such as Animatable.View');
230240
}
231241
return (
232242
// The extra View wrapper is to break badge's flex-ness
@@ -237,6 +247,7 @@ export default class Badge extends PureBaseComponent {
237247
style={[sizeStyle, this.styles.badge, borderStyle, backgroundStyle]}
238248
onPress={onPress}
239249
activeOpacity={activeOpacity}
250+
hitSlop={hitSlop}
240251
{...animationProps}
241252
>
242253
{icon ? this.renderIcon() : this.renderLabel()}

0 commit comments

Comments
 (0)