Skip to content

Commit 5cb3dc2

Browse files
authored
Merge pull request #859 from thundersdata-frontend/rn-issue
fix: 修复slider组件滑动不到最后的bug
2 parents 2edc68a + d7cda0b commit 5cb3dc2

File tree

5 files changed

+57
-41
lines changed

5 files changed

+57
-41
lines changed

.changeset/four-bottles-hide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@td-design/react-native': patch
3+
---
4+
5+
fix: 修复slider组件滑动不到最后的bug

packages/react-native/src/number-keyboard/NumberKeyboardModal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ const NumberKeyboardModal: FC<
5959
<SvgIcon name="down" size={px(20)} color={theme.colors.gray500} />
6060
</Pressable>
6161
</Flex>
62-
<NumberKeyboardView type={type} allowNegative={allowNegative} onPress={handleChange} onDelete={handleDelete} onSubmit={handleSubmit} />
62+
<NumberKeyboardView
63+
type={type}
64+
allowNegative={allowNegative}
65+
onPress={handleChange}
66+
onDelete={handleDelete}
67+
onSubmit={handleSubmit}
68+
/>
6369
</Modal>
6470
);
6571
};

packages/react-native/src/number-keyboard/NumberKeyboardView.tsx

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,44 +49,48 @@ const NumberKeyboardView: FC<NumberKeyboardViewProps> = ({
4949
});
5050

5151
const keyTypes = useMemo(() => {
52-
const numberType = allowNegative ? [
53-
{
54-
key: '0',
55-
flex: 1,
56-
},
57-
{
58-
key: '.',
59-
flex: 1,
60-
},
61-
{
62-
key: '-',
63-
flex: 1,
64-
},
65-
] : [
66-
{
67-
key: '0',
68-
flex: 2,
69-
},
70-
{
71-
key: '.',
72-
flex: 1,
73-
},
74-
];
75-
const integerType = allowNegative ? [
76-
{
77-
key: '0',
78-
flex: 2,
79-
},
80-
{
81-
key: '-',
82-
flex: 1,
83-
},
84-
] : [
85-
{
86-
key: '0',
87-
flex: 1,
88-
},
89-
];
52+
const numberType = allowNegative
53+
? [
54+
{
55+
key: '0',
56+
flex: 1,
57+
},
58+
{
59+
key: '.',
60+
flex: 1,
61+
},
62+
{
63+
key: '-',
64+
flex: 1,
65+
},
66+
]
67+
: [
68+
{
69+
key: '0',
70+
flex: 2,
71+
},
72+
{
73+
key: '.',
74+
flex: 1,
75+
},
76+
];
77+
const integerType = allowNegative
78+
? [
79+
{
80+
key: '0',
81+
flex: 2,
82+
},
83+
{
84+
key: '-',
85+
flex: 1,
86+
},
87+
]
88+
: [
89+
{
90+
key: '0',
91+
flex: 1,
92+
},
93+
];
9094

9195
const types = {
9296
number: numberType,

packages/react-native/src/number-keyboard/type.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export interface NumberKeyboardViewProps {
2020
allowNegative?: boolean;
2121
}
2222

23-
export interface NumberKeyboardItemProps extends Pick<NumberKeyboardViewProps, 'type' | 'activeOpacity' | 'allowNegative'> {
23+
export interface NumberKeyboardItemProps
24+
extends Pick<NumberKeyboardViewProps, 'type' | 'activeOpacity' | 'allowNegative'> {
2425
value?: string;
2526
onChange?: (value: string) => void;
2627
onCheck?: (value: string) => Promise<any>;

packages/react-native/src/slider/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const Slider: FC<SliderProps> = props => {
6464
} = props;
6565
const KNOB_WIDTH = height;
6666
const sliderRange = width - KNOB_WIDTH;
67-
const oneStepValue = Math.floor(sliderRange / (max - min)) || 1;
67+
const oneStepValue = Math.ceil(sliderRange / (max - min)) || 1;
6868

6969
const { progressStyle, knobStyle, onGestureEvent, label } = useSlider({
7070
min,

0 commit comments

Comments
 (0)