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

Drag cap at max value #28

Open
jwugit opened this issue Mar 17, 2021 · 4 comments
Open

Drag cap at max value #28

jwugit opened this issue Mar 17, 2021 · 4 comments

Comments

@jwugit
Copy link

jwugit commented Mar 17, 2021

Is there a way to make it not drag pass the max value?
currently, you can drag and spin muliple round trips.

can we make it not drag pass the min and max value ? just 1 round on the slider?
Thanks,

@fseehawer
Copy link
Owner

It's currently not possible, I will consider it for a future release.

@mbauchet
Copy link

Hi, some news about that? Thanks

@fseehawer
Copy link
Owner

fseehawer commented Apr 16, 2022

I'm working on a new version that will have a new range prop. That should cover your case. Can't give you any estimates on when that version will be out though, sorry.

@Janvampierssel
Copy link

I have a very clunky fix for now using the props provided. It's not perfect and it breaks with certain drag behavior but it's better than nothing.

The code sets draggable to false when the cap (20 in this case) is reached and resets the position of the knob to the appropriate location.

However for some reason, this only works once and the knob position reset doesn't happen again. Maybe it has something to do with my code.

When you start dragging the knob further again, the value doesn't go up (because of max={20}) but visually it makes a step of one before that gets capped. Basically: it caps, then you can drag it one further then it's supposed to go until it caps again.

fseehawer, please look into implementing a fix!

`
const [draggable, setDraggable] = useState(true);
const [knobPosition, setKnobPosition] = useState(-0.49);

const capSlider = (value) => {
setDraggable(false);
setKnobPosition(value % 10 - 0.49);
}

return(
<CircularSlider
continuous={{
enabled: true,
clicks: 10,
increment: 1,
}}
min={-100}
max={20}
dataIndex={knobPosition}
knobDraggable={draggable}
onChange={ value => { value >= 20 && capSlider(value) }}
isDragging={(dragging) => {!dragging && setDraggable(true)}}
>
)
`

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

No branches or pull requests

4 participants