Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate flickering on color animations #37925

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/react-native/Libraries/Animated/animations/Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import type AnimatedNode from '../nodes/AnimatedNode';
import type AnimatedValue from '../nodes/AnimatedValue';

import NativeAnimatedHelper from '../NativeAnimatedHelper';
import AnimatedColor from '../nodes/AnimatedColor';
import AnimatedProps from '../nodes/AnimatedProps';
import AnimatedValueXY from '../nodes/AnimatedValueXY';

export type EndResult = {finished: boolean, value?: number, ...};
export type EndCallback = (result: EndResult) => void;
Expand Down Expand Up @@ -75,6 +77,17 @@ export default class Animation {
return result;
}

// Vectorized animations (animations on AnimatedValueXY, AnimatedColor nodes)
// are split into multiple animations for each component that execute in parallel.
// Calling update() on AnimatedProps when each animation completes results in
// potential flickering as all animations that are part of the vectorized animation
// may not have completed yet. For example, only the animation for the red channel of
// an animating color may have been completed, resulting in a temporary red color
// being rendered. So, for now, ignore AnimatedProps that use a vectorized animation.
if (node instanceof AnimatedValueXY || node instanceof AnimatedColor) {
return result;
}

for (const child of node.__getChildren()) {
result.push(...this.__findAnimatedPropsNodes(child));
}
Expand Down