Dragging on a numeric prop with a range now respects the range.
Fixes #31
This commit is contained in:
parent
69acb61f84
commit
1647d91dc5
1 changed files with 5 additions and 1 deletions
|
@ -241,7 +241,7 @@ const BasicNumberInput: React.FC<{
|
||||||
const onDrag = (deltaX: number, _dy: number) => {
|
const onDrag = (deltaX: number, _dy: number) => {
|
||||||
const curState = refs.current.state as IState_Dragging
|
const curState = refs.current.state as IState_Dragging
|
||||||
|
|
||||||
const newValue =
|
let newValue =
|
||||||
curState.valueBeforeDragging +
|
curState.valueBeforeDragging +
|
||||||
propsA.nudge({
|
propsA.nudge({
|
||||||
deltaX,
|
deltaX,
|
||||||
|
@ -249,6 +249,10 @@ const BasicNumberInput: React.FC<{
|
||||||
magnitude: 1,
|
magnitude: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (propsA.range) {
|
||||||
|
newValue = clamp(newValue, propsA.range[0], propsA.range[1])
|
||||||
|
}
|
||||||
|
|
||||||
setState({
|
setState({
|
||||||
...curState,
|
...curState,
|
||||||
currentDraggingValue: newValue,
|
currentDraggingValue: newValue,
|
||||||
|
|
Loading…
Reference in a new issue