@@ -48,9 +48,10 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
4848 leftIconStyle,
4949 rightIconStyle,
5050 stroke,
51+ onChange = ( ) => { } ,
5152 } = props ;
5253
53- const { panResponder, value, setValue, curPoint, currentRadian } =
54+ const { panResponder, value, setValue, curPoint, currentRadian, prevValue } =
5455 useSilderAnimation ( props ) ;
5556
5657 const {
@@ -74,9 +75,9 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
7475
7576 const handleValue = ( ) => {
7677 if ( iconPosition === 'up' && max > value ) {
77- isStart && setValue ( ( prevState : number ) => prevState + step ) ;
78+ isStart && onPressButtons ( 'up' ) ;
7879 } else if ( iconPosition === 'down' && min < value ) {
79- isStart && setValue ( ( prevState : number ) => prevState - step ) ;
80+ isStart && onPressButtons ( 'down' ) ;
8081 }
8182 } ;
8283
@@ -103,9 +104,19 @@ const RadialSlider = (props: RadialSliderProps & typeof defaultProps) => {
103104
104105 const onPressButtons = ( type : string ) => {
105106 if ( type === 'up' && max > value ) {
106- setValue ( ( prevState : number ) => prevState + step ) ;
107+ setValue ( ( prevState : number ) => {
108+ prevValue . current = prevState + step ;
109+
110+ return prevState + step ;
111+ } ) ;
112+ onChange ( value ) ;
107113 } else if ( type === 'down' && min < value ) {
108- setValue ( ( prevState : number ) => prevState - step ) ;
114+ setValue ( ( prevState : number ) => {
115+ prevValue . current = prevState - step ;
116+
117+ return prevState - step ;
118+ } ) ;
119+ onChange ( value ) ;
109120 }
110121 } ;
111122
0 commit comments