@@ -18,6 +18,7 @@ import type {
1818 PressableFeedbackAnimation ,
1919 PressableFeedbackAnimationContextValue ,
2020 PressableFeedbackHighlightRootAnimation ,
21+ PressableFeedbackRippleRootAnimation ,
2122 PressableFeedbackVariant ,
2223} from './pressable-feedback.types' ;
2324
@@ -84,7 +85,7 @@ export function usePressableFeedbackRootAnimation(options: {
8485 isPressed . set ( false ) ;
8586 scale . set ( withTiming ( 0 , scaleTimingConfig ) ) ;
8687
87- if ( variant === 'ripple ' ) return ;
88+ if ( variant === 'highlight ' ) return ;
8889
8990 rippleProgress . set ( withTiming ( 2 , { duration : 400 } ) ) ;
9091 } ) ;
@@ -198,7 +199,13 @@ export function usePressableFeedbackHighlightAnimation(options: {
198199 * Animation hook for PressableFeedback ripple effect
199200 * Handles ripple circle animation with radial gradient
200201 */
201- export function usePressableFeedbackRippleAnimation ( ) {
202+ export function usePressableFeedbackRippleAnimation ( options : {
203+ animation : PressableFeedbackRippleRootAnimation | undefined ;
204+ } ) {
205+ const { animation } = options ;
206+
207+ const { theme } = useUniwind ( ) ;
208+
202209 const {
203210 pressedCenterX,
204211 pressedCenterY,
@@ -207,32 +214,77 @@ export function usePressableFeedbackRippleAnimation() {
207214 rippleProgress,
208215 } = usePressableFeedbackAnimation ( ) ;
209216
217+ const { animationConfig, isAnimationDisabled } = getAnimationState ( animation ) ;
218+
219+ // Background color
220+ const defaultColor = theme === 'dark' ? 'white' : 'black' ;
221+
222+ const backgroundColor = getAnimationValueProperty ( {
223+ animationValue : animationConfig ?. ripple ?. backgroundColor ,
224+ property : 'value' ,
225+ defaultValue : defaultColor ,
226+ } ) ;
227+
228+ // Opacity animation
229+ const opacityValue = getAnimationValueProperty ( {
230+ animationValue : animationConfig ?. ripple ?. opacity ,
231+ property : 'value' ,
232+ defaultValue : [ 0 , 1 , 0 ] as [ number , number , number ] ,
233+ } ) ;
234+
235+ const opacityTimingConfig = getAnimationValueMergedConfig ( {
236+ animationValue : animationConfig ?. ripple ?. opacity ,
237+ property : 'timingConfig' ,
238+ defaultValue : { duration : 30 } ,
239+ } ) ;
240+
241+ // Scale animation
242+ const scaleValue = getAnimationValueProperty ( {
243+ animationValue : animationConfig ?. ripple ?. scale ,
244+ property : 'value' ,
245+ defaultValue : [ 0 , 1 , 1 ] as [ number , number , number ] ,
246+ } ) ;
247+
248+ const scaleTimingConfig = getAnimationValueMergedConfig ( {
249+ animationValue : animationConfig ?. ripple ?. scale ,
250+ property : 'timingConfig' ,
251+ defaultValue : { duration : 30 } ,
252+ } ) ;
253+
210254 const rContainerStyle = useAnimatedStyle ( ( ) => {
211255 const circleRadius =
212256 Math . sqrt ( containerWidth . get ( ) ** 2 + containerHeight . get ( ) ** 2 ) * 1.25 ;
213257
214258 const translateX = pressedCenterX . get ( ) - circleRadius ;
215259 const translateY = pressedCenterY . get ( ) - circleRadius ;
216260
261+ if ( isAnimationDisabled ) {
262+ return { } ;
263+ }
264+
217265 return {
218266 width : circleRadius * 2 ,
219267 height : circleRadius * 2 ,
220268 borderRadius : circleRadius ,
221269 opacity : withTiming (
222- interpolate ( rippleProgress . get ( ) , [ 0 , 1 , 2 ] , [ 0 , 1 , 0 ] ) ,
223- { duration : 30 }
270+ interpolate (
271+ rippleProgress . get ( ) ,
272+ [ 0 , 1 , 2 ] ,
273+ [ opacityValue [ 0 ] , opacityValue [ 1 ] , opacityValue [ 2 ] ]
274+ ) ,
275+ opacityTimingConfig
224276 ) ,
225277 transform : [
226- {
227- translateX,
228- } ,
229- {
230- translateY,
231- } ,
278+ { translateX } ,
279+ { translateY } ,
232280 {
233281 scale : withTiming (
234- interpolate ( rippleProgress . get ( ) , [ 0 , 1 , 2 ] , [ 0 , 1 , 1 ] ) ,
235- { duration : 30 }
282+ interpolate (
283+ rippleProgress . get ( ) ,
284+ [ 0 , 1 , 2 ] ,
285+ [ scaleValue [ 0 ] , scaleValue [ 1 ] , scaleValue [ 2 ] ]
286+ ) ,
287+ scaleTimingConfig
236288 ) ,
237289 } ,
238290 ] ,
@@ -241,5 +293,6 @@ export function usePressableFeedbackRippleAnimation() {
241293
242294 return {
243295 rContainerStyle,
296+ backgroundColor,
244297 } ;
245298}
0 commit comments