mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Support colors in AnimatedInterpolation on Android
Summary: Color support for AnimatedInterpolation was incomplete with native drivers, as only rgba type strings were supported. There was also an issue where color props instead a StyleAnimatedNode would never get applied. We were also potentially duplicating color parsing support, which is already centralized in `normalizeColor` / `processColor`. Changelog: [Android][Added] Enable AnimatedInterpolation to interpolate arbitrary color types. Reviewed By: mdvacca Differential Revision: D40571873 fbshipit-source-id: 41857ab0391279c5307bc31b855ea8fbcb4cccd8
This commit is contained in:
1 parent
b589123a3d
commit
e7dbfb2dbd
8 files changed
+242
-99
No files matched your search
+38
@@ -120,4 +120,42 @@ public class NativeAnimatedInterpolationTest {
|
||||
InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY))
|
||||
.isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterpolateColor() {
|
||||
double[] input = new double[] {0, 1};
|
||||
int[] output = new int[] {0xFF000000, 0xFFFF0000};
|
||||
assertThat(InterpolationAnimatedNode.interpolateColor(0, input, output)).isEqualTo(0xFF000000);
|
||||
assertThat(InterpolationAnimatedNode.interpolateColor(0.5, input, output))
|
||||
.isEqualTo(0xFF7F0000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterpolateString() {
|
||||
double[] input = new double[] {0, 1};
|
||||
double[][] output =
|
||||
new double[][] {
|
||||
new double[] {20, 20, 20, 80, 80, 80, 80, 20},
|
||||
new double[] {40, 40, 33, 60, 60, 60, 65, 40},
|
||||
};
|
||||
String pattern = "M20,20L20,80L80,80L80,20Z";
|
||||
assertThat(
|
||||
InterpolationAnimatedNode.interpolateString(
|
||||
pattern,
|
||||
0,
|
||||
input,
|
||||
output,
|
||||
InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
|
||||
InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY))
|
||||
.isEqualTo("M20,20L20,80L80,80L80,20Z");
|
||||
assertThat(
|
||||
InterpolationAnimatedNode.interpolateString(
|
||||
pattern,
|
||||
0.5,
|
||||
input,
|
||||
output,
|
||||
InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY,
|
||||
InterpolationAnimatedNode.EXTRAPOLATE_TYPE_IDENTITY))
|
||||
.isEqualTo("M30,30L26.5,70L70,70L72.5,30Z");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user