File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
src/components/RadialSlider Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -103,15 +103,18 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
103103 const onPressButtons = ( type : string ) => {
104104 if ( type === 'up' && max > value ) {
105105 setValue ( ( prevState : number ) => {
106- prevValue . current = prevState + step ;
106+ const calculatedValue = prevState + step ;
107+ const roundedValue = parseFloat ( calculatedValue . toFixed ( 1 ) ) ;
107108
108- return prevState + step ;
109+ return roundedValue ;
109110 } ) ;
110111 } else if ( type === 'down' && min < value ) {
111112 setValue ( ( prevState : number ) => {
112- prevValue . current = prevState - step ;
113+ const calculatedValue = prevState - step ;
114+ const roundedValue = parseFloat ( calculatedValue . toFixed ( 1 ) ) ;
115+ prevValue . current = roundedValue ;
113116
114- return prevState - step ;
117+ return roundedValue ;
115118 } ) ;
116119 }
117120 } ;
Original file line number Diff line number Diff line change @@ -123,12 +123,14 @@ const useSliderAnimation = (props: RadialSliderAnimationHookProps) => {
123123 nValue = Math . max ( min , Math . min ( max , nValue ) ) ;
124124
125125 setValue ( ( prevState : number ) => {
126- prevValue . current = Math . round (
127- Math . abs ( nValue - prevState ) > diff / 4 ? prevState : nValue
128- ) ;
129- return Math . round (
130- Math . abs ( nValue - prevState ) > diff / 4 ? prevState : nValue
131- ) ;
126+ const roundedValue = parseFloat ( nValue . toFixed ( 1 ) ) ;
127+ prevValue . current =
128+ Math . abs ( roundedValue - prevState ) > diff / 4
129+ ? prevState
130+ : roundedValue ;
131+ return Math . abs ( roundedValue - prevState ) > diff / 4
132+ ? prevState
133+ : roundedValue ;
132134 } ) ;
133135
134136 onChange ( prevValue . current ) ;
You can’t perform that action at this time.
0 commit comments