@@ -525,6 +525,12 @@ export class SpringValue<T = any> extends FrameValue<T> {
525525 ) : AsyncResult < T > {
526526 const defaultProps : any = this . _defaultProps
527527
528+ // Let the caller inspect every update.
529+ const onProps = resolveEventProp ( defaultProps , props , 'onProps' , this . key )
530+ if ( onProps ) {
531+ onProps ( props , this )
532+ }
533+
528534 // These props are coerced into booleans by the `scheduleProps` function,
529535 // so they need their default values merged before then.
530536 each ( [ 'cancel' , 'pause' ] as const , key => {
@@ -594,14 +600,8 @@ export class SpringValue<T = any> extends FrameValue<T> {
594600 }
595601
596602 /** Get the function for a specific event prop */
597- const getEventProp = < K extends keyof SpringEventProps > ( prop : K ) => {
598- const value = ! is . und ( props [ prop ] ) ? props [ prop ] : defaultProps [ prop ]
599- return ( is . fun ( value )
600- ? value
601- : key && value
602- ? value [ key ]
603- : undefined ) as Extract < SpringEventProps [ K ] , Function >
604- }
603+ const getEventProp = < K extends keyof SpringEventProps > ( prop : K ) =>
604+ resolveEventProp ( defaultProps , props , prop , key )
605605
606606 // Call "onDelayEnd" before merging props, but after cancellation checks.
607607 const onDelayEnd = getEventProp ( 'onDelayEnd' )
@@ -801,12 +801,6 @@ export class SpringValue<T = any> extends FrameValue<T> {
801801 }
802802 }
803803
804- // By this point, every prop has been merged.
805- const onProps = getEventProp ( 'onProps' )
806- if ( onProps ) {
807- onProps ( props , this )
808- }
809-
810804 // Update our node even if the animation is idle.
811805 if ( reset ) {
812806 node . setValue ( value )
@@ -1071,3 +1065,14 @@ export function declareUpdate(props: any) {
10711065function findDefined ( values : any , keys : Set < string > ) {
10721066 each ( values , ( value , key ) => value != null && keys . add ( key as any ) )
10731067}
1068+
1069+ /** Coerce an event prop into a function */
1070+ function resolveEventProp < T extends SpringEventProps , P extends keyof T > (
1071+ defaultProps : T ,
1072+ props : T ,
1073+ prop : P ,
1074+ key ?: string
1075+ ) : Extract < T [ P ] , Function > {
1076+ const value : any = ! is . und ( props [ prop ] ) ? props [ prop ] : defaultProps [ prop ]
1077+ return is . fun ( value ) ? value : key && value ? value [ key ] : undefined
1078+ }
0 commit comments