DEV Community

Discussion on: How to change numeric input by dragging in React?

Collapse
 
tombalev profile image
Tom Balev • Edited

Change:

if (startVal) {
     setValue(event.clientX - snapshot);
}
Enter fullscreen mode Exit fullscreen mode

to:

if (startVal) {
     setValue(snapshot + event.clientX - startVal);
}
Enter fullscreen mode Exit fullscreen mode

to prevent zeroing out the input on next drag