Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ignoreThumbOffset option #2946

Closed

Conversation

bmichotte
Copy link

Feature request

I'm trying to implement the following design using the Slider component
CleanShot 2024-06-10 at 15 52 02@2x

Overview

Using the following code

<SliderPrimitive.Root
    [clip]
    defaultValue={[value]}
    max={steps}
    step={1}
>
    <SliderPrimitive.Thumb [clip]>
        <Bubble className="px-6 py-2 block">move me</Bubble>
    </SliderPrimitive.Thumb>
</SliderPrimitive.Root>

Which gives me the following result

CleanShot.2024-06-10.at.15.30.45.mp4

The guilty is the thumbInBoundsOffset on https://github.com/radix-ui/primitives/blob/af1e3b41cb5c49d7b8c073d2aec34d5074c6dd17/packages/react/slider/src/Slider.tsx#L586C58-L586C77

By adding the option ignoreThumbOffset on the <Thumb />, we could refactor the code
to be

const thumbInBoundsOffset = orientationSize && !ignoreThumbOffsfet
      ? getThumbInBoundsOffset(orientationSize, percent, orientation.direction)
      : 0;

And it would fix the issue

CleanShot.2024-06-10.at.15.40.58.mp4

@evadecker
Copy link

This would be fixed by the thumbAlignment proposal in #2806

@chaance
Copy link
Member

chaance commented Sep 27, 2024

Thanks for the contribution, but I think I favor the proposal in #2806. Keep posted there for updates!

@chaance chaance closed this Sep 27, 2024
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.

3 participants