[Slider] Add useRelativeDrag prop for relative drag mode#3952
Open
adids1221 wants to merge 1 commit intofix/slider_android_hitslop_container_gesturefrom
Open
[Slider] Add useRelativeDrag prop for relative drag mode#3952adids1221 wants to merge 1 commit intofix/slider_android_hitslop_container_gesturefrom
adids1221 wants to merge 1 commit intofix/slider_android_hitslop_container_gesturefrom
Conversation
Adds a new useRelativeDrag prop (default false). When enabled, dragging anywhere on the slider moves the thumb relative to its current position instead of snapping to the touch point. Designed for single-thumb mode. Made-with: Cursor
Contributor
✅ PR Description Validation PassedAll required sections are properly filled out:
Your PR is good for review! 🚀 This validation ensures all sections from the PR template are properly filled. |
Contributor
Author
How to reproduceDrop this into import React, {useState} from 'react';
import {Platform} from 'react-native';
import {View, Text, Slider, Switch} from 'react-native-ui-lib';
const TAG = `[Slider-${Platform.OS}]`;
export default function PlaygroundScreen() {
const [disabled, setDisabled] = useState(false);
const [useRelativeDrag, setUseRelativeDrag] = useState(false);
return (
<View flex padding-20>
<Text text60 marginB-20>
Slider Debug ({Platform.OS})
</Text>
<View row centerV marginB-10>
<Text text70 marginR-10>Disabled</Text>
<Switch value={disabled} onValueChange={setDisabled}/>
</View>
<View row centerV marginB-20>
<Text text70 marginR-10>useRelativeDrag</Text>
<Switch value={useRelativeDrag} onValueChange={setUseRelativeDrag}/>
</View>
<Text text70 marginB-10>
Slider (default)
</Text>
<Slider
value={30}
minimumValue={0}
maximumValue={100}
disabled={disabled}
onSeekStart={() => console.log(`${TAG} - default - onSeekStart`)}
onSeekEnd={() => console.log(`${TAG} - default - onSeekEnd`)}
onValueChange={(v: number) => console.log(`${TAG} - default - value: ${v.toFixed(1)}`)}
/>
<Text text70 marginT-40 marginB-10>
Slider (useRelativeDrag={String(useRelativeDrag)})
</Text>
<Slider
value={30}
minimumValue={0}
maximumValue={100}
disabled={disabled}
useRelativeDrag={useRelativeDrag}
onSeekStart={() => console.log(`${TAG} - relative - onSeekStart`)}
onSeekEnd={() => console.log(`${TAG} - relative - onSeekEnd`)}
onValueChange={(v: number) => console.log(`${TAG} - relative - value: ${v.toFixed(1)}`)}
/>
</View>
);
}What to test
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a new
useRelativeDragprop (defaultfalse).When enabled, dragging anywhere on the slider moves the thumb relative to its current position instead of snapping to the touch point. Designed for single-thumb mode.
Depends on #3951.
Changelog
Slider - Added
useRelativeDragprop for relative drag mode where touch anywhere moves the thumb proportionally to drag distance.Additional info
MADS-4866