Skip to content

Commit

Permalink
Use Animated.loop(), when possible, to limit JS thread utilization
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesreggio committed Aug 16, 2018
1 parent d9cbb61 commit 5b00247
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions createAnimatableComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,21 +411,12 @@ export default function createAnimatableComponent(WrappedComponent) {
useNativeDriver,
delay: iterationDelay || 0,
};
const iterations = iterationCount === 'infinite' ? -1 : iterationCount;

Animated.timing(animationValue, config).start(endState => {
currentIteration += 1;
if (
endState.finished &&
this.props.animation &&
(iterationCount === 'infinite' || currentIteration < iterationCount)
) {
this.startAnimation(
duration,
currentIteration,
iterationDelay,
callback,
);
} else if (callback) {
Animated.loop(Animated.timing(animationValue, config), {
iterations,
}).start(endState => {
if (callback) {
callback(endState);
}
});
Expand Down

0 comments on commit 5b00247

Please sign in to comment.