Skip to content

Commit 943cee3

Browse files
authored
Feat/slider thumbHitSlop prop (#1729)
* add thumbHitSlop prop * formatting * generated types * PR fixes
1 parent 1b53959 commit 943cee3

File tree

3 files changed

+140
-122
lines changed

3 files changed

+140
-122
lines changed

generatedTypes/src/components/slider/GradientSlider.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ declare const _default: React.ComponentClass<{
108108
containerStyle?: StyleProp<ViewStyle>;
109109
trackStyle?: StyleProp<ViewStyle>;
110110
thumbStyle?: ViewStyle | undefined;
111+
thumbHitSlop?: import("react-native").Insets | undefined;
111112
activeThumbStyle?: ViewStyle | undefined;
112113
disableActiveStyling?: boolean | undefined;
113114
disabled?: boolean | undefined;
@@ -118,6 +119,12 @@ declare const _default: React.ComponentClass<{
118119
minimumValue: number;
119120
maximumValue: number;
120121
step: number;
122+
thumbHitSlop: {
123+
top: number;
124+
bottom: number;
125+
left: number;
126+
right: number;
127+
};
121128
} & {
122129
/**
123130
* The gradient color

generatedTypes/src/components/slider/index.d.ts

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,89 @@
11
import { PureComponent, ReactElement, ElementRef } from 'react';
2-
import { Animated, StyleProp, ViewStyle, PanResponderGestureState, GestureResponderEvent, LayoutChangeEvent, AccessibilityActionEvent, AccessibilityRole, View as RNView } from 'react-native';
2+
import { Animated, StyleProp, ViewStyle, PanResponderGestureState, GestureResponderEvent, LayoutChangeEvent, AccessibilityActionEvent, AccessibilityRole, View as RNView, ViewProps } from 'react-native';
33
export declare type SliderOnValueChange = (value: number) => void;
44
export declare type SliderProps = {
55
/**
6-
* Initial value
7-
*/
6+
* Initial value
7+
*/
88
value?: number;
99
/**
10-
* Minimum value
11-
*/
10+
* Minimum value
11+
*/
1212
minimumValue?: number;
1313
/**
14-
* Maximum value
15-
*/
14+
* Maximum value
15+
*/
1616
maximumValue?: number;
1717
/**
18-
* Step value of the slider. The value should be between 0 and (maximumValue - minimumValue)
19-
*/
18+
* Step value of the slider. The value should be between 0 and (maximumValue - minimumValue)
19+
*/
2020
step?: number;
2121
/**
22-
* The color used for the track from minimum value to current value
23-
*/
22+
* The color used for the track from minimum value to current value
23+
*/
2424
minimumTrackTintColor?: string;
2525
/**
26-
* The track color
27-
*/
26+
* The track color
27+
*/
2828
maximumTrackTintColor?: string;
2929
/**
30-
* Custom render instead of rendering the track
31-
*/
30+
* Custom render instead of rendering the track
31+
*/
3232
renderTrack?: () => ReactElement | ReactElement[];
3333
/**
34-
* Thumb color
35-
*/
34+
* Thumb color
35+
*/
3636
thumbTintColor?: string;
3737
/**
38-
* Callback for onValueChange
39-
*/
38+
* Callback for onValueChange
39+
*/
4040
onValueChange?: SliderOnValueChange;
4141
/**
42-
* Callback that notifies about slider seeking is started
43-
*/
42+
* Callback that notifies about slider seeking is started
43+
*/
4444
onSeekStart?: () => void;
4545
/**
46-
* Callback that notifies about slider seeking is finished
47-
*/
46+
* Callback that notifies about slider seeking is finished
47+
*/
4848
onSeekEnd?: () => void;
4949
/**
50-
* The container style
51-
*/
50+
* The container style
51+
*/
5252
containerStyle?: StyleProp<ViewStyle>;
5353
/**
54-
* The track style
55-
*/
54+
* The track style
55+
*/
5656
trackStyle?: StyleProp<ViewStyle>;
5757
/**
58-
* The thumb style
59-
*/
58+
* The thumb style
59+
*/
6060
thumbStyle?: ViewStyle;
6161
/**
62-
* The active (during press) thumb style
63-
*/
62+
* Defines how far a touch event can start away from the thumb.
63+
*/
64+
thumbHitSlop?: ViewProps['hitSlop'];
65+
/**
66+
* The active (during press) thumb style
67+
*/
6468
activeThumbStyle?: ViewStyle;
6569
/**
66-
* If true the Slider will not change it's style on press
67-
*/
70+
* If true the Slider will not change it's style on press
71+
*/
6872
disableActiveStyling?: boolean;
6973
/**
70-
* If true the Slider will be disabled and will appear in disabled color
71-
*/
74+
* If true the Slider will be disabled and will appear in disabled color
75+
*/
7276
disabled?: boolean;
7377
/**
74-
* If true the component will have accessibility features enabled
75-
*/
78+
* If true the component will have accessibility features enabled
79+
*/
7680
accessible?: boolean;
7781
/**
7882
* The slider's test identifier
7983
*/
8084
testID?: string;
8185
} & typeof defaultProps;
82-
interface SliderState {
86+
interface State {
8387
containerSize: Measurements;
8488
trackSize: Measurements;
8589
thumbSize: Measurements;
@@ -96,19 +100,31 @@ declare const defaultProps: {
96100
minimumValue: number;
97101
maximumValue: number;
98102
step: number;
103+
thumbHitSlop: {
104+
top: number;
105+
bottom: number;
106+
left: number;
107+
right: number;
108+
};
99109
};
100110
/**
101111
* @description: A Slider component
102112
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/SliderScreen.tsx
103113
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/Slider/Slider.gif?raw=true
104114
*/
105-
export default class Slider extends PureComponent<SliderProps, SliderState> {
115+
export default class Slider extends PureComponent<SliderProps, State> {
106116
static displayName: string;
107117
static defaultProps: {
108118
value: number;
109119
minimumValue: number;
110120
maximumValue: number;
111121
step: number;
122+
thumbHitSlop: {
123+
top: number;
124+
bottom: number;
125+
left: number;
126+
right: number;
127+
};
112128
};
113129
private thumb;
114130
private _thumbStyles;
@@ -137,7 +153,7 @@ export default class Slider extends PureComponent<SliderProps, SliderState> {
137153
label: string;
138154
}[];
139155
};
140-
componentDidUpdate(prevProps: SliderProps, prevState: SliderState): void;
156+
componentDidUpdate(prevProps: SliderProps, prevState: State): void;
141157
componentDidMount(): void;
142158
componentWillUnmount(): void;
143159
handleMoveShouldSetPanResponder: () => boolean;
@@ -170,12 +186,6 @@ export default class Slider extends PureComponent<SliderProps, SliderState> {
170186
handleTrackPress: (event: GestureResponderEvent) => void;
171187
handleMeasure: (name: MeasuredVariableName, { nativeEvent }: LayoutChangeEvent) => void;
172188
onAccessibilityAction: (event: AccessibilityActionEvent) => void;
173-
thumbHitSlop: {
174-
top: number;
175-
bottom: number;
176-
left: number;
177-
right: number;
178-
};
179189
renderThumb: () => JSX.Element;
180190
render(): JSX.Element;
181191
}

0 commit comments

Comments
 (0)