Skip to content

[Slider] Add useRelativeDrag prop for relative drag mode#3952

Open
adids1221 wants to merge 1 commit intofix/slider_android_hitslop_container_gesturefrom
feat/slider_use_container_gesture
Open

[Slider] Add useRelativeDrag prop for relative drag mode#3952
adids1221 wants to merge 1 commit intofix/slider_android_hitslop_container_gesturefrom
feat/slider_use_container_gesture

Conversation

@adids1221
Copy link
Contributor

@adids1221 adids1221 commented Mar 15, 2026

Description

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.

Depends on #3951.

Changelog

Slider - Added useRelativeDrag prop for relative drag mode where touch anywhere moves the thumb proportionally to drag distance.

Additional info

MADS-4866

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
@github-actions
Copy link
Contributor

github-actions bot commented Mar 15, 2026

✅ PR Description Validation Passed

All required sections are properly filled out:

  • Description
  • Changelog
  • Additional info

Your PR is good for review! 🚀


This validation ensures all sections from the PR template are properly filled.

@adids1221
Copy link
Contributor Author

adids1221 commented Mar 15, 2026

How to reproduce

Drop this into PlaygroundScreen.tsx:

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

  • Default slider — drag the thumb, tap the track to jump — should work as before
  • useRelativeDrag slider — touch anywhere and drag — thumb moves relative to its current position, no snap on touch
  • Toggle useRelativeDrag — switch between modes, verify behavior changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants