Challenge - 5 Problems
Spring and Decay Animation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the visible effect of this spring animation code?
Consider this React Native code snippet using the Animated API with a spring animation. What will the user see on the screen?
React Native
const position = useRef(new Animated.Value(0)).current; Animated.spring(position, { toValue: 100, useNativeDriver: true }).start(); return <Animated.View style={{transform: [{translateY: position}]}} />;
Attempts:
2 left
💡 Hint
Spring animations create smooth movement with natural bounce.
✗ Incorrect
The spring animation moves the view to 100 pixels down with a natural bounce effect because of the spring physics.
❓ lifecycle
intermediate2:00remaining
When does the decay animation stop automatically?
In React Native, using Animated.decay with a velocity, when will the animation stop by itself?
React Native
const position = useRef(new Animated.Value(0)).current; Animated.decay(position, { velocity: 1, deceleration: 0.997, useNativeDriver: true }).start();
Attempts:
2 left
💡 Hint
Decay animations simulate friction slowing down movement.
✗ Incorrect
Decay animations reduce velocity gradually by deceleration until velocity is near zero, then stop automatically.
📝 Syntax
advanced2:00remaining
Which option correctly uses spring animation with custom tension and friction?
Choose the code snippet that correctly applies a spring animation with tension 40 and friction 7 in React Native.
Attempts:
2 left
💡 Hint
Core Animated.spring uses tension and friction properties. useNativeDriver: true is recommended for performance.
✗ Incorrect
React Native's Animated.spring uses tension and friction for spring config (stiffness/damping are for Reanimated). Option B is correct with useNativeDriver: true.
🔧 Debug
advanced2:00remaining
Why does this decay animation never stop?
This code runs a decay animation but the view keeps moving forever. What is the cause?
React Native
Animated.decay(position, {
velocity: 1,
deceleration: 1,
useNativeDriver: true
}).start();Attempts:
2 left
💡 Hint
Deceleration controls how fast velocity slows down.
✗ Incorrect
A deceleration of 1 means no slowing down, so velocity stays constant and animation never ends.
🧠 Conceptual
expert2:00remaining
How do spring and decay animations differ in user experience?
Which statement best describes the difference in user experience between spring and decay animations in mobile apps?
Attempts:
2 left
💡 Hint
Think about natural physics effects each animation mimics.
✗ Incorrect
Spring animations mimic elastic forces causing bounce; decay animations mimic friction slowing movement gradually.