0
0
React Nativemobile~20 mins

Spring and decay animations in React Native - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Spring and Decay Animation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2: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}]}} />;
AThe view moves up 100 pixels with a spring effect.
BThe view instantly jumps down 100 pixels without animation.
CThe view moves down 100 pixels but stops abruptly without bouncing.
DThe view smoothly moves down 100 pixels with a bouncing effect.
Attempts:
2 left
💡 Hint
Spring animations create smooth movement with natural bounce.
lifecycle
intermediate
2: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();
AWhen the velocity slows down to near zero due to deceleration.
BOnly when the user manually stops the animation.
CAfter a fixed time of 1 second regardless of velocity.
DIt never stops and loops infinitely.
Attempts:
2 left
💡 Hint
Decay animations simulate friction slowing down movement.
📝 Syntax
advanced
2: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.
AAnimated.spring(position, {toValue: 200, stiffness: 40, damping: 7, useNativeDriver: true}).start();
BAnimated.spring(position, {toValue: 200, tension: 40, friction: 7, useNativeDriver: true}).start();
CAnimated.spring(position, {toValue: 200, tension: 40, friction: 7}).start();
DAnimated.spring(position, {toValue: 200, stiffness: 40, damping: 7}).start();
Attempts:
2 left
💡 Hint
Core Animated.spring uses tension and friction properties. useNativeDriver: true is recommended for performance.
🔧 Debug
advanced
2: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();
AuseNativeDriver must be false for decay to stop.
BVelocity is too high causing infinite movement.
CDeceleration is set to 1, so velocity never decreases and animation never stops.
DMissing toValue causes animation to loop.
Attempts:
2 left
💡 Hint
Deceleration controls how fast velocity slows down.
🧠 Conceptual
expert
2: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?
ASpring animations simulate elastic movement with bounce; decay animations simulate gradual slowing to stop.
BSpring animations move at constant speed; decay animations jump instantly to the end.
CSpring animations only move horizontally; decay animations only move vertically.
DSpring animations require manual stop; decay animations loop infinitely.
Attempts:
2 left
💡 Hint
Think about natural physics effects each animation mimics.