File tree Expand file tree Collapse file tree 1 file changed +30
-19
lines changed
components/src/hardware-sim/Deck Expand file tree Collapse file tree 1 file changed +30
-19
lines changed Original file line number Diff line number Diff line change @@ -116,25 +116,36 @@ export function MoveLabwareOnDeck(
116
116
animationFinalCoordinates
117
117
)
118
118
119
- const springProps = useSpring ( {
120
- reset : shouldReset ,
121
- config : { duration : 1000 , easing : easings . easeInOutSine } ,
122
- from : {
123
- ...animationInitialCoordinates ,
124
- splashOpacity : 0 ,
125
- deckOpacity : 0 ,
126
- } ,
127
- to : [
128
- { deckOpacity : 1 } ,
129
- { splashOpacity : 1 } ,
130
- { splashOpacity : 0 } ,
131
- { ...animationFinalCoordinates } ,
132
- { splashOpacity : 1 } ,
133
- { splashOpacity : 0 } ,
134
- { deckOpacity : 0 } ,
135
- ] ,
136
- loop : true ,
137
- } )
119
+ const [ springProps ] = useSpring (
120
+ ( ) => ( {
121
+ reset : shouldReset ,
122
+ config : { duration : 1000 , easing : easings . easeInOutSine } ,
123
+ from : {
124
+ ...animationInitialCoordinates ,
125
+ splashOpacity : 0 ,
126
+ deckOpacity : 0 ,
127
+ } ,
128
+ to : [
129
+ { deckOpacity : 1 } ,
130
+ { splashOpacity : 1 } ,
131
+ { splashOpacity : 0 } ,
132
+ { ...animationFinalCoordinates } ,
133
+ { splashOpacity : 1 } ,
134
+ { splashOpacity : 0 } ,
135
+ { deckOpacity : 0 } ,
136
+ ] ,
137
+ loop : true ,
138
+ } ) ,
139
+ // Dependency array:
140
+ [
141
+ shouldReset ,
142
+ // react-spring behaves weirdly if its props are updated too frequently.
143
+ // So make sure to filter out coordinate "updates" that are just object identity
144
+ // updates and not updates to the actual x/y/z components.
145
+ ...Object . values ( animationInitialCoordinates ) ,
146
+ ...Object . values ( animationFinalCoordinates ) ,
147
+ ]
148
+ )
138
149
139
150
return (
140
151
< BaseDeck
You can’t perform that action at this time.
0 commit comments