File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -24,21 +24,35 @@ function CompassNeedleResponse (props) {
2424  const  responseEmojis  =  randomNumbers . map ( ( num )  =>  symbols [ num ] ) 
2525  const  rotateDirection  =  Math . round ( random ( ) )  ? 1  : - 1 
2626  const  rotateQuantity  =  Math . ceil ( random ( ) )  // a number between 2 and 3 inclusive 
27-   const  rotateTo  =  getRotation ( randomNumbers [ 0 ] ,  numberOfSymbols )  +  ( 360  *  rotateQuantity  *  rotateDirection ) 
27+   const  rotateTo  =  getRotation ( randomNumbers [ 0 ] ,  numberOfSymbols ) 
28+ 
29+   // calc rotate to: if diff between current and destination is less than 
30+   // one full rotation, then add a full rotation. 
31+   let  actualRotateTo  =  rotateTo 
32+   if  ( rotateDirection  ===  - 1 )  { 
33+     actualRotateTo  =  rotateTo  -  360 
34+   } 
35+   if  ( Math . abs ( initialRotation  -  actualRotateTo )  <  360 )  { 
36+     if  ( initialRotation  >  actualRotateTo )  { 
37+       actualRotateTo  =  actualRotateTo  -  360 
38+     }  else  { 
39+       actualRotateTo  =  actualRotateTo  +  360 
40+     } 
41+   } 
2842
2943  const  spring  =  useSpring ( { 
3044    from : { 
3145      rotate : initialRotation , 
3246      transform : `rotate(${ initialRotation }  
3347    } , 
3448    to : { 
35-       rotate : rotateTo , 
36-       transform : `rotate(${ rotateTo }  
49+       rotate : actualRotateTo , 
50+       transform : `rotate(${ actualRotateTo }  
3751    } , 
3852    config : { 
39-       mass : 10 , 
40-       tension : 160 , 
41-       friction : 60 , 
53+       mass : 1 , 
54+       tension : 15 , 
55+       friction : 6 , 
4256    } 
4357  } ) 
4458
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments