File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -150,13 +150,28 @@ class Switch extends Component<SwitchProps> {
150
150
return < Animated . View style = { [ this . styles . thumb , thumbPositionStyle , thumbStyle ] } /> ;
151
151
}
152
152
153
+ getAccessibleHitSlop ( ) {
154
+ const { width = DEFAULT_WIDTH , height = DEFAULT_HEIGHT } = this . props ;
155
+ const verticalPadding = Math . max ( 0 , ( 48 - height ) / 2 ) ;
156
+ const horizontalPadding = Math . max ( 0 , ( 48 - width ) / 2 ) ;
157
+
158
+ return {
159
+ top : verticalPadding ,
160
+ bottom : verticalPadding ,
161
+ left : horizontalPadding ,
162
+ right : horizontalPadding
163
+ } ;
164
+ }
165
+
153
166
render ( ) {
154
167
const { ...others } = this . props ;
168
+
155
169
return (
156
170
// @ts -ignore
157
171
< TouchableOpacity
158
172
{ ...this . getAccessibilityProps ( ) }
159
173
activeOpacity = { 1 }
174
+ hitSlop = { this . getAccessibleHitSlop ( ) }
160
175
{ ...others }
161
176
style = { this . getSwitchStyle ( ) }
162
177
onPress = { this . onPress }
You can’t perform that action at this time.
0 commit comments