File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,22 @@ function describeImmediateProp() {
116116    it . todo ( 'still resolves the "start" promise' ) 
117117    it . todo ( 'never calls the "onStart" prop' ) 
118118    it . todo ( 'never calls the "onRest" prop' ) 
119+ 
120+     it ( 'stops animating' ,  async  ( )  =>  { 
121+       const  spring  =  new  SpringValue ( 0 ) 
122+       spring . start ( 2 ) 
123+       await  advanceUntilValue ( spring ,  1 ) 
124+ 
125+       // Use "immediate" to emulate the "stop" method. (see #884) 
126+       const  value  =  spring . get ( ) 
127+       spring . start ( value ,  {  immediate : true  } ) 
128+ 
129+       // The "immediate" prop waits until the next frame before going idle. 
130+       mockRaf . step ( ) 
131+ 
132+       expect ( spring . idle ) . toBeTruthy ( ) 
133+       expect ( spring . get ( ) ) . toBe ( value ) 
134+     } ) 
119135  } ) 
120136} 
121137
Original file line number Diff line number Diff line change @@ -640,13 +640,21 @@ export class SpringValue<T = any> extends FrameValue<T> {
640640      node . setValue ( ( value  =  from  as  T ) ) 
641641    } 
642642
643+     const  immediate  = 
644+       // Sometimes the value is not animatable. 
645+       ! ( toConfig  ||  is . num ( goal )  ||  is . arr ( goal ) )  || 
646+       ! ! matchProp ( get ( 'immediate' ) ,  key ) 
647+ 
648+     if  ( immediate  !==  anim . immediate )  { 
649+       anim . immediate  =  immediate 
650+       if  ( ! is . und ( to ) )  { 
651+         started  =  true 
652+       } 
653+     } 
654+ 
643655    if  ( started )  { 
644656      anim . values  =  node . getPayload ( ) 
645657      anim . toValues  =  toConfig  ? null  : toArray ( goal ) 
646-       anim . immediate  = 
647-         // Sometimes the value is not animatable. 
648-         ! ( toConfig  ||  is . num ( goal )  ||  is . arr ( goal ) )  || 
649-         ! ! matchProp ( get ( 'immediate' ) ,  key ) 
650658    } 
651659
652660    // Event props are replaced on every update. 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments